6

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
John Smith
  • 831
  • 5
  • 19
  • 37
  • Sounds like you are trying to run from with Eclipse? Not 100% sure. If you are, open the Run-Configurations and take a look at the "Arguments" tab of the server you are trying to deploy to. This will tell where the deployment is located. It is usually under .../.metadata/somewhere.... Go there, look in the "logs" directory at catalina.out and localhost.todaydate.log and see what errors are being reported. – JoeG Sep 25 '12 at 13:14
  • yep, i'm working with eclipse. and I found no logs. I looked for them in many folders, but no result :( – John Smith Sep 25 '12 at 13:48
  • had to add an "answer" to tell you how to enable that - sorry I forgot the details earlier. Try that and see if you get any errors. – JoeG Sep 25 '12 at 14:20
  • john, I had a very similar issue yesterday and posted a few hints on http://stackoverflow.com/questions/10046654/maven-spring-dynamic-web-module-eclipse-java-lang-classnotfoundexcepti/12600686#12600686 – Adriano Sep 26 '12 at 11:50

3 Answers3

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/

Mukesh Kumar
  • 945
  • 4
  • 11
  • 26
1

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

vacuum
  • 2,273
  • 3
  • 20
  • 32
  • spring version is 3.0.6.Release – John Smith Sep 25 '12 at 10:08
  • probably, maven can't find the jars, but they are in the repository and the classes and methods are called normally. but the issue project can't start worries me more – John Smith Sep 25 '12 at 10:20
  • maybe this issues are connected? More important that your project must work without any IDE. – vacuum Sep 25 '12 at 10:34
  • @JohnSmith you need to package war-file with your porject and try to deploy it on standalone Tomcat. – vacuum Sep 25 '12 at 10:35
  • @JohnSmith seems to me, you have mess with libraries in classpath. Some library may conflict with other. For example, if you have two versions of spring-web.jar – vacuum Sep 25 '12 at 10:53
  • You should at least make sure "maven clean install" is able to run successfully. Then check whether the necessary dependencies resident in the war file or WEB-INF folder under the target folder. If All above pass but the problem remains, you can add a VM parameter -verbose:class, this will show all the class loading info of the JVM. – Gavin Xiong Jan 02 '13 at 08:06
0

This is not an answer per se, but needed to type more than I could fit in a comment. This only tells you how to enable logging of the Eclipse Tomcat instance. It is messier than I remembered to enable loggin of the Eclipse Tomcat instances. You still edit the runtime configuration. On the "Arguments" tab under VM arguments add 2 properties:

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djava.util.logging.config.file=/path_to_your/logging.properties

This should enable your logging per the logging.properties file (which can be placed anywhere - I seldom change my Eclipse servers so I just put a copy in the "conf" directory there).

In case you need one handy, here is a copy of a logging.properties file:


# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler,     3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.

4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers =   2localhost.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE
JoeG
  • 7,191
  • 10
  • 60
  • 105