10 Replies Latest reply: May 2, 2012 7:16 PM by rwhitely RSS

    ClassNotFoundException when deploying ear file on Jboss AS 7

    mcatalin23 Newbie

      I included my ear file into <jboss_home>\standalone\deployments\ folder.

      The ear file was generated with Jboss Developer Studio version 4.0.0.GA.

       

      I'm getting following error when starting Jboss 7 as standalone:

       

      12:07:08,729 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."<ear_name>.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."<ear_name>.ear".INSTALL: Failed to process phase INSTALL of deployment "<ear_name>.ear"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

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

          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

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

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

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

      Caused by: java.lang.RuntimeException: Error getting reflective information for class <my_class_name>

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

          at org.jboss.as.ee.component.EEModuleClassDescription$DefaultConfigurator.configure(EEModuleClassDescription.java:144)

          at org.jboss.as.ee.component.EEClassConfigurationProcessor.processClasses(EEClassConfigurationProcessor.java:133)

          at org.jboss.as.ee.component.EEClassConfigurationProcessor.deploy(EEClassConfigurationProcessor.java:76)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

          ... 5 more

      Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Category;

          at java.lang.Class.getDeclaredFields0(Native Method) [:1.6.0_23]

          at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [:1.6.0_23]

          at java.lang.Class.getDeclaredFields(Class.java:1743) [:1.6.0_23]

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

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

          ... 9 more

      Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category from [Module "deployment.<ear_name>.ear.<jar_name>.jar:main" from Service Module Loader]

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

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

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

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

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

          ... 14 more

       

       

      Following instructions from

      https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7

      section "How to find the JBoss module dependency"

      I searched for the jboss 7 module that contains the class org.apache.log4j.Category

      The class is included into following jar: <jboss_home>\modules\org\apache\log4j\main\log4j-1.2.16.jar

      From module.xml file I got the module name org.apache.log4j, and I added this module name to the Dependencies in the MANIFEST.MF file:

      like Dependencies: org.apache.log4j

       

      I did all these steps from the documentation but I still get the same error ClassNotFoundException.

      I have tried to update the main MANIFEST.MF file from the ear and also the MANIFEST.MF file from jar included into the ear that requires the class.

       

      The MANIFEST.MF file I used is attached.

       

      Where is the problem regarding this issue?

      Is anything wrong with my configuration for manifest file? I manually edited the manifest file.

        • 1. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
          jaikiran pai Master

          Which MANIFEST.MF did you add it to?

          • 2. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
            mcatalin23 Newbie

            I tried with

            <ear_name>.ear\META-INF\MANIFEST.MF

            and also with

            <ear_name>.ear\<jar_name>.jar\META-INF\MANIFEST.MF

            • 3. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
              jaikiran pai Master

              It should be in the .ear/.jar/META-INF/MANIFEST.MF since that's what the stacktrace is complaining about. By the way, the attached application doesn't have any Dependencies: in the MANIFEST.MF. If you still run into issues after adding that dependency, then please post the new stacktrace and also the exact MANIFEST.MF and its location.

              • 4. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                mcatalin23 Newbie

                I have tried again with the .ear/.jar/META-INF/MANIFEST.MF file and I get the same error.

                Most probably is something wrong with my configuration into MANIFEST.MF file because I edited it manually.

                The file contains also Class-Path: as well as the Dependencies: sections and I'm not sure what should be the structure of the file in this case.

                Below is the MANIFEST.MF file am using. Also the attached file contains the MANIFEST.MF I am using.

                 

                Manifest-Version: 1.0

                Dependencies: org.apache.log4j

                Class-Path: <jar_name_001>.jar

                <jar_name_002>.jar

                <jar_name_003>.jar

                 

                 

                 

                 

                ... and the stacktrace:

                 

                13:04:51,898 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."<ear_name>.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."<ear_name>.ear".INSTALL: Failed to process phase INSTALL of deployment "<ear_name>.ear"

                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

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

                    at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

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

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

                    at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

                Caused by: java.lang.RuntimeException: Error getting reflective information for class <my_class_name>

                    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

                    at org.jboss.as.ee.component.EEModuleClassDescription$DefaultConfigurator.configure(EEModuleClassDescription.java:144)

                    at org.jboss.as.ee.component.EEClassConfigurationProcessor.processClasses(EEClassConfigurationProcessor.java:133)

                    at org.jboss.as.ee.component.EEClassConfigurationProcessor.deploy(EEClassConfigurationProcessor.java:76)

                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

                    ... 5 more

                Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Category;

                    at java.lang.Class.getDeclaredFields0(Native Method) [:1.6.0_23]

                    at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [:1.6.0_23]

                    at java.lang.Class.getDeclaredFields(Class.java:1743) [:1.6.0_23]

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

                    at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

                    ... 9 more

                Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category from [Module "deployment.<ear_name>.ear.<jar_name>.jar:main" from Service Module Loader]

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

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

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

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

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

                    ... 14 more

                • 5. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                  mcatalin23 Newbie

                  My simplified schema for ear looks like:

                   

                  myapp.ear // contains META-INF\application.xml with ejb & web modules: ejb.jar & web.war

                  |

                  |-- web.war // this includes WEB-INF\web.xml with web services definitions

                  |

                  |--- ejb.jar // this includes META-INF\ejb-jar.xml with deployment descriptor for ejb3

                  |

                  |---additional_module.jar //this requires org.apache.log4j module for Category class

                   

                  I have tried different approaches but it doesn't work. I still get ClassNotFoundException.

                  What do I have to do exactly to add the dependency for org.apache.log4j module to my additional_module.jar into the ear?

                  • 6. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                    jaikiran pai Master

                    What kind of jar is that addition_module.jar? If it's a plain jar, then move it to the .ear/lib folder and then add a

                     

                    Dependencies: org.apache.log4j
                    
                    

                     

                    to the .ear/META-INF/MANIFEST.MF.

                    • 7. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                      mcatalin23 Newbie

                      Yes, addition_module.jar it's a plain jar.

                      My ejb.jar needs a reference to addition_module.jar so the MANIFEST.MF file for my ejb.jar contains in Class-Path: addition_module.jar.

                       

                      I moved all additional (plain) jars to .ear/lib and for .ear/META-INF/MANIFEST.MF I added "Dependencies: org.apache.log4j".

                      Also I updated the Class-Path into MANIFEST.MF files for my ejb.jar & web.war to new location of additional jars .ear/lib.

                       

                      But the error is still there; stacktrace:

                       

                      14:39:53,187 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."my.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."my.ear".INSTALL: Failed to process phase INSTALL of deployment "my.ear"

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

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

                          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

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

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

                          at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

                      Caused by: java.lang.RuntimeException: Error getting reflective information for class <my_class_in_addition_module.jar>

                          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

                          at org.jboss.as.ee.component.EEModuleClassDescription$DefaultConfigurator.configure(EEModuleClassDescription.java:144)

                          at org.jboss.as.ee.component.EEClassConfigurationProcessor.processClasses(EEClassConfigurationProcessor.java:133)

                          at org.jboss.as.ee.component.EEClassConfigurationProcessor.deploy(EEClassConfigurationProcessor.java:76)

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

                          ... 5 more

                      Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Category;

                          at java.lang.Class.getDeclaredFields0(Native Method) [:1.6.0_23]

                          at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [:1.6.0_23]

                          at java.lang.Class.getDeclaredFields(Class.java:1743) [:1.6.0_23]

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

                          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

                          ... 9 more

                      Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category from [Module "deployment.my.ear.lib/<my_class_in_addition_module.jar>.jar:main" from Service Module Loader]

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

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

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

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

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

                          ... 14 more

                       

                       

                      Now my ear structure is as shown below:

                       

                      myapp.ear

                      |

                      |---lib

                      |    |---additional_module_1.jar

                      |    |---additional_module_n.jar

                      |

                      |---META-INF

                      |    |---application.xml

                      |    |---MANIFEST.MF     //contains Dependencies: org.apache.log4j

                      |

                      |--- ejb.jar

                      |    |---META-INF\ejb-jar.xml

                      |    |---META-INF\MANIFEST.MF

                      |

                      |-- web.war

                           |---META-INF\MANIFEST.MF

                           |---WEB-INF\web.xml

                      • 8. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                        mcatalin23 Newbie

                        @jaikiran pai

                         

                        Can you attach a MANIFEST.MF file that includes "Dependencies: org.apache.log4j"?

                        I don't know if my manually edited MANIFEST.MF is correct because I still get the same error.

                        • 9. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                          d.croe Newbie

                          i think you should remove < > from the jar names within the manifest file and be sure to have a newline at the end!

                          • 10. Re: ClassNotFoundException when deploying ear file on Jboss AS 7
                            rwhitely Newbie

                            Adding a newline at the end of my manifest hast mostly fixed this problem for me.

                             

                            Apparently, the last character of the file needs to be a newline, which is absolutely rediculous, because it's completely invisible.... Though this appears to be the standard. From the official documentation, it appears that this is by design (http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html) at least back with Java 1.4. Specifically, where it says:

                             

                            Be sure that any pre-existing manifest file that you use ends with a new line. The last line of a manifest file will not be parsed if it doesn't end with a new line character.

                             

                            I say it's "mostly fixed" because I'm still seeing an error, but I suspect it's a new, unrelated error. So if anyone is running into this problem, it's worth checking your manifest file to make sure the file ends with a new line.