java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25180880/
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-11-02 07:31:28  来源:igfitidea点击:

java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener error

javaspringhibernate

提问by Shrikant Dande

Hi my dynamic web application in struts1 spring and hibernate integration is developed on 64 bit machine..Its running fine on 64 bit machine but giving jar issues on 32 bit machine its giving following error

嗨,我在 struts1 spring 和 hibernate 集成中的动态 Web 应用程序是在 64 位机器上开发的。它在 64 位机器上运行良好,但在 32 位机器上出现 jar 问题,它给出了以下错误

    SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    at java.lang.ClassLoader.findBootstrapClass(Native Method)

and

    SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    at java.lang.ClassLoader.findBootstrapClass(Native Method)

should i change all jars for 32 bit machine?

我应该为 32 位机器更改所有 jars 吗?

回答by nicearma

I had some similar problem in when i tried to compile one project without the servlet dependancy, if you use maven put the javax.servlet in the pom.xml

当我尝试编译一个没有 servlet 依赖关系的项目时,我遇到了一些类似的问题,如果您使用 maven 将 javax.servlet 放在 pom.xml 中

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
</dependency>

You can change the version to another if you know the version target and the scope is providedbecause is probably that you will use tomcat or another type of server, that contain already the implementation

如果您知道版本目标并且提供了范围,您可以将版本更改为另一个版本,因为您可能会使用已经包含实现的 tomcat 或其他类型的服务器

Or if you not use maven, you can download the .jar and add to the lib folder of your projet

或者如果你不使用 maven,你可以下载 .jar 并添加到你的项目的 lib 文件夹中

回答by AlexR

You just do not have Spring (totally or partially) in your classpath at runtime. It seems that Log4jConfigListeneris the first class referenced when you try to load your application. Take care on copying all needed jar files to your WEB-INF/libdirectory.

在运行时,您的类路径中没有 Spring(全部或部分)。这似乎Log4jConfigListener是您尝试加载应用程序时引用的第一个类。小心将所有需要的 jar 文件复制到您的WEB-INF/lib目录中。