12 Replies Latest reply on Aug 13, 2015 9:16 AM by bohremsdaq

    Wildfly 9 NoClassDefFoundError javax.jms

    jlstephens89

      We have an application running on Wildfly 8 that uses an ActiveMQ resource adapter with no issues. When we deploy the same application to Wildfly 9 we get the following exception:

       

      java.lang.ClassCastException: org.apache.activemq.command.ActiveMQTopic cannot be cast to javax.jms.Topic

       

      I've done the same test using the jboss quickstarts application "helloworld-mdb"  and suffer from the same problem but the NoClassDefFoundError points to javax.jms.Destination (same issue just a different class used first).

       

      jboss-eap-quickstarts/helloworld-mdb at 7.0.x-develop · jboss-developer/jboss-eap-quickstarts · GitHub

       

      This is obviously a Classpath issue but because this issue occurs with the helloworld project it suggests to me that this is something wrong with one of the modules in the default Wildfly 9 setup or possibly an issue with the ActiveMQ adapter that only shows up in 9 and is not an issue with the project itself.

       

      Is there a way for me to list all jars + their dependencies on the classpath in wildfly (a bit like the Maven dependency tree)? If not what other steps can I take.

        • 1. Re: Wildfly 9 NoClassDefFoundError javax.jms
          jaikiran

          Can you paste the entire ClassCastException stacktrace? Also paste the output of:

           

          jar -tf yourear.ear

           

          to show us what jars are packaged within the .ear.

          • 2. Re: Wildfly 9 NoClassDefFoundError javax.jms
            ctomc

            start server with -c standalone-full.xml that will include messaging support.

             

            also, wildfly has its own set of quickstarts wildfly/quickstart · GitHub

            • 3. Re: Wildfly 9 NoClassDefFoundError javax.jms
              jlstephens89

              Jaikiran/Tomaz thank you for your responses.

               

              I've tried both standalone.xml and standalone-full.xml and neither work (I have no issue getting this simple example to work in Wildfly 8).

               

              The output of jar -tf (as you can see all dependencies are marked as provided):

               

              META-INF/

              META-INF/MANIFEST.MF

              WEB-INF/

              WEB-INF/classes/

              WEB-INF/classes/org/

              WEB-INF/classes/org/jboss/

              WEB-INF/classes/org/jboss/as/

              WEB-INF/classes/org/jboss/as/quickstarts/

              WEB-INF/classes/org/jboss/as/quickstarts/mdb/

              WEB-INF/classes/org/jboss/as/quickstarts/servlet/

              1. index.html

              WEB-INF/beans.xml

              WEB-INF/classes/org/jboss/as/quickstarts/mdb/HelloWorldQueueMDB.class

              WEB-INF/classes/org/jboss/as/quickstarts/mdb/HelloWorldTopicMDB.class

              WEB-INF/classes/org/jboss/as/quickstarts/servlet/HelloWorldMDBServletClient.class

              META-INF/maven/org.wildfly.quickstarts/wildfly-helloworld-mdb/pom.xml

              META-INF/maven/org.wildfly.quickstarts/wildfly-helloworld-mdb/pom.properties

               

               

              Full stack trace:

               

              11:48:09,326 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."wildfly-helloworld-mdb.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."wildfly-helloworld-mdb.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "wildfly-helloworld-mdb.war"

              [Server:primary4i]      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163)

              [Server:primary4i]      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

              [Server:primary4i]      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

              [Server:primary4i]      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

              [Server:primary4i]      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

              [Server:primary4i]      at java.lang.Thread.run(Thread.java:745)

              [Server:primary4i] Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module "deployment.wildfly-helloworld-mdb.war:main" from Service Module Loader

              [Server:primary4i]      at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

              [Server:primary4i]      at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)

              [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)

              [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)

              [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)

              [Server:primary4i]      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156)

              [Server:primary4i]      ... 5 more

              [Server:primary4i] Caused by: java.lang.NoClassDefFoundError: javax/jms/Destination

              [Server:primary4i]      at java.lang.Class.getDeclaredFields0(Native Method)

              [Server:primary4i]      at java.lang.Class.privateGetDeclaredFields(Class.java:2583)

              [Server:primary4i]      at java.lang.Class.getDeclaredFields(Class.java:1916)

              [Server:primary4i]      at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57)

              [Server:primary4i]      at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

              [Server:primary4i]      ... 10 more

              [Server:primary4i] Caused by: java.lang.ClassNotFoundException: javax.jms.Destination from [Module "deployment.wildfly-helloworld-mdb.war:main" from Service Module Loader]

              [Server:primary4i]      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

              [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

              [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

              [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

              [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

              [Server:primary4i]      ... 15 more

              [Server:primary4i]

              [Server:primary4i] 11:48:09,343 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 67) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "wildfly-helloworld-mdb.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"wildfly-helloworld-mdb.war\"

              [Server:primary4i]     Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader

              [Server:primary4i]     Caused by: java.lang.NoClassDefFoundError: javax/jms/Destination

              [Server:primary4i]     Caused by: java.lang.ClassNotFoundException: javax.jms.Destination from [Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader]"}}

              [Server:primary4i] 11:48:09,366 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 67) WFLYSRV0021: Deploy of deployment "wildfly-helloworld-mdb.war" was rolled back with the following failure message:

              [Server:primary4i] {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"wildfly-helloworld-mdb.war\"

              [Server:primary4i]     Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader

              [Server:primary4i]     Caused by: java.lang.NoClassDefFoundError: javax/jms/Destination

              [Server:primary4i]     Caused by: java.lang.ClassNotFoundException: javax.jms.Destination from [Module \"deployment.wildfly-helloworld-mdb.war:main\" from Servi

              • 4. Re: Wildfly 9 NoClassDefFoundError javax.jms
                mayerw01

                Did you verify in the log file that your ActiveMQ resource adapter is started successfully in Wildfly 9?

                • 5. Re: Wildfly 9 NoClassDefFoundError javax.jms
                  ctomc

                  ah,

                  you are running in domain mode not standalone.

                  in that case standalone-full.xml doesn't have any efffect on you.

                   

                  you should use "full" profile to run you application not "default".

                  If you use custom profile, you should make sure that profile you assigned to this server group(that has server primary4i in) has hornetq subsystem present.

                  default profile doesn't.

                  • 6. Re: Wildfly 9 NoClassDefFoundError javax.jms
                    bohremsdaq

                    Tomaz,

                    We are using the Full-ha profile in domain mode to run the application. The helloworld-mdb is now working using hornetq, but we are required to use activemq as an external message broker. I have added the activemq-rar.rar to $JBOSS_HOME//modules/system/layers/base/org/apache/activemq/main. I have edited the ra.xml and removed the section where it says "<!-- NOTE disable the following property if you do not wish to deploy an embedded broker -->", do I also need to remove the broker.xml file from the archive. I have tried to deploy as an archive and it appears to have worked as I get this message in the server.log "IJ020002: Deployed: file://RaActivatoractivemq-rar.rar" then ": Started message driven bean 'HelloWorldQTopicMDB' with 'activemq-rar.rar' resource adapter" and "INFO  [org.jboss.as.messaging] (MSC service thread 1-2) WFLYMSG0002: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory", however when I run the app and do the "http://ipaddress:8080/wildfly-helloworld-mdb/HelloWorldMDBServletClient" it still seem to be using the hornetq subsystem, as I get this in the log

                    "[Server:primary4i] 08:59:31,013 INFO  [class org.jboss.as.quickstarts.mdb.HelloWorldQueueMDB] (Thread-5 (HornetQ-client-global-threads-605257470)) Received Message from queue: This is message 1" copied to message 5.

                    and if i look in the activemq broker I do not see any of the queues or topics.

                     

                    I have attached the full-ha profile from our domain.xml file and the activemq-rar.rar.

                    • 7. Re: Wildfly 9 NoClassDefFoundError javax.jms
                      mayerw01

                      I understand the suggested configuration is a bit different How to Use Out of Process ActiveMQ with WildFly

                      • 8. Re: Wildfly 9 NoClassDefFoundError javax.jms
                        bohremsdaq

                        Wolfgang,

                         

                        I have followed the instructions and again it seems to load the ra module, but when I deploy the hellowworld-mdb.war i get the error below

                         

                        "

                        [Server:primary4i] 11:31:30,796 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."wildfly-helloworld-mdb.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."wildfly-helloworld-mdb.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "wildfly-helloworld-mdb.war"

                        [Server:primary4i]      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:163)

                        [Server:primary4i]      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

                        [Server:primary4i]      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

                        [Server:primary4i]      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                        [Server:primary4i]      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                        [Server:primary4i]      at java.lang.Thread.run(Thread.java:745)

                        [Server:primary4i] Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module "deployment.wildfly-helloworld-mdb.war:main" from Service Module Loader

                        [Server:primary4i]      at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

                        [Server:primary4i]      at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)

                        [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)

                        [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)

                        [Server:primary4i]      at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)

                        [Server:primary4i]      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:156)

                        [Server:primary4i]      ... 5 more

                        [Server:primary4i] Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSException

                        [Server:primary4i]      at java.lang.Class.getDeclaredFields0(Native Method)

                        [Server:primary4i]      at java.lang.Class.privateGetDeclaredFields(Class.java:2583)

                        [Server:primary4i]      at java.lang.Class.getDeclaredFields(Class.java:1916)

                        [Server:primary4i]      at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57)

                        [Server:primary4i]      at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

                        [Server:primary4i]      ... 10 more

                        [Server:primary4i] Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException from [Module "deployment.wildfly-helloworld-mdb.war:main" from Service Module Loader]

                        [Server:primary4i]      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

                        [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

                        [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

                        [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

                        [Server:primary4i]      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

                        [Server:primary4i]      ... 15 more

                        [Server:primary4i]

                        [Server:primary4i] 11:31:30,819 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 72) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "wildfly-helloworld-mdb.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"wildfly-helloworld-mdb.war\"

                        [Server:primary4i]     Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader

                        [Server:primary4i]     Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSException

                        [Server:primary4i]     Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException from [Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader]"}}

                        [Server:primary4i] 11:31:30,848 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 72) WFLYSRV0021: Deploy of deployment "wildfly-helloworld-mdb.war" was rolled back with the following failure message:

                        [Server:primary4i] {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"wildfly-helloworld-mdb.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"wildfly-helloworld-mdb.war\"

                        [Server:primary4i]     Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient with ClassLoader ModuleClassLoader for Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader

                        [Server:primary4i]     Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSException

                        [Server:primary4i]     Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException from [Module \"deployment.wildfly-helloworld-mdb.war:main\" from Service Module Loader]"}}

                        "

                        I have followed the guide in quickstarts (Comparing wildfly:9.x...jmesnil:helloworld-mdb-activemq-ra · wildfly/quickstart · GitHub) on how to change helloworld to use activemq and packeaged for deployment.

                         

                        I have attached my activemq directory - zipped and the wildfly-helloworld-mdb.war file

                        • 9. Re: Wildfly 9 NoClassDefFoundError javax.jms
                          mayerw01

                          I was just testing the ActiveMq and it runs fine. Are you sure you applied all the changes mentioned in Comparing wildfly:master...jmesnil:helloworld-mdb-activemq-ra · jmesnil/quickstart · GitHub

                          It looks like some imports are missing in your source files

                          • 10. Re: Wildfly 9 NoClassDefFoundError javax.jms
                            bohremsdaq

                            Wolfgang,

                             

                            I have redone the quickstart and basically copied the full file instead of trying to edit it. This worked and activemq was seeing the topics and queues. For reference in case anyone else gets directed here. The Resource-adapters reference and subsection subsection that finally worked was :-

                            <subsystem xmlns="urn:jboss:domain:ejb3:3.0">

                            ...

                                        <mdb>
                                            <resource-adapter-ref resource-adapter-name="activemq-rar"/>
                                            <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
                                        </mdb>

                            ...

                            </subsystem>

                             

                            <subsystem xmlns="urn:jboss:domain:resource-adapters:3.0">

                                            <resource-adapters>

                                                <resource-adapter id="activemq-rar.rar">

                                                    <module slot="main" id="org.apache.activemq.ra"/>

                                                    <transaction-support>XATransaction</transaction-support>

                                                    <config-property name="ServerUrl">

                                                        tcp://activemqipaddress?jms.rmIdFromConnectionId=true

                                                    </config-property>

                                                    <config-property name="UserName">

                                                        username

                                                    </config-property>

                                                    <config-property name="UseInboundSession">

                                                        false

                                                    </config-property>

                                                    <config-property name="Password">

                                                        password

                                                    </config-property>

                                                    <connection-definitions>

                                                        <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ConnectionFactory" enabled="true" pool-name="ConnectionFactory">

                                                            <xa-pool>

                                                                <min-pool-size>1</min-pool-size>

                                                                <max-pool-size>20</max-pool-size>

                                                                <prefill>false</prefill>

                                                                <is-same-rm-override>false</is-same-rm-override>

                                                            </xa-pool>

                                                        </connection-definition>

                                                    </connection-definitions>

                                                    <admin-objects>

                                                        <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/HELLOWORLDMDBQueue" use-java-context="true" pool-name="HELLOWORLDMDBQueue">

                                                            <config-property name="PhysicalName">

                                                                HELLOWORLDMDBQueue

                                                            </config-property>

                                                        </admin-object>

                                                    <admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="java:/topic/HELLOWORLDMDBTopic" use-java-context="true" pool-name="HELLOWORLDMDBTopic">
                                                        <config-property name="PhysicalName">
                                                            HELLOWORLDMDBTopic
                                                        </config-property>
                                                    </admin-object>
                                                </admin-objects>
                                            </resource-adapter>
                                        </resource-adapters>
                                    </subsystem>

                             

                             

                             

                             

                             

                            The activemq I used was 5.11.1, which I placed in $JBOSS_HOME/modules/system/layers/base/org/apache/. The Archive is too larege to attach ~32Mb though.

                            • 11. Re: Wildfly 9 NoClassDefFoundError javax.jms
                              mayerw01

                              So does this mean that everything is working now?

                              The only difference i see so far is that I used the values from the documentation instead. So I left this line unchanged:

                              <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:hornetq-ra.rar}"/>

                               

                              Btw what is the reason that you placed activemq into the AS directory?

                              I just stored it to some directory outside WildFly to be independent of the WildFly installation.

                              • 12. Re: Wildfly 9 NoClassDefFoundError javax.jms
                                bohremsdaq

                                Wolfgang, at this stage everything appears to be working, our client application is talking to the server and receiving messages via activemq. The activemq I have put in the AS directory is the activemq-rar.rar file expanded as per the How to Use Out of Process ActiveMQ with WildFly,  I have my actual Activemq broker that does the messaging on a different virtual machine. Thanks for the help. The thing I did differently though this time was leave the activemq-rar.rar file in the directory once I had expanded it (not included in the module.xml file though.

                                For completeness the directory struture was $JBOSS_HOME/modules/system/layers/base/org/apache/activemq/ra/main/