servlet.jar--jar not loaded错误

本文分析了Tomcat启动时出现的特定错误信息原因,并提供了两种解决方案:一是解决servlet.jar包冲突的问题;二是修正web.xml配置错误。

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

出错信息:validateJarFile(D:\Program Files\apache-tomcat-6.0.29\webapps\BookShop\WEB-INF\lib\servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

造成这种错误的原因有两个:servlet.jar包冲突web.xml文件配置出现问题

1、servlet.jar包冲突

如果在tmocat的lib目录下有了servlet.jar包,而又再在项目的\WEB-INF\lib\目录下加入servlet.jar包,这时候会造成包冲突,tomcat启动时会报上述错误,解决办法是把项目\WEB-INF\lib\路径下的servlet.jar删除。

与此类似,如果是jar冲突,就查看项目路径下是不是有了跟tomcat路径下相同的jar包,如果是则删除项目路 径中的jar包!

2、配置文件错误:

如果在tomcat的lib目录下并没有跟\WEB-INF\lib\目录下重复的包,这时候造成上述错误的原因就是web.xml文件有些配置出了问题,错误提示中有如下语句:org.apache.tomcat.util.digester.Digester endElement,有可能是servlet的配置名字跟页面中不一致,也有可能servlet的路径没有写对,还有可能是因为<servlet>跟<servlet-mapping>的顺序出现了错误,改正以上错误,重启tomcat,错误解决!

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值