Steps to reproduce: ===================== Start Glassfish and configure the jms resources ===================== Environment: $ ./asadmin version --verbose Version = Oracle GlassFish Server 3.1.2.3 (build 2), JRE version 1.6.0_37 Command version executed successfully. gf@linux:/opt/GFv312/bin $ ./asadmin start-domain domain1 .... gf@linux:/opt/GFv312/bin $ ./asadmin create-jms-resource --restype=javax.jms.QueueConnectionFactory --enabled=true ConnectionFactory Connector resource ConnectionFactory created. Command create-jms-resource executed successfully. gf@linux:/opt/GFv312/bin $ ./asadmin create-jms-resource --restype=javax.jms.Queue --enabled=true queue/MessageDriveBeanOSGI Administered object queue/MessageDriveBeanOSGI created. Command create-jms-resource executed successfully. ===================== Unzip the testcase and create the maven project ===================== gf@linux:/testing/MyOSGI $ unzip mainProject-v2.zip gf@linux:/testing/MyOSGI $ cd mainProject gf@linux:/testing/MyOSGI/mainProject $ mvn package ... Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 ... [INFO] [ejb:ejb {execution: default-ejb}] [INFO] Building EJB messageReceiver-0.0.1-SNAPSHOT with EJB version 3.1 [INFO] Building jar: /testing/MyOSGI/mainProject/messageReceiver/target/messageReceiver-0.0.1-SNAPS HOT.jar [INFO] META-INF/maven/com.macd/messageReceiver/pom.xml already added, skipping [INFO] META-INF/maven/com.macd/messageReceiver/pom.properties already added, skipping ... [INFO] BUILD SUCCESSFUL ... ===================== Open a second terminal and monitor the server.log using tail ===================== $ tail -f /opt/GFv312/glassfish/domains/domain1/log/server.log ===================== Deploy the Message Receiver and the OSGI Bundle ===================== gf@linux:/testing/MyOSGI $ /opt/GFv312/bin/asadmin deploy --force mainProject/messageReceiver/target/messageReceiver-0.0.1-SNAPSHOT.jar Application deployed with name messageReceiver-0.0.1-SNAPSHOT. Command deploy executed successfully. gf@linux:/testing/MyOSGI $ /opt/GFv312/bin/asadmin deploy --force --type=osgi mainProject/osgiBundle/target/osgiBundle-0.0.1-SNAPSHOT.jar Application deployed with name osgiBundle-0.0.1-SNAPSHOT. Command deploy executed successfully. ===================== satisfy classpath dependencies for the java client ===================== gf@linux:/testing/MyOSGI $ CLASSPATH=/opt/GFv312/glassfish/modules/*:/opt/GFv312/glassfish/lib/install/ap plications/jmsra/* ===================== run the MessageSender client at least 1 time ===================== gf@linux:/testing/MyOSGI $ java -cp $CLASSPATH:mainProject/externalMessageSender/target/classes:mainProject/osgiBu ndle/target/osgiBundle-0.0.1-SNAPSHOT.jar com.macd.external.MessageSender MessageSender.main() MessageSender.sendMessage() Dec 11, 2012 5:48:49 PM org.hibernate.validator.internal.util.Version INFO: HV000001: Hibernate Validator 4.3.0.Final Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5.2 Patch 1 (Build 3-d) Compile: Thu Jun 7 10:46:15 PDT 2012 Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is REMOTE, connection mode is TCP Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:REMOTE Message sent successfully to remote queue. Sent message: MyOSGI [] MyOSGI instanceof MyOSGI: true ---> within server.log you will see few messages reported, ---> all is woring fine ===================== Now Re-Deploy the Message Receiver and the OSGI Bundle using ... ===================== gf@linux:/testing/MyOSGI $ /opt/GFv312/bin/asadmin deploy --force mainProject/messageReceiver/target/messageReceiver-0.0.1-SNAPSHOT.jar Application deployed with name messageReceiver-0.0.1-SNAPSHOT. Command deploy executed successfully. gf@linux:/testing/MyOSGI $ /opt/GFv312/bin/asadmin deploy --force --type=osgi mainProject/osgiBundle/target/osgiBundle-0.0.1-SNAPSHOT.jar Application deployed with name osgiBundle-0.0.1-SNAPSHOT. Command deploy executed successfully. ===================== run the MessageSender client at least 1 time again ===================== gf@linux:/testing/MyOSGI $ java -cp $CLASSPATH:mainProject/externalMessageSender/target/classes:mainProject/osgiBu ndle/target/osgiBundle-0.0.1-SNAPSHOT.jar com.macd.external.MessageSender MessageSender.main() MessageSender.sendMessage() Dec 11, 2012 5:48:49 PM org.hibernate.validator.internal.util.Version INFO: HV000001: Hibernate Validator 4.3.0.Final Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5.2 Patch 1 (Build 3-d) Compile: Thu Jun 7 10:46:15 PDT 2012 Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is REMOTE, connection mode is TCP Dec 11, 2012 5:48:50 PM com.sun.messaging.jms.ra.ResourceAdapter start INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:REMOTE Message sent successfully to remote queue. Sent message: MyOSGI [] MyOSGI instanceof MyOSGI: true -> within Server log you get the mentioned java.lang.ClassCastException, -> as long as you did not restart Glassfish (asadmin stop/start-domain)