我在加載jar時遇到了一些麻煩。我部署了一個Struts2的Web應用程序在Tomcat上,它導致錯誤:Maven和Tomcat的罐子衝突?
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:....../Tomcat%206.0/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:....../Tomcat%206.0/webapps/Timesheet/WEB-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
2011-03-31 14:33:48,302 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles:748 - Loading action configurations from: struts-default.xml
2011-03-31 14:33:50,592 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles:832 - Loaded action configuration from: struts-default.xml
...
2011-03-31 14:33:50,809 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register:202 - Loaded type:com.opensymphony.xwork2.util.XWorkConverter name:struts impl:com.opensymphony
.xwork2.util.AnnotationXWorkConverter
Mar 31, 2011 2:33:50 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Mar 31, 2011 2:33:50 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Timesheet] startup failed due to previous errors
我已經排除在pom.xml
所有jar-衝突,但它似乎又是slf4j-log4j
文件在Tomcat的lib。
然後我試圖刪除SLF4J-log4j12-1.5.8.jar在Tomcat的/ lib目錄並重新運行戰爭,但還是得到了另一個錯誤:
Mar 31, 2011 2:44:51 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(...\Tomcat 6.0\webapps\Timesheet\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class:
javax/servlet/Servlet.class
... // Struts file still loaded here, but another Error filterStart: the same as above.
難道我錯過了什麼嗎?
編輯:我有去除包括在pom.xml的冗餘servlet的API:它被意外由另一個罐包括在內。但排除那個罐子後,我得到了錯誤:
Mar 31, 2011 4:11:19 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(...\Tomcat 6.0\webapps\Timesheet\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class:
javax/servlet/Servlet.class
2011-03-31 16:11:20,234 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles:748 - Loading action configurations from: struts-default.xml
2011-03-31 16:11:21,028 DEBUG com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles:832 - Loaded action configuration from: struts-default.xml
我的Tomcat的servlet-api版本爲2.5; pom.xml中排除的servlet-api.jar版本爲2.4。
我認爲這可能是原因的一部分,但問題仍然存在。您介意查看我更新的問題嗎? – 2011-03-31 09:22:47
@HoàngLong mvn clean,以確保舊罐子不存在於目標 – Bozho 2011-03-31 10:54:07
實際上,「mvn clean」解決了我的問題,即使我沒有在pom.xml中排除servlet-api-2.4.jar。奇怪。 – 2011-04-04 04:31:01