servlet-api-2.5.jar – jar not loaded
2015-07-13 23:07
405 查看
Deployed a “war” file on Tomcat, and hits following error messages :
Reason
The Tomcat’s container comes with own version of servlet-api.jar, and the “war” file is deploy the same jar again, and causing the Offending class: javax/servlet/Servlet.class.
This is a really common problem for developers who are using Maven as a build tool. Normally, we will include the servlet-api as a project dependency like this :
When building a war file, Maven will include the servlet-api as well.
Solution
To fix it, set the scope to provided. This tells Maven use code servlet-api.jar for compiling and testing only, but NOT include it in the WAR file. The deployed container will “provide” the servlet-api.jar at runtime.
References
Maven : Introduction
4000
to the Dependency Mechanism
转自:http://www.mkyong.com/java/servlet-api-2-5-jar-jar-not-loaded/
相关:http://stackoverflow.com/questions/1993493/error-servlet-jar-not-loaded-offending-class-javax-servlet-servlet-class
http://yunzhu.iteye.com/blog/1015416
自己的理解:
WEB-INFO/lib中的jar与Tomcat/lib中的service-api.jar冲突了,Tomcat启动后,只会用他自己的jar,所以自己配置的jar要删掉
Jul 17, 2014 7:59:55 PM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(D:\apache-tomcat-7.0.53\webapps\hc\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class Tools used : JDK1.7 Maven 3 Tomcat 7
Reason
The Tomcat’s container comes with own version of servlet-api.jar, and the “war” file is deploy the same jar again, and causing the Offending class: javax/servlet/Servlet.class.
This is a really common problem for developers who are using Maven as a build tool. Normally, we will include the servlet-api as a project dependency like this :
pom.xml <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency>
When building a war file, Maven will include the servlet-api as well.
Solution
To fix it, set the scope to provided. This tells Maven use code servlet-api.jar for compiling and testing only, but NOT include it in the WAR file. The deployed container will “provide” the servlet-api.jar at runtime.
pom.xml <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency>
References
Maven : Introduction
4000
to the Dependency Mechanism
转自:http://www.mkyong.com/java/servlet-api-2-5-jar-jar-not-loaded/
相关:http://stackoverflow.com/questions/1993493/error-servlet-jar-not-loaded-offending-class-javax-servlet-servlet-class
http://yunzhu.iteye.com/blog/1015416
自己的理解:
WEB-INFO/lib中的jar与Tomcat/lib中的service-api.jar冲突了,Tomcat启动后,只会用他自己的jar,所以自己配置的jar要删掉
相关文章推荐
- Struts2.3.4.1异常及解决方法1(javassist-3.11.0.GA.jar包的添加)
- learning English <1>
- memcached和redis对比
- FragmentStatePagerAdapter第二次加载时不能显示其界面的原因及解决办法
- jquery checked
- Linux内核源码针对S3C2440的初步框架交叉编译过程分享
- HTML“pre”标签 :用pre元素可定义预先格式文字。所有在pre元素内文字的空白间隔以及换行都会被保留。
- Java的基本类型
- 2015071305 - 整洁的房屋
- HDU 2844 Coins (多重背包计数 空间换时间)
- Oracle数据库的导入导出
- 微信开发博客——柳峰
- 继承
- ado.net连接数据库
- 银行系统
- 大学中的一些心得体会——写给学弟学妹
- 利用yum下载软件包
- 使用 maskView 设计动画
- 当我设计游戏服务器时,我在想些什么?(4)
- 《coredump问题原理探究》Linux x86版7.9节list相关的iterator对象