Problem with Error listenerStart

I encountered a problem with a web.xml today.

Use Spring to integrate the Struts2 framework and configure a listener in the web.xml file to complete the function of loading the Spring configuration file. The code to join is simple. Only the content of <listener>...</listener> is added.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<listener>
      <listener-class>
              org.springframework.web.context.ContextLoaderListener
      </listener-class>
  </listener>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>
    
  </web-app>

(Of course, the premise is that the Spring configuration file applicationContext.xml has been created under the WebRoot/WEB-INF/ path of the project .)

After running my registration page, register.jsp file. An exception occurred.

And the Tomact console just shows

Critical: Error listenerStart.

I have searched for several hours of information on the Internet and have their own methods, but none of them are very useful. I have tried a lot, but still the same Error listenerStart.

Looking for a way to no avail, then look for the cause of the problem.

In the Tomcat directory, find the logs folder. Inside find localhost.2016-12-23.log. Here's today's log with the problem that the console doesn't show. (The console only shows Error listenerStart)

my exception:

Dec 23, 2016 6:23:46 PM org.apache.catalina.core.StandardContext listenerStart
严重: 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:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4179)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4739)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1287)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1385)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1393)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1657)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1666)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1646)
at java.lang.Thread.run(Thread.java:745)

The exception is simple, the corresponding class could not be found.
The project can import spring-web.jar.
Everyone may have different reasons for error. Nine times out of ten, the same method to solve a problem will fail.
So first you have to find out the cause of your problem.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325516360&siteId=291194637