java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20039546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 22:34:33  来源:igfitidea点击:

java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener

javaspringmaventomcat

提问by Shelly

Well, i'm trying to Run my web application in tomcat, but i got the following error:

好吧,我正在尝试在 tomcat 中运行我的 Web 应用程序,但出现以下错误:

Nov 18, 2013 12:19:35 AM org.apache.catalina.core.StandardContext listenerStart
Grave: Error configuring application listener of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
    at org.apache.catalina.core.StandardContext.call(StandardContext.java:5204)
    at org.apache.catalina.core.StandardContext.call(StandardContext.java:5199)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

My project works with and some classes have strange errors, like this: "JOIN FETCH expressions cannot be defined with an identification variable.". When i run "Maven --> Update Project" the error in "JOIN FETCH.." disappear but i continue don't get start my server.

我的项目与某些类一起工作,并且有些类有奇怪的错误,例如:“JOIN FETCH 表达式不能用标识变量定义。”。当我运行“Maven --> Update Project”时,“JOIN FETCH ..”中的错误消失了,但我继续没有启动我的服务器。

EDIT 1: My pom.xml

编辑 1:我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.sender</groupId>
    <artifactId>Sender</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>sender App</name>
    <url>http://maven.apache.org</url>
    <properties>
        <org.springframework.version>3.0.6.RELEASE
        </org.springframework.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>0.7.1</version>
        </dependency>


        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.6</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.6</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>


        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.4.0.GA</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2.2</version>
        </dependency>       
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.0.2.GA</version>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-commons</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>2.7.4</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.5</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>bootstrap</artifactId>
            <version>1.0.9</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3</version>
        </dependency>


        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>

        <repository>
            <id>java.net2</id>
            <name>Java.net</name>
            <url>https://oss.sonatype.org/content/repositories/java.net2</url>
        </repository>
    </repositories>

    <build>
        <finalName>sender</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <targetJdk>1.6</targetJdk>
                </configuration>
            </plugin>
        </plugins>
        <resources>
         <resource>
            <directory>src/main/resources</directory>
         </resource>
        </resources>
    </build>
</project>

回答by SkorpEN

In eclipse -> Your Project -> Properties -> Java Build Path -> Order and Export -> check Maven Dependencies. Or in WebProject -> Your Project -> Properties -> Deployment assambly -> check Maven Dependencies. This work in my case.

在 eclipse -> Your Project -> Properties -> Java Build Path -> Order and Export -> 检查 Maven Dependencies。或者在 WebProject -> Your Project -> Properties -> Deployment assambly -> 检查 Maven Dependencies。在我的情况下这项工作。

回答by KingFeming

For this error, there can be different solutions. I have noted down the ones that had worked for me.

对于此错误,可以有不同的解决方案。我已经记下了对我有用的那些。

Solution 1.This is always happened in deployment and debugging environment. In deployment environment, just make sure your server classpath has included the Spring jar library (e.g spring-4.0.4.jar).

解决方案 1.部署和调试环境中经常出现这种情况。在部署环境中,只需确保您的服务器类路径已包含 Spring jar 库(例如 spring-4.0.4.jar)。

In debugging environment, the steps may vary from different IDE, but the solution is same. In Eclipse, developers usually will create a tomcat, jboss…whatever application server for debugging, just make sure the correct Spring jars are included.

在调试环境中,不同IDE的步骤可能有所不同,但解决方法是一样的。在 Eclipse 中,开发人员通常会创建一个 tomcat、jboss……任何用于调试的应用程序服务器,只要确保包含正确的 Spring jar 即可。

  1. Double click on your debugging server Click on the “Open launch
  2. configuration” to access the server environment Click on the classpath tab Include the Spring jar file here , it may also required common log jar due to Spring dependency.
  3. Done, run your application again.
  1. 双击您的调试服务器单击“打开启动
  2. 配置”访问服务器环境点击classpath选项卡在此包含Spring jar文件,由于Spring依赖,可能还需要common log jar。
  3. 完成,再次运行您的应用程序。

.

.

Solution 2. If you are using Maven as a build tool and downloading dependencies using it, there can be some jar conflict. Because Tomcat servers normally provide some jars such as servlet-api and jpa-api. So if you again included them using maven; there will be problems in identifying them.

解决方案2。如果您使用 Maven 作为构建工具并使用它下载依赖项,则可能存在一些 jar 冲突。因为Tomcat服务器一般都会提供servlet-api、jpa-api等一些jar包。因此,如果您再次使用 maven 包含它们;识别它们会有问题。

Solution 3. If you are using Eclipse as your IDE and using Maven as your build tool and tomcat as your server; remember Tomcat server will not look on the jars which are just inside the folders. For that there's a small trick,

解决方案3。如果您使用 Eclipse 作为您的 IDE,并使用 Maven 作为您的构建工具和 tomcat 作为您的服务器;请记住,Tomcat 服务器不会查看文件夹中的 jar。为此,有一个小技巧,

  1. Right click on your project and select properties From the displayed window,

  2. select Deployment Assembly

  3. Select Add

  4. Add Maven dependencies

  5. Click Apply and Click OK

  1. 右键单击您的项目并选择属性 从显示的窗口中,

  2. 选择部署程序集

  3. 选择添加

  4. 添加Maven依赖

  5. 单击应用并单击确定

Hope one of these solutions would help you to solve your problem. Happy Coding and make sure that is using Java.

希望这些解决方案之一可以帮助您解决问题。快乐编码并确保使用 Java。

回答by Mu'ath Baioud

I have faced a similar issue with the same exception "java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener".

我遇到了同样的异常“java.lang.ClassNotFoundException:org.springframework.web.context.request.RequestContextListener”的类似问题。

It fixed after adding one dummy class in the src/main/java folder, and I really didn't know how this did the trick, it works for me.

它在 src/main/java 文件夹中添加一个虚拟类后修复了,我真的不知道这是如何做到的,它对我有用。

回答by Kimchi Man

Project Properties

项目属性

I had the same issue, but I fixed by adding Maven Dependencies. It was missing for some reason, and I have no clue

我有同样的问题,但我通过添加Maven Dependencies. 由于某种原因它不见了,我不知道