Spring MVC | java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener - spring

Hi! Although I've found very similar questions over the forum, none of them was meeting my requirement.
I am using Tomcat 7 to deploy my spring app. However, I am facing:
‘java.lang.ClassNotFoundException:
org.springframework.web.context.ContextLoaderListener’ error,
java.lang.ClassNotFoundException:
org.springframework.web.context.ContextLoaderListener at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at
org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
at
org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Oct 09, 2012 7:37:32 PM org.apache.catalina.core.StandardContext
listenerStart SEVERE: Skipped installing application listeners due to
previous error(s) Oct 09, 2012 8:00:48 PM
org.apache.catalina.core.ApplicationContext log
I have verified that org.springframework.web-3.1.2.RELEASE.jar is present in the WEB-INF\ \lib\ folder and the required file is present inside it. Kindly note that I am not using any build tool to deploy this web-app like maven.
I have tried to clean and reinstall the app, restarted Tomcat, but didn't have any luck.
Please help.

In WEB-INF\ \lib\ where? In artifacts, or in the project? if it is in the project then it does not mean it is in classpath, If you are using eclipse and did not edit output classpath by eclipse - tomcat setting then you should make sure the .jar file is in:
..\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\YourApp\WEB-INF\lib
that is the default place that eclipse makes artifact and deploys it from there. So make sure you included jar file in eclipse build path configuration. First time when you add new jar or something that related to classpath then do: right click on tomcat(in eclipse) then publish from menu, By this way eclipse updates whole artifact.

Worth verifying if you have the project structure and required jars in classpath. You can take help of this if required for set up.

If you are sure all the jars are available in your lib directory, try cleaning tomcat work directory.
From eclipse (servers view), right click on Tomcat server and then click on the menu "Clean Tomcat Work Directory).

Related

Spring Batch Admin Config Throw ClassNotFoundException

I am unable to configure Spring Batch Admin 1.3.0
I have overridden the data source defaults but I keep getting all kinds of errors.
The last one has to do with ClassNotFoundException.
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.MessagingException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) ~[catalina.jar:7.0.42]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) ~[catalina.jar:7.0.42]
... 35 more
Sep 30, 2014 5:45:18 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
I have included Spring Messaging 4.0 jar in the pom..
I had similar issues using Spring Batch Admin 1.3.0 with Spring 4.1.4 . Several of the classes have had their names changed or have been moved to different packages. Also, a couple of the previously deprecated "SimpleXxx" classes have been dropped (SimpleJdbcTemplate, for example). The resolution is to use the current classes and packages, and to lose the "simple" from a couple of class names.
I finally resolved all of my issues with spring-batch-admin by downloading the current 1.3.1.RELEASE source from github and building it without any modifications.
Does this help?
You might be missing spring-integration-core jar. Please check and try again.

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport

While I am deploying and runing my web application on Apache Tomcat in Eclipse IDE
I've included the JSTL1.2.jar, jstl-impl.jar.
I'm really wondering how to get this fixed. The same deployment works perfectly fine on Weblogic server(on PROD environment)
Exception stack trace:
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Feb 10, 2014 6:40:29 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1223)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)
at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
I would check a number of things:
1) That the jar files are sitting in the lib folder under WEB-INF and not just referenced in the build path.
2) That the tomcat 7 runtime library is included in your build path
3) I'd check the web.xml file and ensure that I'm complying to a spec higher than or equal to 2.5.
If you provide more details with your project setup it might be easier to answer.

Error while deploying application in tomcat 7

Hi I am getting the following error while deplying application in tomcat:
Jul 25, 2013 5:04:43 PM org.apache.catalina.deploy.NamingResources cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/oms-inter-web]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:988)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:970)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5494)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1595)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1585)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Any help will be appreciated.
it may be because of previous applications are not properly undeployed from tomcat container.
Stop the tomcat, and then
go to the tomcat conf directory /<Tomcat root>/conf/Catalina/localhost and clean the xml files in that directory. and restart the tomcat
Note:
1. make a backup of those xml files before deleting, so that if this not works then you can restore it.
To do the same in Netbeans IDE
In Netbeans menu go to Window->Services ,
In the listed Services expand Servers->->web applications-> right click on each application and choose Undeploy
Note: the tomcat need to be in running condition for this
I had exact the same problem and because Eclipse Tomcat was using the same working directory as Tomcat standalone I cannot started the standalone Tomcat properly. The solution was to change the Eclipse-Tomcat Config - Arguments - Working directory to something different than Tomcat/webapps.

