java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener issue

34,239

Solution 1

Looks like some configuration issue with your application. You can refer this link http://www.mkyong.com/spring/spring-error-classnotfoundexception-org-springframework-web-context-contextloaderlistener/

Solution 2

What is your spring version?

Run mvn clean install on your project

And then mvn tomcat:run Show the result log.

You need to package war-file with your porject and try to deploy it on standalone Tomcat

Share:
34,239
John Smith
Author by

John Smith

Updated on July 26, 2020

Comments

  • John Smith
    John Smith almost 4 years

    when I try to start my app, console shows the next stacktrace:

    java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    

    I've read about the same problem, but ther were absent spring-web jars, but in my pom.xml I've included spring dependencies, the problem stays:

             <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
            </dependency>
    

    here is web.xml file(just to be sure):

    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath:/context/webContext.xml
            </param-value>
        </context-param>
    
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>classpath:log4j.xml</param-value>
        </context-param>
    
    
    
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <servlet>
            <servlet-name>springServlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value></param-value>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>springServlet</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
    
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
         <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
            </filter-mapping>
    
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    
        <welcome-file-list>
            <welcome-file>login.jsp</welcome-file>
        </welcome-file-list>
    

    I made clean.., clean tomcat work directory..., I cleaned workspace with project->clean.. but nothing helped.. I'm in a such desperation...

    updated============= after some manipulation and magic :) I succeeded not to have such exception, but the next appears:

    java.lang.ClassCastException: org.springframework.web.filter.DelegatingFilterProxy cannot be cast to javax.servlet.Filter