8 Replies Latest reply on Jan 5, 2014 9:51 PM by andyrooheavens

    class in rt.jar is not loaded by JBoss 7

    ohmygod

      I am using JBoss 7.1.1.Final and found a class from rt.jar cannot be loaded in runtime. From my experience, classes from rt.jar in jre should be able to be loaded anytime.

       

      Could somebody advise why this problem happens and how to resolve it?

       

      Caused by: java.lang.ClassNotFoundException: sun.beans.editors.StringEditor from [Module "deployment.demo.ear.demo.jar:main" from Service Module L
      oader]
              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:319) [rt.jar:1.6.0_07]
      
      
        • 1. Re: class in rt.jar is not loaded by JBoss 7
          ohmygod

          I added <path name="sun/beans/editors"/> to modules\sun\jdk\main\module.xml and it works. Could anybody explain to me why JBoss 7 needs all class packages to be configured in module xml?

          • 2. Re: class in rt.jar is not loaded by JBoss 7
            mac2009

            Mike, I agree with you. "From my experience, classes from rt.jar in jre should be able to be loaded anytime."

            I have the same issue with com/sun/org/apache/xml/internal/serialize/XMLSerializer

             

            Thats really a strange behaviour...

            • 3. Re: class in rt.jar is not loaded by JBoss 7
              sfcoy

              I believe this is a consequence of JBoss 7 trying to remain JVM agnostic. These classes may not exist in non SunOracle implementations, or even some future Oracle release.

              • 4. Re: class in rt.jar is not loaded by JBoss 7
                mac2009

                Ok, thats a valid point.

                So, whas best practice?

                In my case the ClassNotFound is caused by castor-xml. Should I add the xerces.jar as well?

                Not sure, but I think that I have read something like "better remove xerces.jar (or xml-apis.jar) for example from lib dir"...?

                • 5. Re: class in rt.jar is not loaded by JBoss 7
                  sfcoy

                  What version of castor-xml are you using?

                   

                  There's some interesting comments at http://www.castor.org/1.2/release-notes.html down just below the notes for Release 1.1-M3 regarding changes for Java 5, xerces and serialization.

                   

                  Maybe you can spot some hints there. It certainly answers your last question I think. xml-apis.jar is evil and should never be deployed in an application BTW.

                   

                  Speaking of evil, Mikes thread has now been hijacked...

                  • 6. Re: class in rt.jar is not loaded by JBoss 7
                    ohmygod

                    Hi Stevephen,

                     

                    Your opinion sounds reasonable. However, I have made it work by adding the classpath in the module xml. BTW, could you please take a look at my another question here

                     

                    https://community.jboss.org/thread/202324

                     

                    It is also about class loading problem. If you have any idea on it, it will be much appreciated.

                    • 7. Re: class in rt.jar is not loaded by JBoss 7
                      mac2009

                      Hi Stephen,

                       

                      we are using castor-xml 1.3.2.

                      I checked the notes for Release 1.1-M3. Castor uses xerces shipped with jdk/jre. Anyway, not the issue...

                       

                      In general, whats the best way to do it ?

                      a) adding path element to module.xml (as Mike and have done so far)

                      b) adding jar (xerces for example) to ear/lib

                      c) matter of taste

                       

                      Cheers

                      Carsten

                      • 8. Re: class in rt.jar is not loaded by JBoss 7
                        andyrooheavens

                        For our EAR project we have the following for our jboss-deployment-structure.xml:

                         

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

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

                        <deployment>

                          <dependencies>

                           <system>

                            <paths>

                             <path name="com/sun/org/apache/xml/internal/serialize"/>

                             <path name="sun/beans/editors"/>

                            </paths>

                           </system>

                          </dependencies>

                        </deployment>

                        <sub-deployment name="xyz.war"/>

                        </jboss-deployment-structure>


                        This allows you to deploy the app without making changes to the (possibly shared with other teams) module.xml file.