1 Reply Latest reply on Jan 26, 2018 6:18 AM by Anup Dey

    Jboss 7.1.1 external jar load issue!

    Rahul Verma Newbie

      Hi folks,

      My project is having an EAR, EAR contains jars, one jar in that is made to call a external client jar of some other product for communication. This external client jar is further having some 3rd party jars referenced.

       

      So being not good at jboss, not able to make it work. Please provide suggestions. Below putting EAR structure for better visualization of issue.

       

      A.ear

           - META-INF

                - MANIFEST.MF

           - lib

            - b1.jar

            - b2.jar

                - com

                - META-INF

                     - MANIFEST.MF (Added classpath :  Class-Path:  /opt/ExternalProduct/lib/client.jar)

       

      Above external client.jar refers to some 20 3rd party jars. I am adding all 3rd party jars in classpath as above, but getting ClassDefNotFoundException. Jboss starts without complaining, creates .index files for all referred jars, but when code hits client jar, exception is thrown as 3rd party jars Def not found. Tried adding classpath in all levels of MANIFEST files, but nothing is working.

       

      Not willing to make module folders for  each jars separately (close to 20 3rd party jars), that looks big task for 20 jars. Please suggest.

       

      Cheers,

      Rahul

        • 1. Re: Jboss 7.1.1 external jar load issue!
          Anup Dey Expert

          There is no ClassDefNotFoundException in standard Java lib..

           

          Typically, NoClassDefFoundError is thrown if the class failed to initialize.

           

          When a class is used for the 1st time, it's being initialized. if that fails for whatever reason, the relevant exception is thrown. http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.4

           

          When the class is used again, it's known to be corrupt. Initialization won't be attempted again. JVM throws the mysterious NoClassDefFoundError. Not really descriptive of the problem, could be quite confusing for diagnosis. It would be better if something like ClassInitFailedError is thrown.

           

          When you see a NoClassDefFoundError, you should search the log backwards, find the root cause why the class failed to initialize (hopefully it's logged)..

           

          NoClassDefFoundError happens when class cannot be instantiated by new because the jvm failed to initialize the class. It could be the constructor threw exceptions, or static block threw up, or version mismatch.