0 Replies Latest reply on Dec 27, 2016 4:26 AM by gossi

    java.lang.NoClassDefFoundError for spring classes

    gossi

      Hello everyone.

       

      While trying to write a simple Springframework war I'm running into some problems. I have already tried some stuff, but at first I wanna explain my problem.

       

      When publishing my project (SpringTutorial.war) to my Wildfly 10 i got this trace log:

      09:57:48,540 WARN  [org.jboss.modules] (MSC service thread 1-2) Failed to define class org.springframework.context.ApplicationContextAware in Module "deployment.SpringTutorial.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/springframework/context/ApplicationContextAware (Module "deployment.SpringTutorial.war:main" from Service Module Loader): org/springframework/beans/factory/Aware
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          
      09:57:48,541 WARN  [org.jboss.modules] (MSC service thread 1-2) Failed to define class org.springframework.web.servlet.FrameworkServlet in Module "deployment.SpringTutorial.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/springframework/web/servlet/FrameworkServlet (Module "deployment.SpringTutorial.war:main" from Service Module Loader): Failed to link org/springframework/context/ApplicationContextAware (Module "deployment.SpringTutorial.war:main" from Service Module Loader): org/springframework/beans/factory/Aware
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          
      ervice thread 1-2) Failed to define class org.springframework.web.servlet.DispatcherServlet in Module "deployment.SpringTutorial.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/springframework/web/servlet/DispatcherServlet (Module "deployment.SpringTutorial.war:main" from Service Module Loader): Failed to link org/springframework/web/servlet/FrameworkServlet (Module "deployment.SpringTutorial.war:main" from Service Module Loader): Failed to link org/springframework/context/ApplicationContextAware (Module "deployment.SpringTutorial.war:main" from Service Module Loader): org/springframework/beans/factory/Aware
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          
      ntUnitPhaseService.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 org/springframework/web/servlet/DispatcherServlet (Module "deployment.SpringTutorial.war:main" from Service Module Loader): Failed to link org/springframework/web/servlet/FrameworkServlet (Module "deployment.SpringTutorial.war:main" from Service Module Loader): Failed to link org/springframework/context/ApplicationContextAware (Module "deployment.SpringTutorial.war:main" from Service Module Loader): org/springframework/beans/factory/Aware
          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:423)
          at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
          
      ava.lang.NoClassDefFoundError: Failed to link org/springframework/web/servlet/DispatcherServlet (Module \"deployment.SpringTutorial.war:main\" from Service Module Loader): Failed to link org/springframework/web/servlet/FrameworkServlet (Module \"deployment.SpringTutorial.war:main\" from Service Module Loader): Failed to link org/springframework/context/ApplicationContextAware (Module \"deployment.SpringTutorial.war:main\" from Service Module Loader): org/springframework/beans/factory/Aware"},
          "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"SpringTutorial.war\".POST_MODULE"],
          "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
      }
      09:57:48,607 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "SpringTutorial.war" (runtime-name : "SpringTutorial.war")
      09:57:48,607 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
      WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."SpringTutorial.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."SpringTutorial.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "SpringTutorial.war"
      

      This is a short version, for the complete trace feel free to take a look at the attachment.

       

      I'm using Eclipse and directly publish from Eclipse to the Wildfly wich I have added to the Eclipse IDE, using it to start, stop and publish to the Wildfly.

      My project is a Web-Project and the following jars are in the WEB-INF/lib folder:

      • spring-aop-4.3.5.RELEASE.jar
      • spring-context-4.3.5.RELEASE.jar
      • spring-core-4.3.5.RELEASE.jar
      • spring-web-4.3.5.RELEASE.jar
      • spring-webmvc-4.3.5.RELEASE.jar

       

      When I take a look at the wildfly-10.1.0.Final/standalone/deployments/SpringTutorial.war/WEB-INF/lib folder, all the jars are included in this folder.

       

      Thinks I have tried

      • Adding the springframework as a module to  the Wildfly Server. (Created new folders, so I got these wildfly-10.1.0.Final/modules/org/springframework/spring/main with module.xml)
      • Using jboss-deployment-structure.xml in combination with the module
      • Adding the module to the standalone.xml from Wildfly

      But nothing worked for me. And most informations and answers in the internet are connected to maven, wich i would use, but because of some reasons, I have to solve the problem without maven.

       

      I hope someone could help me. Thanks for reading this and for your help.

       

      Greetings

      gossi