It appears that a deployed application using the JMSJCA RA cannot access
singleton objects created by the JMSRA system RA.
This can be seen if you deploy an application that uses JMSJCA to connect to an
embedded MQ broker using MQ's direct mode client rather than the longstanding
TCP mode client.
If you do this, the application fails because it thinks that the embedded broker
is not running. This is because the singleton class used for the two to connect
is being loaded by different class loaders, leading to their being two instances
of this singleton object.
This is a regression from Glassfish 2.1.1, in which JMSJCA+direct mode works
I have written a simple EJB application to demonstrate the issue.
1. Deploy the attached JMSJCA resource adapter.
Please deploy using --libraries
where $GLASSFISH is the root of your glassfish installation (the top-level
directory containing glassfish and mq)
2. Deploy the attached EnterpriseApplicationJMSJCA-ejb.zip
This is a Stateless session bean with one business method, doCase(int x). Call
this with x=1 to execute the test case. It does this:
Connection connection1 =
Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer =
where the connection factory and destination are defined in sun-resources.xml
3. Deploy the attached EnterpriseApplicationJMSJCA-war.zip
This is a simple servlet which invokes the session bean.
4. Start the embedded broker
Make sure the JMSRA is has been lazily started by invoking "asadmin jms-ping"
5. Run the test case
To run the test case, install the RA and use Netbeans to deploy both
applications (Netbeans should create the required resources).
Then use a web browser to goto
Look at the server log. This will show the errors:
WARNING: [I500]: Caught JVM Exception: java.lang.RuntimeException: Direct broker
not initialized for this client runtime.
WARNING: [C4003]: Error occurred on connection creation [mq://localhost/direct].
- cause: javax.jms.JMSException: Direct broker not initialized for this client
5. More information
I believe the reason for this error is that I am getting duplicate classes
which mean I get duplicate copies of each class's singleton instance.
These classes can be found in the following jars:
(though I got the same error even if I removed the relevant classes from
imqjmsra.jar and copied imq.jar into $GLASSFISH/glassfish/lib/install/applications)
One instance is created when JMSRA is started and is loaded by EJBClassLoader.
The other instance is created when the application is run, and is loaded by
6. Workaround attemts
I had several attemots at working round this issue:
6A: I left sun-jms-adapter deployed using the --libraries option and added the
same jars to "classpath-suffix". This made no difference, the tests still failed
with the duplicate class problem. (I did the same for classpath-prefix).
6B: I then removed the --libraries option and repeated the test. Now the test
failed with a class not found error: sun-jms-adapter could not find the MQ
client classes, despite the jars being included in in the jars added by
6C: If I simply add the jars to domains/domain1/lib everything passes fine.
Obviously this is not a solution, but it shows how this is a classpath/class