简体   繁体   English

Tomcat中的Maven War部署错误

[英]Maven War Deployment Error in Tomcat

Basically I'm not able to overcome this error, trying time and again. 基本上,我无法克服此错误,需要反复尝试。

I have ported my current javaee project to maven, made a war from maven 3.0.3, which doesnt seem to deploy in tomcat 6.0.10.I am using jdk 1.7 (though, i get the same error using jdk 1.6 and tomcat 7) 我已经将当前的javaee项目移植到了maven,从maven 3.0.3发起了一场战争,它似乎没有部署在tomcat 6.0.10中。我使用的是jdk 1.7(尽管我在使用jdk 1.6和tomcat 7时遇到了相同的错误)

The error it throws is 它引发的错误是

Mar 15, 2013 10:24:39 AM org.apache.catalina.loader.WebappClassLoader validateJa
rFile
INFO: validateJarFile(D:\apache-tomcat-6.0.10\webapps\Name\WEB-INF\lib\
javaee-api-5.0-1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Off
ending class: javax/servlet/Servlet.class
Mar 15, 2013 10:24:39 AM org.apache.catalina.loader.WebappClassLoader validateJa
rFile
INFO: validateJarFile(D:\apache-tomcat-6.0.10\webapps\Name\WEB-INF\lib\
servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offe
nding class: javax/servlet/Servlet.class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
s.
Inside Cache Manager Initialization new ....
java.lang.NullPointerException
Mar 15, 2013 10:24:59 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 15, 2013 10:24:59 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Name] startup failed due to previous errors

When i tried to find out about the error "jar not loaded. See Servlet Spec 2.3, section 9.7.2", it said that the preferred jar must be present at both copilation and runtime, so i added servlet-api-2.5.jar inside the pom.xml. 当我尝试查找错误“未加载jar。请参阅Servlet Spec 2.3,第9.7.2节”时,它说首选的jar必须同时存在于编译和运行时,因此我添加了servlet-api-2.5.jar。在pom.xml中。 javaee-api-5.0.1.jar was already there. javaee-api-5.0.1.jar已经在那里。

After adding the dependency, i get the same error. 添加依赖项后,我得到相同的错误。

Anyone got any idea about this weird behaviour. 任何人都对这种奇怪的行为有任何想法。

Change the scope of servlet api to <scope>provided</scope> since it is provided by tomcat. 将servlet api的范围更改为<scope>provided</scope>因为它是由tomcat 提供的。 And javaee-api is NOT provided by tomcat, so keep it in your webapp. 而且tomcat不提供javaee-api ,因此请将其保存在您的webapp中。

Tomcat doesn't support the full Java EE stack, but only part of it (ie servlet-api is supported, but JTA, JPA, JMS aren't supported): that's why you need to include javaee-api in your web-app Tomcat不支持完整的Java EE堆栈,但仅支持其中一部分(即,支持servlet-api,但不支持JTA,JPA,JMS):这就是为什么您需要在Web应用程序中包含javaee-api

The "jar not loaded" errors are caused by having multiples of javax/servlet/Servlet.class for the Tomcat runtime to choose from. “无法加载jar”错误是由可供Tomcat运行时选择的javax/servlet/Servlet.class倍数引起的。 Remove javaee-api-5.0-1.jar and servlet-api-2.5.jar from your app's WEB-INF/lib . 从应用程序的WEB-INF/lib删除javaee-api-5.0-1.jarservlet-api-2.5.jar These jars are already provided by Tomcat. 这些jar已由Tomcat提供。 To verify this look in <TOMCAT_HOME>\\lib to see that these jars are already there. 要验证这一点,请在<TOMCAT_HOME>\\lib中查看这些罐子已经存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM