Java 服务器启动时,违规课程告诉我什么?

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

What does offending class tell me on server startup?

javatomcat

提问by membersound

I'm having the jee7 web api as dependency. I can start my app on tomcatapplication successfully, but what does the following "offending class" statements tell me? Do I have to take any actions?

我有 jee7 web api 作为依赖项。我可以在tomcat应用程序上成功启动我的应用程序,但是以下“违规类”语句告诉我什么?我必须采取任何行动吗?

Jan 13, 2014 5:47:47 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
Information: validateJarFile(C:\Users\me\Servers\apache-tomcat-7.0.50\wtpwebapps\app\WEB-INF\lib\el-api-2.2.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
Jan 13, 2014 5:47:47 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
Information: validateJarFile(C:\Users\me\Servers\apache-tomcat-7.0.50\wtpwebapps\app\WEB-INF\lib\javaee-web-api-7.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class

pom.xml

pom.xml

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
    </dependency>

采纳答案by Sotirios Delimanolis

It seems like you (your Servlet container) are trying to load some classes that have already been loaded. The servlet-apiand el-apishould be provided by the Servlet container.

看起来您(您的 Servlet 容器)正在尝试加载一些已经加载的类。在servlet-apiel-api应该由Servlet容器来提供。

Change your pom.xml to account for that

更改您的 pom.xml 以解决该问题

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>

回答by Siva Kameswara Rao Munipalle

I have faced the same issue during a project using Eclipse.

我在使用 Eclipse 的项目中遇到了同样的问题。

Doing below things resolved the issue

做以下事情解决了问题

  1. Added javax.*.jar to the build path
  2. Removed the project - gave clean build and add the project and finally published....!!
  1. 添加了 javax. *.jar 到构建路径
  2. 删除了项目 - 进行了干净的构建并添加了项目并最终发布....!!

Bingo...!!

答对了...!!

This resolved my issue. Hope this helps.

这解决了我的问题。希望这可以帮助。

Thanks,

谢谢,

mskr.

mskr。

回答by Vijay Bhatt

This is a very common problem for developers who are using Maven as a build tool. when , we include the servlet-api as a project dependency i.e pom.xml like this :

对于使用 Maven 作为构建工具的开发人员来说,这是一个非常常见的问题。时,我们将 servlet-api 作为项目依赖项,即 pom.xml 包含在内,如下所示:

<dependency>
<groupId>  javax.servlet</groupId>

<artifactId>servlet-api</artifactId>
<version>2.5</version>

add scope as provided in the above dependency as following .

添加上述依赖项中提供的范围,如下所示。

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

回答by joemadeus

I fixed this by using the correct Servlet API version: Tomcat 7.x expects version 3.0.x, not the 3.1.x I'd tried using.

我通过使用正确的 Servlet API 版本解决了这个问题:Tomcat 7.x 需要 3.0.x 版本,而不是我尝试使用的 3.1.x。