Error configuring application listener of class org.springframework.web.context.ContextLoaderListener

I'm trying to deploy my application through IntelliJ IDEA 11.0, and it is giving me the following error:
09:35:52,997 WARN [JAXWSDeployerHookPreJSE] Cannot load servlet class: org.springframework.web.servlet.ViewRendererServlet
09:35:52,999 INFO [TomcatDeployer] deploy, ctxPath=/my-portlet-1.0, warUrl=.../tmp/deploy/tmp555932443707493677my-portlet-1.0-exp.war/
09:35:53,386 ERROR [0]] Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
...
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
09:35:53,391 ERROR [0]] Skipped installing application listeners due to previous error(s)
09:35:53,391 ERROR [StandardContext] Error listenerStart
09:35:53,391 ERROR [StandardContext] Context [/my-portlet-1.0] startup failed due to previous errors
09:35:53,402 WARN [ServiceController] Problem starting service jboss.web.deployment:war=my-portlet-1.0.war,id=-135869088
org.jboss.deployment.DeploymentException: URL file:/C:/JBOSS/jboss-portal-2.7.2/server/default/tmp/deploy/tmp555932443707493677my-portlet-1.0-exp.war/ deployment failed
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:386)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
...
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
09:35:53,407 ERROR [MainDeployer] Could not start deployment: file:C:/Users/Abbas/Projects/my-app/my-portlet/target/my-portlet-1.0.war
org.jboss.deployment.DeploymentException: URL file:/C:/JBOSS/jboss-portal-2.7.2/server/default/tmp/deploy/tmp555932443707493677my-portlet-1.0-exp.war/ deployment failed
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:386)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
...
at java.lang.Thread.run(Thread.java:662)
[2012-07-25 09:35:53,431] Artifact my-portlet:war: Error during artifact deployment. See server log for details.
Does anyone know how to fix this?
Actually I was also facing the same problem and after wasting a lot of time. I realized that actually it is a very silly error. You must have changed the pom file and update the dependencies. But once we do so the jar files of maven dependencies are removed from deployment Assembly.
All you need to do is:
Right click the project folder.
click on properties.
click on Web Deployment Assembly.
check if maven dependencies are listed or not.
if not click the add button
from the list select the maven dependencies and done, apply and OK!
Hope this solve your problem. If you still have it!
ContextLoaderListener is in org.springframework.web-3.0.4.RELEASE.jar
You mentioned a file called org.springframework-3.0.4.RELEASE.jar, which is different.
Maybe you have a typo in your dependencies file?

Tomcat 7 - unable to load class X warnings

Lately I've noticed that after deploying a web application to Tomcat 7 from Eclipse, I'm getting 30+ warnings in the Catalina log file that look like the following:
Oct 17, 2011 3:33:47 PM org.apache.catalina.startup.ContextConfig
checkHandlesTypes WARNING: Unable to load class
[com.sun.codemodel.JArrayClass$1] to check against the #HandlesTypes
annotation of one or more ServletContentInitializers.
java.lang.ClassNotFoundException: com.sun.codemodel.JArrayClass$1 at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at
org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1969)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1932)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1826)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1785)
at
org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1771)
at
org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1254)
at
org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
at
org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
The application still works fine, it's just a pain to have to scroll past all these warnings to get to debugging lines. Any idea on how to fix these warnings?
Turns out that the jaxb-xjc.jar wasn't needed for deployment so I just ended up removing it from the classpath which ended up getting rid of all the warning messages.
The following forum post also outlines a problem that occurs when using Metro 2.1.1 with Servlet 3.0 WebApps - may also be of value:
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/metro-211-and-servlet-version-30-tomcat-many-startup-errors
Check your dependencies. One (or more) of them contain META-INF/services/javax.servlet.ServletContainerInitializer file. This file contains class names of type ServletContainerInitializer. ServletContainerInitializers usually have #HandlesTypes annotation which refers classes. One of the referred classes imports/use com.sun.codemodel.JArrayClass which is not on your webapp's classpath.
This question also could be useful: Class implementing ServletContainerInitializer in web.xml
I faced the same issue with tomcat version 7.0.23. I didn't notice this issue after I switched to Tomcat 7.0.33.
Even when I just replaced ${tomcat.dir}/lib/*jars with the jars from the latest tomcat, the problem was solved.
Alternatively, if it helps
two other solutions work
Modify web.xml for every war in webapps and change the web-app version to 2.5 from 3.0
or
Add metadata-complete=true to web-app tag

Resources