2
votes

I am new to this forum. I am trying to make an application using spring 3.2.6 and tomcat 7.0. I have added all the necessary jars in the WEB-INF/lib folder. The DispatcherServlet and ContextLoaderListener is properly configured in the web.xml. The same application was working fine with spring 3.0.2 version. Now when I am trying to open the jsp page, it is giving me below error:

HTTP Status 500 - org/springframework/web/servlet/HttpServletBean : org/springframework/context/EnvironmentAware


type Exception report

message org/springframework/web/servlet/HttpServletBean : org/springframework/context/EnvironmentAware

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.NoClassDefFoundError: org/springframework/web/servlet/HttpServletBean : org/springframework/context/EnvironmentAware java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) java.lang.ClassLoader.defineClass(ClassLoader.java:616) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) java.lang.Thread.run(Thread.java:662)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.42 logs.

The jar

spring-context-3.2.6.RELEASE

is already added in the classpath. I am able to open the class file also from the Eclipse. But I don't understand why it is giving class not found error at run time. I tried to search it on google but didn't find exact the solution. Thanks in advance.

4

4 Answers

0
votes

If it works for an older version(as you say), What I guess there are some places you have old jar in the path, which mess up the jar dependency I will suggest you do a full disk search to find out all your spring jar location and clean them up. BTW: you can try to add jar to tomcat/lib to try also (it is not proper practice, but this can help to find out whether it is path related issue).

0
votes

The class org.springframework.web.servlet.HttpServletBean is part of spring-webmvc. You will need to add that library to your classpath as well. You can get it here.

0
votes

EnvironmentAware is located in the spring-context-3.1.1.RELEASE.jar, so you are missing that one.

Also recheck your Maven POM file so that you are not missing any other Spring library, like spring-web, spring-webmvc (you may have these since the DispatcherServlet class if found), spring-orm if you use an ORM like Hibernate, spring-jms if you use JMS, etc.

0
votes

I had this problem. I solved it by adding the jar:

org.springframework.context-3.1.0.RELEASE.jar

to both the build path and as a maven dependency (java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet error)

Hope it helps