2 Replies Latest reply: Aug 18, 2014 5:37 AM by Igor Maculan RSS

    Class not found (com.sun.net.httpserver.HttpHandler)

    siclotus Newbie

      Hello, i'm new here, so please don't be too rude...

       

      I had a project working on tomcat. Now i want to migrate to jboss7 and i get a class not found exception.

      The Stacktrace looks like:

       

      12:45:17,141 WARN  [org.jboss.modules] (MSC service thread 1-4) Failed to define class org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter in Module "deployment.project-web.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/springframework/remoting/httpinvoker/SimpleHttpInvokerServiceExporter (Module "deployment.project-web.war: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.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.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_31]

          at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_31]

          at java.lang.Class.getDeclaredConstructors(Class.java:1836) [rt.jar:1.6.0_31]

          at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:447) [cglib-nodep-2.2.jar:]

          at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) [cglib-nodep-2.2.jar:]

          at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) [cglib-nodep-2.2.jar:]

          at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) [cglib-nodep-2.2.jar:]

          at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317) [cglib-nodep-2.2.jar:]

          at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:118) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:89) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:238) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:160) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:602) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]

          at de.company.commons.spring.context.SpringApplicationContext.initContext(SpringApplicationContext.java:172) [company-commons-spring-context-1.0.0-SNAPSHOT.jar:]

          at de.company.commons.spring.context.CommunicationTypeAwareSpringApplicationContext.init(CommunicationTypeAwareSpringApplicationContext.java:315) [company-commons-services-1.0.0-SNAPSHOT.jar:]

          at de.company.project.common.spring.ExaktSpringApplicationContext.init(ExaktSpringApplicationContext.java:167) [project-common-1.0.0-SNAPSHOT.jar:]

          at de.company.project.server.http.ExaktHttpServer.init(ExaktHttpServer.java:205) [project-srv-http-1.0.0-SNAPSHOT.jar:]

          at de.company.project.server.http.ExaktServletContextListener.initHttpServer(ExaktServletContextListener.java:165) [project-srv-http-1.0.0-SNAPSHOT.jar:]

          at de.company.project.server.http.ExaktServletContextListener.contextInitialized(ExaktServletContextListener.java:137) [project-srv-http-1.0.0-SNAPSHOT.jar:]

          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-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_31]

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

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]

      Caused by: java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler

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

          at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [rt.jar:1.6.0_31]

          at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [rt.jar:1.6.0_31]

          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_31]

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

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

          ... 38 more

      Caused by: java.lang.ClassNotFoundException: com.sun.net.httpserver.HttpHandler from [Module "deployment.project-web.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.performLoadClassChecked(ConcurrentClassLoader.java:423)

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

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

          ... 44 more

       

      Can someone help me? I'm not sure how to handle this. Any advice would be helpful.

        • 1. Re: Class not found (com.sun.net.httpserver.HttpHandler)
          T.A. Nguyen Newbie

          Since the com.sun.net.httpserver.* package included with the runtime libarary but not available, you will need to add a module to 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 that should work.

           

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

           

          * btw, eclipse enviroment also have the similar problem.  For eclipse all you have to do is to "REMOVE" the JRE library and re-added it back in, this will reset the default restriction and allow the com.sun.net.httpserver.* packages and other sun implementation to load without restriction.

           

          Enjoy!

          • 2. Re: Class not found (com.sun.net.httpserver.HttpHandler)
            Igor Maculan Newbie

            Hi, maybe 2 years too late to answer but, I solved following this http://jira.codehaus.org/browse/ACT-2069