Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 638
John Smith Avatar asked Nov 03 '22 15:11

John Smith


2 Answers

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/

like image 190
Mukesh Kumar Avatar answered Nov 09 '22 11:11

Mukesh Kumar


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

like image 43
vacuum Avatar answered Nov 09 '22 13:11

vacuum