当前位置: 代码迷 >> 综合 >> tomcat异常java.lang.reflect.InvocationTargetException web.xml 2.5 3.0
  详细解决方案

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

热度:50   发布时间:2024-01-09 11:33:04.0

十二月 04, 2014 11:12:45 上午 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;;.
十二月 04, 2014 11:12:47 上午 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-80
十二月 04, 2014 11:12:47 上午 org.apache.coyote.ajp.AjpProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
十二月 04, 2014 11:12:47 上午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1988 ms
十二月 04, 2014 11:12:47 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十二月 04, 2014 11:12:47 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.2
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的问题)

 

 

 

  相关解决方案