Java.lang.NoClassDefFoundError: org / springframework / context / ApplicationContext

I had problems deploying my project in which I use jsf / spring / hibernate as faramework, I added the necessary banks specifically org.springframework.web-3.1.0.CI-1162, error:

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4150) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 

and added a list of added cans:

ANTLR-2.7.6.jar

Common-dbcb-1.4.jar

Wikimedia Commons Collection-3.1.jar

Community pool.1.6.jar

General Logging 1.1.jar

dom4j-1.6.1.jar

hibernate3.jar

hibernation-JPA-2.0-api-1.0.1.Final.jar

iText-5.0.4.jar (for Primefaces)

Javassist-3.9.0.GA.jar

com.springsource.org.jboss-el-2.0.0.GA.jar (optional for working on Tomcat 6)

jsf-api.jar (Mojarra 2.0.4)

jsf-impl.jar (Mojarra 2.04)

JTA-1.1.jar

log4j-1.2.11.jar

mysql-connector-java-5.0.5.jar (for MySQL)

org.springframework.aop-3.1.0.CI-1162.jar

org.springframework.asm-3.1.0.CI-1162.jar

org.springframework.aspects-3.1.0.CI-1162.jar

org.springframework.beans-3.1.0.CI-1162.jar

org.springframework.context-3.1.0.CI-1162.jar

org.springframework.context.support-3.1.0.CI-1162.jar

org.springframework.core-3.1.0.CI-1162.jar

org.springframework.expression-3.1.0.CI-1162.jar

org.springframework.jdbc-3.1.0.CI-1162.jar

org.springframework.orm-3.1.0.CI-1162.jar

org.springframework.oxm-3.1.0.M1.jar

org.springframework.transaction-3.1.0.CI-1162.jar

org.springframework.web-3.1.0.CI-1162.jar

org.springframework.web.portlet-3.1.0.M1.jar

org.springframework.web.servlet-3.1.0.CI-1162.jar

poi-3.2-FINAL-20081019.jar (for privacy)

primefaces-3.5jar

SLF4J-api-1.6.1.jar

SLF4J-jdk14-1.6.1.jar

qlfj4-log4j12-1.6.4.jar

+7
source share
5 answers

There may be different solutions for this error. I noted that I worked for me.

Solution 1. This always happens in a deployment and debugging environment. In a deployment environment, just make sure your server class path has included the Spring jar library (e.g. spring -4.0.4.jar).

In a debugging environment, steps may differ from different IDEs, but the solution is the same. In Eclipse, developers typically create tomcat, jboss ... regardless of the application server for debugging, just make sure the correct Spring flags are enabled.

  • Double click on the debug server
  • Click "Open Launch Configuration" to access the server environment.
  • Go to the class path tab
  • Add the Spring jar file here, you may also need a general log file due to the Spring dependency.
  • Done, run the application again.

.

Solution 2. If you use Maven as a build tool and load dependencies using it, a jar conflict may occur. Since Tomcat servers usually provide some banks, such as servlet-api and jpa-api. Therefore, if you re-enable them using maven; there will be problems with their identification.

Solution 3. If you use Eclipse as your IDE and use Maven as a build tool and tomcat as your server; remember that the Tomcat server will not look at banks that are only inside folders. There’s a little trick for this,

  • Right click on the project and select properties
  • In the window that appears, select Deployment Deployment
  • Choose Add
  • Add Maven Dependencies
  • Click Apply and click OK.

We hope that one of these solutions helps you solve your problem. Happy Coding and make sure you use Java.

+22
source

In my situation, I use maven to create a project, simply because the war file was not created correctly, this will lead to this exception. I check the war file and run the installation again to solve my problem.

+1
source

You need to download the necessary jar file. You can download the spring -context.jar file from the following link

http://mvnrepository.com/artifact/org.springframework/spring-context/3.2.2.RELEASE

0
source

I suggest you replace all Spring banks with the latest version (3.2.2.RELEASE)

0
source

Make sure your server class path includes the Spring jar library. Check out this link .

0
source

All Articles