org.apache.jasper.JasperException:无法为JSP编译类:生成的java文件中的行:[42]发生错误

时间:2015-01-04 05:18:34

标签: java jsp

我们正在使用jdk 1.8和apache tomcat 8.0.12 尝试部署简单的Web应用程序,但收到错误

INFO main org.apache.catalina.startup.Catalina - Initialization processed in 1622 ms
INFO main org.apache.catalina.core.StandardService - Starting service Catalina
INFO main org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/8.0.12
INFO tomgensoft.com-startStop-1 org.apache.catalina.startup.HostConfig - Deploying web application archive /home/tomgenso/tomcat/webapps/tomgensoft.com/ROOT.war
ERROR tomgensoft.com-startStop-1 org.apache.catalina.startup.ContextConfig - Unable to process web resource [/WEB-INF/classes/ConnectionManager.class] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 41
    at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:127)
    at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:59)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:168)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:92)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1990)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsWebResource(ContextConfig.java:1897)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1135)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:767)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:302)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5074)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
INFO tomgensoft.com-startStop-1 org.apache.catalina.startup.HostConfig - Deployment of web application archive /home/tomgenso/tomcat/webapps/tomgensoft.com/ROOT.war has finished in 1,120 ms
INFO main org.apache.catalina.startup.Catalina - Server startup in 1690 ms
ERROR ajp-nio-127.0.0.1-9631-exec-1 org.apache.catalina.core.ContainerBase.[Catalina].[tomgensoft.com].[/].[jsp] - Servlet.service() for servlet [jsp] in context with path [] threw exception [Unable to compile class for JSP: 

An error occurred at line: [42] in the generated java file: [/home/tomgenso/tomcat/work/Catalina/tomgensoft.com/ROOT/org/apache/jsp/home_jsp.java]
The method getDispatcherType() is undefined for the type HttpServletRequest

Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [42] in the generated java file: [/home/tomgenso/tomcat/work/Catalina/tomgensoft.com/ROOT/org/apache/jsp/home_jsp.java]
The method getDispatcherType() is undefined for the type HttpServletRequest

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:446)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
    at javax.servlet.http.HttpServlet.service

1 个答案:

答案 0 :(得分:1)

The method getDispatcherType() is undefined for the type HttpServletRequest您的日志表明您尚未在项目中添加servet.jarjsp.jar个文件。

我在您的日志中找不到UnsupportedClassVersion主要和次要版本错误,这些错误是因为版本冲突而导致您必须删除所有类文件然后再次构建项目。