tomcat异常java.lang.reflect.InvocationTargetException web.xml 2.5 3.0

上午 org.apache.catalina.core.AprLifecycleListener init

信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.8.0_25\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\Program Files\Java\jdk1.8.0_25\jre\bin;D:/Program Files/Java/jdk1.8.0_25/bin/../jre/bin/server;D:/Program Files/Java/jdk1.8.0_25/bin/../jre/bin;D:/Program Files/Java/jdk1.8.0_25/bin/../jre/lib/amd64;d:\program files (x86)\imagemagick-6.3.9-q8;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\Java\jdk1.8.0_25\bin;D:\Program Files\mysql-5.5.29-winx64\bin;D:\Program Files (x86)\apache-maven-3.2.1\bin;D:\Program Files\TortoiseSVN\bin;D:\Program Files (x86)\Subversion\bin;;D:\Program Files (x86)\eclipse;;.

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:128)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:61)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:215)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:125)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1844)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1733)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1692)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1678)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1245)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:313)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4667)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)

... 6 more

相信在笔者写这篇文章的这个时间左右,应该还有其的苦逼程序员也被困扰了。原因其实仅仅是web.xml的问题,eclipse版本,tomcat版本的问题。

---笔者的开发环境---

[tomcat]

apache-tomcat-7.0.2

[eclipse]

Version: Luna Service Release 1 (4.4.1)
Build id: 20140925-1800

在eclipse这个版本下创建的web工程生成的web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>sdf</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

那么问题就来了,在tomcat7.0.2的这个版下运行,就会报最上边的错误。

解决方案:

修改version="3.0"为version="2.5"

修改http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd为http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd

也就是更换下版本号就ok了。

注意:

如果工程没有web.xml也会出现上边的报错。(所以,问题的根源是web.xml的问题)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值