7 Replies Latest reply on May 18, 2012 10:44 AM by jimbrady

    Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)

    jimbrady

      Hi,

        I get class loading problems in trying to execute a SSO Valve as follows:

       

      11:50:11,734 ERROR [org.apache.catalina.connector.CoyoteAdapter] (http-dbkdprn01.rze.de.db.com-10.225.109.100-8080-1) An exception or error occurred in the container during the request processing: java.lang.LinkageError: Failed to link sun/net/www/protocol/https/Handler (Module "deployment.Admin.ear:main" from Service Module Loader)

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

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

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

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

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

              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)

              at org.apache.catalina.valves.AbstractGDAuthValve.calculateKeyLocation(AbstractGDAuthValve.java:531) [LDAPRealm-5.5New.jar:]

              at org.apache.catalina.valves.AbstractGDAuthValve.initSignatureChecker(AbstractGDAuthValve.java:510) [LDAPRealm-5.5New.jar:]

              at org.apache.catalina.valves.AbstractGDAuthValve.invoke(AbstractGDAuthValve.java:83) [LDAPRealm-5.5New.jar:]

              at org.apache.catalina.valves.gdAuthValve.invoke(gdAuthValve.java:23) [LDAPRealm-5.5New.jar:]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

              at java.lang.Thread.run(Unknown Source) [:1.6.0_25]

      Caused by: java.lang.NoClassDefFoundError: sun/net/www/protocol/http/Handler

              at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_25]

              at java.lang.ClassLoader.defineClassCond(Unknown Source) [:1.6.0_25]

              at java.lang.ClassLoader.defineClass(Unknown Source) [:1.6.0_25]

              at java.security.SecureClassLoader.defineClass(Unknown Source) [:1.6.0_25]

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

              ... 20 more

      Caused by: java.lang.ClassNotFoundException: sun.net.www.protocol.http.Handler from [Module "deployment.Admin.ear: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.performLoadClassChecked(ConcurrentClassLoader.java:330)

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

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

              ... 25 more

       

      But this module is in JAVA_HOME/lib/jsse.jar.

       

      I also tried putting jsse.jar direct in EAR/lib - but that also didn't work. Has somebody got any help here - I'm not sure what to do here.

        • 1. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
          jimbrady

          I notice here that the class not found is in fact not sun.net.www.protocol.https.Handler BUT sun.net.www.protocol.http.Handler which is in fact in the rt.jar!

           

          I earlier had a mysterious problem with an Oracle 11.2 jdbc driver - but I got the old 1.4 driver working. Could it be that somehow the class loader for the application is working with the installed (IBM) 1.4 Java and not using the 1.6 which I used to start the jboss server?

          • 2. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
            jimbrady

            OK I got the solution. You need to add a module (say sun.net.www.protocol) that loads the classes required from the runtime library. It doesn't need a jar - just a module.xml in main.

             

            Then point the web application in dependencies to this module - and viola.

             

            <module xmlns="urn:jboss:module:1.0" name="sun.net.www.protocol">
                <dependencies>
                    <module name="system" export="false">
                        <exports>
                            <include-set>
                                <path name="sun/net/www/protocol/http"/>
                                <path name="sun/net/www/protocol/https"/>
                            </include-set>
                        </exports>
                    </module>
                </dependencies>
            </module>

             

            War Manifest:

             

            Manifest-Version: 1.0

            Ant-Version: Apache Ant 1.7.1

            Created-By: 19.1-b02 (Sun Microsystems Inc.)

            Built-By: kz2100

            Implementation-Version: ${version}-b26

            Built-Date: 2011-09-06 17:10:13

            Main-class:

            Dependencies: javax.ejb.api,javax.servlet.api,javax.servlet.jsp.api,ja

            vax.servlet.jstl.api,org.apache.commons.beanutils,org.apache.commons.

            collections,org.apache.commons.lang,org.jboss.as.jmx,org.jboss.as.web

            ,org.jboss.logmanager,org.slf4j.impl,org.slf4j.jcl-over-slf4j,org.slf

            4j,sun.net.www.protocol

            • 3. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
              karpaczio

              I've tried to use your solution, but it did not work. What I've changed is:

              1. modified module.xml, cause it was invalid

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

              <module xmlns="urn:jboss:module:1.1" name="sun.net.www.protocol">

                  <dependencies>

                      <system export="true">

                          <exports>

                              <include-set>

                                  <path name="sun/net/www/protocol/http"/>

                                  <path name="sun/net/www/protocol/https"/>

                              </include-set>

                          </exports>

                      </system>

                  </dependencies>

              </module>

               

              2. instead of manifest file, I have /WEB-INF/jboss-deployment-structure.xml

              <jboss-deployment-structure>

                  <deployment>

                      <dependencies>

                          <module name="sun.net.www.protocol" services="export" />

                      </dependencies>

                  </deployment>

              </jboss-deployment-structure>

               

              I'm getting similar exception, namely

              Caused by: java.lang.NoClassDefFoundError: sun/net/www/protocol/http/Handler

                      at pl.egierek.web.util.ClassloaderWorkaround.simpleTest(ClassloaderWorkaround.java:20) [classes:]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_27]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_27]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_27]

                      at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_27]

                      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

                      ... 22 more

              Caused by: java.lang.ClassNotFoundException: sun.net.www.protocol.http.Handler from [Module "deployment.web-0.0.2-SNAPSHOT.war: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)

                      ... 30 more

               

              Any ideas what else can be wrong ?

              • 4. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
                jimbrady

                Why did you change the export parameters? And is services="export" even allowed?

                 

                P.S. It works also if you set the dependencies in a module including the required jars that call sun.net.www.protocol, you don't need a seperate module which exports the dependencies (what exactly is it exporting, I wonder?). I loaded the module calling sun.net.www.protocol using a global module definition in the configuration.

                 

                e.g.

                        <subsystem xmlns="urn:jboss:domain:ee:1.0">
                            <global-modules>
                                <module name="your.domain.login" slot="main"/>
                            </global-modules>
                        </subsystem>

                • 5. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
                  karpaczio


                  > Why did you change the export parameters?

                  I wanted to check whether changing value of export from "false" to "true" will change anything, but it didn't.

                  > And is services="export" even allowed?

                  Well according to http://www.jboss.org/schema/jbossas/jboss-deployment-structure-1_0.xsd yes, it is.

                   

                  > P.S. It works also if you set the dependencies in a module including the required jars that call sun.net.www.protocol, you don't need a seperate module which exports the dependencies (what exactly is it exporting, I wonder?). I loaded the module calling sun.net.www.protocol using a global module definition in the configuration.

                   

                  e.g.

                          <subsystem xmlns="urn:jboss:domain:ee:1.0">
                              <global-modules>
                                  <module name="your.domain.login" slot="main"/>
                              </global-modules>
                          </subsystem>

                   

                  If I understood you correctly, you put above config to ${jboss}/domain/configuration/domain.xml and instead "your.domain.login" you set "sun.net.www.protocol" ?

                  • 6. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
                    jimbrady

                    "If I understood you correctly, you put above config to ${jboss}/domain/configuration/domain.xml "

                     

                    Well yes in principle - but I did it into standalone.xml in my case

                     

                    "and instead "your.domain.login" you set "sun.net.www.protocol" ?"

                     

                    Not sure what you mean exactly here - but I did the following in "your.domain.login" module.xml:

                     


                    <module xmlns="urn:jboss:module:1.1" name="your.domain.login">
                        <resources>
                            <resource-root path="YourLogin.jar"/>
                        </resources>

                        <dependencies>
                               <module name="sun.jdk" export="true"/>
                               <module name="org.jboss.as.web"/>
                               <module name="javax.api"/>
                               <module name="javax.servlet.api"/>
                               <module name="org.picketbox"/>
                               <module name="org.slf4j.jcl-over-slf4j"/>
                               <system export="false">
                                     <paths>
                                           <path name="sun/net/www/protocol/http"/>
                                           <path name="sun/net/www/protocol/https"/>
                                     </paths>
                                </system>
                                <module name="javax.security.auth.message.api"/>
                        </dependencies>
                    </module>

                     

                    Hope this makes it 100% clear.

                     

                     

                    • 7. Re: Class loading Problem with jsse.jar (sun.net.www.protocol.https.Handler)
                      jimbrady

                      P.S.

                      The answer from last year was developed with 7.0 final - now I am using 7.1.

                       

                      P.P.S. It turns out better to use globals for valve logic, because it isn't necessarily called from the same class loader as the web application.