13 Replies Latest reply on Apr 3, 2017 7:26 PM by jamezp

    ClassNotFoundException when starting WildFly 10

    leo.chen

      I am starting my web application with WildFly version 10. Now I am getting the ClassNotFoundException during the startup.

       

      I noticed the class (a servlet class) is configured in web.xml in the web.war (at /my-web.war/WEB-INF), and the servlet class is in my jar at /my.ear.

       

      The structure is like:
      my.ear

          -- my-web.war

                -- WEB-INF

                      -- web.xml

          -- my.jar

       

      This ever worked fine in JBoss EAP 6.4.0. I have not changed anything on the configuration yet. But now I see ClassNotFoundException when trying to migrate to WildFly 10.

       

      The jboss-deployment-structure is like below:

      <jboss-deployment-structure>
        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
      </jboss-deployment-structure>
      

       

      Below is the error. Please advise.

      ERROR;org.jboss.msc.service.fail;MSC000001: Failed to start service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "my-web.war" of deployment "my.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: com.DemoServlet from [Module "deployment.my.ear.my-web.war:main" from Service Module Loader]
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:292)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:153)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:104)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
        ... 5 more
      Caused by: java.lang.ClassNotFoundException: com.DemoServlet from [Module "deployment.my.ear.my-web.war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
        at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:290)
        ... 8 more
      
        • 1. Re: ClassNotFoundException when starting WildFly 10
          jamezp

          Where is the com.DemoServlet.class located?

           

          --

          James R. Perkins

          • 2. Re: ClassNotFoundException when starting WildFly 10
            leo.chen

            it is located at my.jar, as I said in the first time. This worked in JBoss EAP 6.4.0. I did not change anything on the configuration or file location.

            • 3. Re: ClassNotFoundException when starting WildFly 10
              leo.chen

              Additional information for reference:

              when I uncommented the DemoServlet configuration in web.xml, other servlet classes which are configured in web.xml will be reported not found errors while they are all located in my.jar.

              • 4. Re: ClassNotFoundException when starting WildFly 10
                jaikiran

                leo chen wrote:

                 

                I am starting my web application with WildFly version 10. Now I am getting the ClassNotFoundException during the startup.

                 

                I noticed the class (a servlet class) is configured in web.xml in the web.war (at /my-web.war/WEB-INF), and the servlet class is in my jar at /my.ear.

                 

                The structure is like:
                my.ear

                    -- my-web.war

                          -- WEB-INF

                                -- web.xml

                    -- my.jar

                 

                This ever worked fine in JBoss EAP 6.4.0. I have not changed anything on the configuration yet. But now I see ClassNotFoundException when trying to migrate to WildFly 10.

                 

                The jboss-deployment-structure is like below:

                1. <jboss-deployment-structure> 
                2.   <ear-subdeployments-isolated>false</ear-subdeployments-isolated> 
                3. </jboss-deployment-structure> 


                If the my.jar is just a plain jar without any EE components bundled in it, then it won't be considered a sub deployment and its classes won't be visible to the other sub deployments. If it's a plain jar, move it to a lib folder within the .ear. Something like my.ear/lib/my.jar. That way, it will be considered a library and will be available to all sub deployments of that .ear.

                • 5. Re: ClassNotFoundException when starting WildFly 10
                  leo.chen

                  Hi Jaikiran, thanks for your reply. Bad news is I have tried that but it does not work. Anything else to advise?

                  • 6. Re: ClassNotFoundException when starting WildFly 10
                    jaikiran

                    Move that jar to the lib folder of the .ear and then post the output of:

                     

                    jar -tf myear.ear

                     

                    and also the output of

                     

                    jar -tf my.jar

                     

                    and please paste the latest exception stacktrace

                    • 7. Re: ClassNotFoundException when starting WildFly 10
                      leo.chen

                      Here is the error log. It is a bit different.

                      ERROR;org.jboss.msc.service.fail;MSC000001: Failed to start service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "my-web.war" of deployment "my.ear"
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                        at java.lang.Thread.run(Thread.java:745)
                      Caused by: java.lang.NoClassDefFoundError: Failed to link com/DemoServlet (Module "deployment.my.ear:main" from Service Module Loader): org/apache/cxf/transport/servlet/CXFNonSpringServlet
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
                        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
                        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
                        at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
                        at org.jboss.modules.Module.loadModuleClass(Module.java:605)
                        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
                        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
                        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
                        at java.lang.Class.forName0(Native Method)
                        at java.lang.Class.forName(Class.java:348)
                        at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:21)
                        at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:14)
                        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:84)
                        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
                        ... 5 more
                      
                      • 8. Re: ClassNotFoundException when starting WildFly 10
                        leo.chen

                        my.ear is a just a folder which cannot be jar - tf.

                         

                        output of my.jar:

                        >jar -tf my.jar
                        META-INF/MANIFEST.MF
                        com/DemoServlet.class
                        ... (other bunch of classes)
                        

                         

                        All the error trace:

                        2016-05-24 12:07:58,462;[MSC service thread 1-4];WARN ;org.jboss.modules;Failed to define class com.DemoServlet in Module "deployment.my.ear:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/DemoServlet (Module "deployment.my.ear:main" from Service Module Loader): org/apache/cxf/transport/servlet/CXFNonSpringServlet
                          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
                          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                          at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
                          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
                          at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
                          at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
                          at org.jboss.modules.Module.loadModuleClass(Module.java:605)
                          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
                          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
                          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
                          at java.lang.Class.forName0(Native Method)
                          at java.lang.Class.forName(Class.java:348)
                          at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:21)
                          at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:14)
                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:84)
                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                          at java.lang.Thread.run(Thread.java:745)
                        
                        
                        2016-05-24 12:07:58,475;[MSC service thread 1-4];ERROR;org.jboss.msc.service.fail;MSC000001: Failed to start service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "my-web.war" of deployment "my.ear"
                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                          at java.lang.Thread.run(Thread.java:745)
                        Caused by: java.lang.NoClassDefFoundError: Failed to link com/DemoServlet (Module "deployment.my.ear:main" from Service Module Loader): org/apache/cxf/transport/servlet/CXFNonSpringServlet
                          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
                          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                          at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
                          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
                          at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
                          at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
                          at org.jboss.modules.Module.loadModuleClass(Module.java:605)
                          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
                          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
                          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
                          at java.lang.Class.forName0(Native Method)
                          at java.lang.Class.forName(Class.java:348)
                          at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:21)
                          at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:14)
                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:84)
                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
                          ... 5 more
                        
                        
                        2016-05-24 12:07:58,489;[Controller Boot Thread];ERROR;org.jboss.as.controller.management-operation;WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "my.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"my.ear\".\"my-web.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"my.ear\".\"my-web.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"my-web.war\" of deployment \"my.ear\"
                            Caused by: java.lang.NoClassDefFoundError: Failed to link com/DemoServlet (Module \"deployment.my.ear:main\" from Service Module Loader): org/apache/cxf/transport/servlet/CXFNonSpringServlet"}}
                        2016-05-24 12:07:58,534;[ServerService Thread Pool -- 33];INFO ;org.jboss.as.server;WFLYSRV0010: Deployed "ROOT.war" (runtime-name : "ROOT.war")
                        2016-05-24 12:07:58,536;[ServerService Thread Pool -- 33];INFO ;org.jboss.as.server;WFLYSRV0010: Deployed "my.ear" (runtime-name : "my.ear")
                        2016-05-24 12:07:58,538;[Controller Boot Thread];INFO ;org.jboss.as.controller;WFLYCTL0183: Service status report
                        WFLYCTL0186:   Services which failed to start:      service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "my-web.war" of deployment "my.ear"
                        
                        
                        2016-05-24 12:07:58,663;[Controller Boot Thread];INFO ;org.jboss.as;WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
                        2016-05-24 12:07:58,664;[Controller Boot Thread];INFO ;org.jboss.as;WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
                        2016-05-24 12:07:58,664;[Controller Boot Thread];ERROR;org.jboss.as;WFLYSRV0026: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) started (with errors) in 15334ms - Started 401 of 694 services (3 services failed or missing dependencies, 389 services are lazy, passive or on-demand)
                        2016-05-24 12:07:58,801;[MSC service thread 1-5];INFO ;org.jboss.as.server.deployment;WFLYSRV0208: Stopped subdeployment (runtime-name: my-web.war) in 87ms
                        2016-05-24 12:07:58,895;[MSC service thread 1-8];INFO ;org.jboss.as.server.deployment;WFLYSRV0208: Stopped subdeployment (runtime-name: myServices.war) in 181ms
                        2016-05-24 12:07:58,988;[MSC service thread 1-4];INFO ;org.jboss.as.server.deployment;WFLYSRV0028: Stopped deployment my.ear (runtime-name: my.ear) in 275ms
                        2016-05-24 12:07:59,053;[DeploymentScanner-threads - 1];INFO ;org.jboss.as.server;WFLYSRV0009: Undeployed "my.ear" (runtime-name: "my.ear")
                        2016-05-24 12:07:59,054;[DeploymentScanner-threads - 1];INFO ;org.jboss.as.controller;WFLYCTL0183: Service status report
                        WFLYCTL0184:    New missing/unsatisfied dependencies:
                              service jboss.naming.context.java.module.my.myServices (missing) dependents: [service jboss.deployment.subunit."my.ear"."myServices.war".INSTALL] 
                        WFLYCTL0186:   Services which failed to start:      service jboss.deployment.subunit."my.ear"."my-web.war".POST_MODULE
                        
                        
                        2016-05-24 12:08:03,642;[DeploymentScanner-threads - 1];INFO ;org.jboss.as.server.deployment.scanner;WFLYDS0004: Found my.ear in deployment directory. To trigger deployment create a file called my.ear.dodeploy
                        
                        
                        • 9. Re: ClassNotFoundException when starting WildFly 10
                          leo.chen

                          Hi Jaikiran, I think this problem has gone. I added the cxf dependency in jboss-deployment-structure xml as below and the error is fixed.

                           

                          <dependencies>
                            <module name="org.apache.cxf" export="true" />
                            <module name="org.apache.cxf.impl" export="true" />
                          </dependencies>
                          

                           

                          So thanks for your advice. I will close this thread as resolved for now.

                          • 10. Re: ClassNotFoundException when starting WildFly 10
                            hemanthkolla

                            Hi Jaikiran,

                                              I am having a similar problem regarding class not found. In wildfly 10 application, My java class use some external jar files provided by Business Objects and when I am trying to call the class I get the below error.

                             

                            at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
                            at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
                            at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
                            at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:254)
                            ... 181 more

                            Caused by: java.lang.ClassNotFoundException: com.crystaldecisions.sdk.framework.CrystalEnterprise from [Module "deployment.app-custom.ear.custom-ejb-11.2.0.jar:main" from Service Module Loader]

                            at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
                            at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
                            at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
                            at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
                            ... 215 more

                            I have added the jar files need into a lib folder in custom-ejb-11.2.0.jar and added Manifest classpath entries. But still its not able to find the external jar files.

                             

                            My structure is as below

                             

                            app-custom.ear

                                    /lib

                                   /custom-ejb-11.2.0.jar

                                      runtime-lib/

                                      a class file

                            • 11. Re: ClassNotFoundException when starting WildFly 10
                              jamezp

                              The JAR files would need to be in the app-custom.ear/lib directory. The JAR directory structure does not have a lib directory.

                               

                              --

                              James R. Perkins

                              • 12. Re: ClassNotFoundException when starting WildFly 10
                                hemanthkolla

                                Hi James,

                                                    Thank you for the reply. If I have multiple sub deployments do I have to add the jars to modules structure and add module dependencies in the jboss-deployment-structure.xml file? Also I am creating the jar file using maven build wonder if I need to add dependent jar's to the manifest file classpath?

                                 

                                I added the jars to the lib folder initially and unfortunately they are still not visible.

                                 

                                Thanks,

                                Hemanth

                                • 13. Re: ClassNotFoundException when starting WildFly 10
                                  jamezp

                                  It all depends on what type of deployment you're using. If you're deploying an EAR then by default all sub-deployments will have a dependency on the libraries in the EAR/lib directory. See Class Loading in WildFly for more details. The manifest entries are also addressed in the documentation.

                                   

                                  --

                                  James R. Perkins