2

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 Answers 4

0

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the hint. There were spring jars in the plugins folder of the eclipse installation. I tried removing those but didn't work. Then as per your suggestion, just copied the jar in the tomcat/lib folder and the error was not coming. But in this way I had to add all the jar which was not proper solution. Finally I just created new workspace and configure the project again which solved the issue. But I am still not sure about the error cause. Anyway, Thank you.
0

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.

6 Comments

Thanks for the comment. But I have already added spring-webmvc-3.2.6.RELEASE in the WEB-INF/lib folder.
@DDP Right click your project, select Properties and go to Deployment Assembly and Build Path. Are you jars added?
Yes. jars are added there. Even I tried by adding both the jars as external jars using Java >Build Path -> Libraries -> Add External JARs But still it gives the same error.
@DDP Can you add an image (or just write it up) of your directory structure?
I am unable to upload the image so I giving you the hierarchy in brief. It has WebContent -> WEB-INF ->lib. There are several other packages under src folder for model and controllers. But all the jars are placed in the lib folder
|
0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.