我在加载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