martes, 23 de octubre de 2012

Passing values containing commas in the jndiProperties parameter of GenericJMSRA

I'm trying the Open Source Glassfish's Generic Resource Adapter for JMS (GenericJMSRA aka GenericRA) and need to supply a value that contains commas for one of the provider specific parameters of the jndiProperties parameter.

I have for example this jndiProperties's value (used to work with Websphere Application Server JMS resources): 

java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory,
java.naming.provider.url=corbaloc::myhost1:9810,:myhost1:9811,
com.ibm.CORBA.ORBInit=com.ibm.ws.sib.client.ORB,
java.naming.security.principal=USERNAME,java.naming.security.credentials=PASWORD

As you can see, the value of the java.naming.provider.url sub-parameter contains a comma, but the global jndiProperties value is also comma separated. GenericRA supports "special" character scaping, so you can do this:

java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory,
java.naming.provider.url=corbaloc::myhost1:9810\,:myhost1:9811,
com.ibm.CORBA.ORBInit=com.ibm.ws.sib.client.ORB,
java.naming.security.principal=USERNAME,java.naming.security.credentials=PASWORD

BUT, the value that the providers's code is receiving, stills contains the comma: corbaloc::myhost1:9810\,:myhost1:9811, causing errors like the following (in Websphere's case):

Caused by: javax.naming.ConfigurationException: Malformed provider URL: corbaloc::myhost1:9810\,:myhost1:9811 [Root exception is org.omg.CORBA.BAD_PARAM: For input string: "9810\" in 9810\  vmcid: OMG  minor code: 9  completed: No]
    at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBootstrapURL(WsnInitCtxFactory.java:1508)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:389)
    at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:113)
    at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:428)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:144)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at com.sun.genericra.util.ObjectBuilderFactory$JndiObjectBuilder.createObject(ObjectBuilderFactory.java:97)
    ... 24 more
Caused by: org.omg.CORBA.BAD_PARAM: For input string: "9810\" in 9810\  vmcid: OMG  minor code: 9  completed: No
    at com.ibm.rmi.corba.IIOPAddrImpl.setPort(IIOPAddrImpl.java:185)
    at com.ibm.rmi.corba.IIOPAddrImpl.(IIOPAddrImpl.java:107)
    at com.ibm.rmi.corba.Corbaloc.parseObjAddr(Corbaloc.java:230)
    at com.ibm.rmi.corba.Corbaloc.parseObjAddrList(Corbaloc.java:184)
    at com.ibm.rmi.corba.Corbaloc.parseCorbaloc(Corbaloc.java:141)
    at com.ibm.rmi.corba.Corbaloc.(Corbaloc.java:119)
    at com.ibm.rmi.corba.ORB.createObjectURL(ORB.java:3890)
    at com.ibm.rmi.corba.ORB.createObjectURL(ORB.java:3853)
    at com.ibm.CORBA.iiop.ORB.createObjectURL(ORB.java:3416)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBootstrapURL(WsnInitCtxFactory.java:1503)
    ... 30 more


I found there's an reported bug that, although is related to other use case, has the same underlying cause: imqAddressList doesn't get parsed properly when passed to resource adapter config.

I found the proposed bug fix works for me, so I'm compiling an "ObjectBuilder" version that contains the fix.