10 Replies Latest reply on May 15, 2013 10:12 AM by Stephen Coy

    jboss-deployment-structure.xml cannot access files in EAR/lib

    surendrand001 Newbie

      Hi,

      I am tring to deploy an EAR as standalone in Jboss AS 7

       

      My EAR structure is as follows

       

      MyDeployment.EAR

      ---lib/ folder with jar files

      ---foo.jar

      ---bar.jar

      ---baz.jar

      ---qux.war

       

      my jboss-deployment-structure.xml is as follows

       

           <sub-deployment name="foo.jar">

              <dependencies>

                  <module name="deployment.qux"/>

              </dependencies>

          </sub-deployment>

       

          <sub-deployment name="bar.jar">

              <dependencies>

                  <module name="deployment.qux"/>

              </dependencies>

          </sub-deployment>

       

           <module name="deployment.qux">

              <resources>

                  <resource-root path="baz.jar" />

              </resources>

          </module>

       

       

      In my case baz.jar is dependent on some libraries inside EAR/lib folder

       

      When ever I try to deploy. I am getting NoclassDefinitionFound Error for all jar's inside by EAR/lib

      As per the documentation Jboss should automatically resolve the jar's under EAR/lib, but its not getting loaded

       

      is there anything I need to specify in <resource-root> tag line <filter> ?

      Is there any other place I need to specify the dependencies.

       

      Thanks

        • 1. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
          jaikiran pai Master

          Let's keep aside the jboss-deployment-structure.xml for now. What kind of jar is baz.jar? Is it a subdeployment? If yes, what kind of sub deployment? Do you have an application.xml, what does it look like?

          • 2. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
            surendrand001 Newbie

            baz.jar is not a sub deployment

             

            I have an application.xml as follows

             

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

            <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_5.xsd" version="5">

             

             

              <display-name>MyDeploymentEAR</display-name>

             

              <module>

                <java>foo.jar</java>

              </module>

              <module>

                <ejb>bar.jar</ejb>

              </module>

              <module>

                <web>

                  <web-uri>qux.war</web-uri>

                  <context-root>/App/index</context-root>

                </web>

              </module>

            </application>

            • 3. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
              jaikiran pai Master

              Surendran D wrote:

               

              baz.jar is not a sub deployment

               

              If baz.jar is not a subdeployment, then it needs to be placed within the .ear/lib folder too.

              • 4. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                surendrand001 Newbie

                I tried placing baz.jar inside .ear/lib folder.

                 

                Now I am getting java.lang.ClassNotFoundException for class in baz.jar files.

                • 5. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                  jaikiran pai Master

                  Please post the entire exception stacktrace and a bit more details about what the application is doing.

                  • 6. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                    surendrand001 Newbie

                    My Exception is as follows;

                     

                    I have MySystemDTO inside Baz.jar which is refered inside jboss-deployment-structure.xml as follows

                     

                          <module name="deployment.qux">

                            <resources>

                                <resource-root path="baz.jar" />

                            </resources>

                        </module>

                     

                     

                     

                    I have another EmployeeBean which is refered in a library inside .ear/lib in my case business.jar

                     

                    Current EAR structure is as follows

                     

                    MyDeployment.EAR

                    ---lib/ folder with jar files (business.jar)

                    ---foo.jar

                    ---bar.jar

                    ---baz.jar

                    ---qux.war

                     

                    When I try to deploy I get following exception.

                     

                    11:03:28,890 WARN  [org.jboss.modules] (MSC service thread 1-9) Failed to define class com.example.test.MySystemDTO in Module "deployment.qux:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/example/test/MySystemDTO (Module "deployment.qux:main" from Service Module Loader)

                              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)

                              at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)

                              at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)

                              at org.jboss.modules.Module.loadModuleClass(Module.java:517)

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

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

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

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

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

                              at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)

                              at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:489) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                              at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:851) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                              at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:596) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

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

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

                              at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_17]

                    Caused by: java.lang.NoClassDefFoundError: com/example/service/base/EmployeeBean

                              at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_17]

                              at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_17]

                              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [rt.jar:1.6.0_17]

                              at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)

                              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)

                              ... 20 more

                     

                     

                    When I move my baz.jar inside lib folder I get exception as follows.

                     

                    MyDeployment.EAR

                    ---lib/ folder with jar files (business.jar, baz.jar)

                    ---foo.jar

                    ---bar.jar

                    ---qux.war

                     

                     

                    Caused by: java.lang.NoClassDefFoundError:  com/example/test/MySystemDTO

                      at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_17]

                      at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_17]

                      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [rt.jar:1.6.0_17]

                      at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)

                      at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)

                      ... 20 more

                    • 7. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                      surendrand001 Newbie

                      updating my entire stack trace...

                       

                      11:52:56,414 WARN  [org.jboss.modules] (MSC service thread 1-12) Failed to define class com.example.test.MySystemDTO in Module "deployment.qux:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/example/test/MySystemDTO (Module "deployment.qux:main" from Service Module Loader)

                                at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)

                                at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)

                                at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)

                                at org.jboss.modules.Module.loadModuleClass(Module.java:517)

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

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

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

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

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

                                at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)

                                at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:489) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                                at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:851) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:596) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

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

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

                                at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_17]

                      Caused by: java.lang.NoClassDefFoundError: com/example/service/base/EmployeeBean

                                at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_17]

                                at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_17]

                                at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [rt.jar:1.6.0_17]

                                at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)

                                at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)

                                ... 20 more

                      Caused by: java.lang.ClassNotFoundException: com.example.service.base.EmployeeBean from [Module "deployment.qux:main" from Service Module Loader]

                                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)

                                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) [rt.jar:1.6.0_17]

                                ... 25 more

                      • 8. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                        Nicklas Karlsson Master

                        So where is the DTO packed? It looks like the CNFE happens at JPA bootstrap, where are the persistence.xml:s located?

                        • 9. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                          surendrand001 Newbie

                          I removed the persitence related stuff and found this issue is not related JPA...

                           

                          18:12:01,223 WARN  [org.jboss.modules] (MSC service thread 1-12) Failed to define class com.example.test.MySystemDTO in Module "deployment.qux:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/example/test/MySystemDTO (Module "deployment.qux:main" from Service Module Loader)

                                    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.Module.loadModuleClass(Module.java:517) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]

                                    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) [rt.jar:1.6.0_17]

                                    at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.6.0_17]

                                    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) [rt.jar:1.6.0_17]

                                    at java.lang.Class.getDeclaredMethods(Class.java:1791) [rt.jar:1.6.0_17]

                                    at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:65) [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]

                                    at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)

                                    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:85)

                                    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:70)

                                    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:55)

                                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [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_17]

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

                                    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_17]

                          Caused by: java.lang.NoClassDefFoundError: com/example/service/base/EmployeeBean

                                    at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_17]

                                    at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [rt.jar:1.6.0_17]

                                    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) [rt.jar:1.6.0_17]

                                    at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391) [jboss-modules.jar:1.1.1.GA]

                                    ... 26 more

                          Caused by: java.lang.ClassNotFoundException: com.example.service.base.EmployeeBean from [Module "deployment.qux:main" from Service Module Loader]

                                    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]

                                    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]

                                    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316) [rt.jar:1.6.0_17]

                                    ... 31 more

                          • 10. Re: jboss-deployment-structure.xml cannot access files in EAR/lib
                            Stephen Coy Master

                            In the absence of a jboss-deployment-structure.xml file (and manifest classpath entries), the rules for class visibility within an EAR deployment (in a default JBossAS/WildFly installation) are:

                             

                            1. War file classes can see any of the classes in any of the EJB/RAR jar subdeployments of the EAR and any of the classes in the EAR/lib directory;
                            2. EJB/RAR jar file classes can see any of the classes in any of the EJB/RAR jar subdeployments of the EAR and any of the classes in the EAR/lib directory;
                              • EJB jar file classes cannot see any of the classes in a WAR subdeployment
                            3. jar file classes in the EAR/lib directory can see classes in other jars contained within the EAR/lib directory only;
                              • classes in the EAR/lib directory cannot see any of the classes in either EJB or RAR or WAR subdeployments

                             

                            The JEE6 spec is a bit fuzzy in this regard, but it hints that you can add a manifest Class-Path entry to an EAR/lib jar that contains the relative path to an EJB jar within the EAR, thus making the EJB jar's classes available to the library jar:

                             

                            {code}Class-Path: ../foo.jar ../bar.jar{code}

                             

                            I've never had occasion to try this myself though.