WEB-INF/lib/servlet-api.jar not loaded

本文介绍了Tomcat启动时报错“WEB-INF/lib/servlet-api.jarnotloaded”的原因及解决方法。通过调整项目中WEB-INF/lib目录下与tomcat共同目录中的JAR包,避免重复加载冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误提示

WEB-INF/lib/servlet-api.jar not loaded

 

错误现象

启动tomcat后,控制台报错:WEB-INF/lib/servlet-api.jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class


网上说明解决办法:
保证WEB-INF/lib跟tomcat的common/lib下的JAR包没有重复的包即可!
将项目的web-inf/lib下的servlet-api.jar删掉!ok

 

个人总结

WEB-INF/lib目录,存放jar包,就好象C#的bin目录存放控件一样,都是固定的指定存储路径。

个人理解,存放在WEB-INF/lib目录,jar可以用svn统一管理,而保存在tomcat目录,则只能在个人机器上管理,且tomacat的版本不同,可能会存在jar包丢失或版本不一致的情况,建议,统一保存在WEB-INF/lib目录的方式进行开发。

解决方法,没做处理,现在tomcat/lib和WEB-INF/lib目录,都保存了份,只是多了一个警告提示;因不能删除tomcat/lib目录下的该文件,否则系统报错。

 

 

呵呵,java有多种工具,有的是可以自动引用的。

An attempt was made to call a method that does not exist. The attempt was made from the following location: org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1200) The following method did not exist: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; The calling method's class, org.apache.catalina.authenticator.AuthenticatorBase, was loaded from the following location: jar:file:/D:/Maven/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.96/tomcat-embed-core-9.0.96.jar!/org/apache/catalina/authenticator/AuthenticatorBase.class The called method's class, javax.servlet.ServletContext, is available from the following locations: jar:file:/D:/Maven/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class jar:file:/D:/Maven/repository/javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class jar:file:/D:/Maven/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.96/tomcat-embed-core-9.0.96.jar!/javax/servlet/ServletContext.class The called method's class hierarchy was loaded from the following locations: javax.servlet.ServletContext: file:/D:/Maven/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes org.apache.catalina.authenticator.AuthenticatorBase and javax.servlet.ServletContext 16:23:59.301 [Thread-15] WARN c.a.n.c.n.NotifyCenter - [shutdown,136] - [NotifyCenter] Start destroying Publisher 16:23:59.301 [Thread-10] WARN c.a.n.c.h.HttpClientBeanHolder - [shutdown,102] - [HttpClientBeanHolder] Start destroying common HttpClient 16:23:59.301 [Thread-15] WARN c.a.n.c.n.NotifyCenter - [shutdown,153] - [NotifyCenter] Destruction of the end
03-22
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值