1 Reply Latest reply on Jul 17, 2013 8:14 AM by Tomaz Cerar

    Using a user module results in NoClassDefFoundError:  javax/management/InstanceNotFoundException

    thorkummer Newbie

      Hi

       

      I'm trying to deploy some common MBean functionality as a module in JBoss 7.1, but I get an exception when I deploy an EAR with a SAR that uses the module.

       

      My additions to the module tree under jboss7.1/modules are:

       

      modules/

        com/

          one/

            common/

              jmx/

                main/

                  common-jmx.jar

                  common-jmx.jar.index

                  module.xml

                     | <?xml version="1.0" encoding="UTF-8"?>

                     | <module xmlns="urn:jboss:module:1.0" name="com.one.common.jmx">

                     |     <resources>

                     |         <resource-root path="common-jmx.jar" />

                     |     </resources>

                     |     <dependencies>

                     |         <module name="org.quartz-scheduler" />

                     |         <module name="org.apache.log4j" />

                     |         <module name="javax.management.j2ee.api" />

                     |     </dependencies>

                     | </module>

              utils/

                main/

                  common-utils.jar

                  common-utils.jar.index

                  module.xml

                     | <?xml version="1.0" encoding="UTF-8"?>

                     | <module xmlns="urn:jboss:module:1.0" name="com.one.common.utils">

                     |     <resources>

                     |         <resource-root path="common-utils.jar" />

                     |     </resources>

                     |     <dependencies>

                     |         <module name="javax.persistence.api"/>

                     |         <module name="org.apache.log4j"/>

                     |         <module name="javaee.api"/>

                     |     </dependencies>

                     | </module>

        org/

          quartz-scheduler/

            main/

              module.xml

                 | <?xml version="1.0" encoding="UTF-8"?>

                 | <module xmlns="urn:jboss:module:1.0" name="org.quartz-scheduler">

                 |     <resources>

                 |         <resource-root path="quartz-2.1.7.jar" />

                 |         <resource-root path="quartz-jboss-2.1.7.jar" />

                 |     </resources>

                 | </module>

              quartz-2.1.7.jar

              quartz-2.1.7.jar.index

              quartz-jboss-2.1.7.jar

              quartz-jboss-2.1.7.jar.index

       

      The structure of the ear is (with SAR file exploded):

       

      mailer.ear

        mailer-ejb-impl.jar

        mailer-persistence.jar

        META-INF/

          MANIFEST.MF

          application.xml

            | <?xml version="1.0"?>

            | <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">

            |   <display-name>mailer</display-name>

            |   <module>

            |     <ejb>mailer-ejb-impl.jar</ejb>

            |   </module>

            |   <module>

            |     <ejb>mailer-jmx.sar</ejb>

            |   </module>

            |   <module>

            |     <ejb>mailer-persistence.jar</ejb>

            |   </module>

            |   <library-directory>lib</library-directory>

            | </application>

          jboss-deployment-structure.xml

            | <?xml version="1.0" encoding="UTF-8"?>

            | <jboss-deployment-structure><!--  xmlns="urn:jboss:deployment-structure:1.1" -->

            |

            |   <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

            |

            |   <deployment>

            |     <dependencies>

            |       <module name="deployment.systemproperties-jmx.jar" />

            |       <module name="com.one.common.utils" export="true" />

            |       <module name="com.one.common.jmx" export="true" />

            |     </dependencies>

            |   </deployment>

            |  

            | </jboss-deployment-structure>

        lib/

          XmlSchema-1.4.7.jar

          apache-mime4j-core-0.7.2.jar

          axiom-api-1.2.13.jar

          axiom-impl-1.2.13.jar

          axis2-kernel-1.6.2.jar

          b-one-utils.jar

          bcmail-jdk14-138.jar

          bcprov-jdk14-138.jar

          commons-codec-1.2.jar

          commons-fileupload-1.2.jar

          commons-httpclient-3.1.jar

          commons-logging-1.1.1.jar

          geronimo-activation_1.1_spec-1.1.jar

          geronimo-javamail_1.4_spec-1.7.1.jar

          geronimo-jta_1.1_spec-1.1.jar

          geronimo-stax-api_1.0_spec-1.0.1.jar

          geronimo-ws-metadata_2.0_spec-1.1.2.jar

          itext-2.1.5.jar

          jaxen-1.1.3.jar

          jsr311-api-1.0.jar

          log4j-1.2.16.jar

          mailer-ejb-api.jar

          mailer-utils.jar

          neethi-3.0.2.jar

          servlet-api-2.5.jar

          sysdev-ejb-api.jar

          vies-ws-1.0.jar

          woden-api-1.0M9.jar

          woden-impl-commons-1.0M9.jar

          woden-impl-dom-1.0M9.jar

          wsdl4j-1.6.2.jar

          wstx-asl-3.2.9.jar

        mailer-jmx.sar/

          META-INF/

            MANIFEST.MF

            jboss-service.xml

              | <?xml version="1.0" encoding="UTF-8"?>

              | <server xmlns="urn:jboss:service:7.0"

              |       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              |       xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">

              |          

              |     <mbean code="dk.bone.projects.mailer.MailService" name="bone.schedulable:service=MailService">

              |         <attribute name="Timeout">30000</attribute>

              |         <attribute name="SmtpServer">localhost</attribute>

              |         <attribute name="MaxMails">200</attribute>

              |         <attribute name="SkipInitialInvocations">6</attribute>

              |     </mbean>

              |     <mbean code="com.one.common.jmx.Scheduler" name="bone.schedulers:service=MailScheduler">

              |         <attribute name="StartAtStartup">true</attribute>

              |         <attribute name="SchedulableMBean">bone.schedulable:service=MailService</attribute>

              |         <attribute name="SchedulableMBeanMethod">execute()</attribute>

              |         <attribute name="InitialStartDate">NOW</attribute>

              |         <attribute name="SchedulePeriod">5000</attribute>

              |         <attribute name="InitialRepetitions">-1</attribute>

              |         <attribute name="TimerName">jboss:service=MailTimer</attribute>

              |     </mbean>

              |          

              | </server>

          dk/

            bone/

              projects/

                mailer/

                  MailSender$ByteArrayDataSource.class

                  MailSender.class

                  MailSenderException.class

                  MailService.class

                  MailServiceMBean.class

       

       

      The exeception I get when I try to deploy my ear is:

       

      12:19:28,773 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit."mailer.ear"."mailer-jmx.sar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."mailer.ear"."mai

      ler-jmx.sar".INSTALL: Failed to process phase INSTALL of subdeployment "mailer-jmx.sar" of deployment "mailer.ear"

              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_26]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_26]

              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

      Caused by: java.lang.RuntimeException: Error getting reflective information for class com.one.common.jmx.Scheduler with ClassLoader ModuleClassLoader for Module "com.one.common.jmx:main" from local module loader @47315d34 (roots: /opt/jboss7.1/modules,/opt/jbos

      s7.1/user-modules)

              at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

              at org.jboss.as.service.ReflectionUtils.getClassHierarchy(ReflectionUtils.java:124)

              at org.jboss.as.service.ParsedServiceDeploymentProcessor.addServices(ParsedServiceDeploymentProcessor.java:108)

              at org.jboss.as.service.ParsedServiceDeploymentProcessor.deploy(ParsedServiceDeploymentProcessor.java:99)

              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

              ... 5 more

      Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceNotFoundException

              at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.6.0_26]

              at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [rt.jar:1.6.0_26]

              at java.lang.Class.getDeclaredFields(Class.java:1743) [rt.jar:1.6.0_26]

              at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

              at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

              ... 9 more

      Caused by: java.lang.ClassNotFoundException: javax.management.InstanceNotFoundException from [Module "com.one.common.jmx:main" from local module loader @47315d34 (roots: /opt/jboss7.1/modules,/opt/jboss7.1/user-modules)]

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

              ... 14 more

       

      I found the class javax.management.InstanceNotFoundException in rt.jar in java 6.

       

      The whole thing works fine when I deploy the utility jars with the application rather than as a module.

       

      The reason I'm trying to deploy them as a module rather than with the application is because they are used by multiple ears and the MBean container appearantly gets confused when it meets the same MBean from a different classloader and says the the MBean cannot access it's superclass.

       

      Any help greatly appriciated.