`

Unable to compile class for JSP

阅读更多
错误背景:
   项目原本运行在tomcat 6底下, 因某些原因需要升级到tomcat 7, 于是在部署完成tomcat 7.0.69之后,把原tomcat6底下的war包拷贝到tomcat 7底下的webapps目录下, 关闭tomcat 6, 启动tomcat 7, 启动过程无报错. 打开浏览器, 访问项目首页, 报无法解析jsp的错误. 以下为此次错误的解决之道:
STEP 1:
先来个错误日志(注意红色字体):
严重: Servlet.service() for servlet [jsp] in context with path [/我是项目名称] threw exception [Unable to compile class for JSP] with root cause
java.lang.IllegalArgumentException: Page directive: invalid value for import at org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:628)
at org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:609)
at org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:352)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:473)
at org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1773)
at org.apache.jasper.compiler.Parser.parse(Parser.java:135)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.ts.security.filter.RequestMethodFilter.doFilter(RequestMethodFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.ts.security.filter.SecurityFilter.doFilter(SecurityFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.ts.security.filter.RequestHeadFilter.doFilter(RequestHeadFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.travelsky.pss.abframe.filter.LogFilter.doFilter(LogFilter.java:94)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:619)
STEP 2:
看step 1的错误日志里面红色字体部分, 他们是这个错误日志的关键部分。第一步, 怀疑是不是tomcat 7并没有部署成功, 但它在没有部署项目上去的时候成功启动过, 所以怀疑不成立; 第二步, 怀疑jar包冲突, 项目的某些jar包, 如servlet-api.jar等于tomcat本身的jar冲突, 很快也排除此猜测, 因为tomcat它优先加载的是项目路径底下的jar, 找不到才加载其本身的jar包; 其实事情发展到现在已经无头绪了, 惟有继续BD搜索, 万幸, 找到一个有遇到同样问题的博主, 原来是页面的page import标签搞得鬼.. 先看原来的<%@ page import="java.lang.Exception;" %>, 看到Exception后面那个分号(;)了吗, 尼玛, 就是它, 删除它就好, tomcat 7不认它...
该怎么说呢, 理论上, 按照jsp编写规范, 这个分号的确是不该存在的, 可是程序员习惯写完一段代码就会顺手加上个分号... anyway, 坑爹就是了
分享到:
评论

相关推荐

    Unable to compile C++ source code(解决方案).md

    Unable to compile C++ source code(解决方案).md

    JSP访问时出错

    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [45] in the generated java file: [F:\apache-tomcat-8.0.14\work\Catalina\localhost\MoniWeb\org\apache\jsp...

    jsp中使用javabean的两点注意事项

    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 18 in the jsp file: /javabean.jsp TempBean cannot be resolved to a type ``` 这个错误表明JSP页面在尝试...

    java异常解决方案.docx

    * org.apache.jasper.JasperException: Unable to compile class for JSP: + 解决方案:检查 JSP 文件是否存在编译错误,尝试使用 JSP 的编译工具来检查问题。 * Servlet.service() for servlet jsp threw ...

    MinGW_w64 CC++安装包及说明.rar

    ERROR: Unable to compile MEX function: "未找到支持的编译器或 SDK。您可以安装免费提供的 MinGW-w64 C/C++ 编译器的解决方案 含有安装包,以及对应的安装说明,系统环境说明, 按照说明操作,即可保证正常运行

    mingwC/C++编译器

    wxgcc是一个开源的C/C++编辑软件,该软件轻型小巧,支持代码高亮,支持即时输入即时运行;是对著名的GCC开源编译工具的简单图形前端实现,通过wxpython语言开发而成。支持Windows XP,Windows 7 和 Linux 等多个平台...

    vbe 3.0 samples ,how to compile it? (1)

    how to compile the sample ?

    compile DCMTK for Windows with CMake

    OpenSSL support: set "DCMTK_WITH_OPENSSL" to "ON" and "WITH_OPENSSLINC" as well as "WITH_OPENSSLLIB" to the respective paths for OpenSSL include files and libraries. TIFF support: set "DCMTK_WITH_...

    fckeditor for jsp 的jar包

    这个是一个我修改过的fckeditor for jsp 的jar包的源代码,是fckeditor-2.3的,我修改了ConnectorServlet.java和SimpleUploaderServlet.java两个文件 我在这两个文件中都是加了一个静态变量encoding,private static...

    demo of msbuild to compile without vs

    一个简单的msbuild命令行使用demo,可直接编译项目,无论是解决方案(sln)还是csproj或者vbproj。msbuild真的非常好,有了它就不用打开笨重的visual studio了!如需实际使用,请执行填写项目相对路径(绝对路径也可以)...

    解决vue安装less报错Failed to compile with 1 errors的问题

    1、创建vue项目后安装less,执行 npm install less less-loader –save-dev 下载版本为:less-loader@6.1.0 , less@3.11.3,重启服务报错,报错信息如下: 2、报错原因 less 本版太高需要降低版本,执行代码 ...

    compile_compile

    compile

    How to compile Windows Server 2003-bO0daYbti5g.mkv

    How to compile Windows Server 2003-bO0daYbti5g.mkv windows server 2003操作系统源代码构建指南视频教程

    Java_for_the_Web_with_Servlets

    - **JSP Directives**: Directives provide instructions to the JSP engine about how to compile the page. Common directives include `page`, `include`, and `taglib`. - **JSP Actions**: JSP actions are ...

    moc.exe 解决moc过程中不支持处理enum包含#include头文件的语法。

    The moc process failed to compile "SRC:/..............." into "Src:/................................." command -------- path/to/path 问题2 tbb/tbb_profiling.:28: Parse error at "{

    python compile to source

    complied python code to source code.

    vlc compile for android

    This page is an introduction to the compilation of VLC for Android on Linux

    正则表达式测试器 for jsp

    "正则表达式测试器 for JSP" 是一个专门针对JSP开发的工具,它可以帮助开发者测试和调试正则表达式,提高开发效率。 在JSP中使用正则表达式,通常会结合Java的`java.util.regex`包,其中`Pattern`类用于编译正则...

    How to build compile server with virtualbox & samba

    How to build compile server with virtualbox & samba

    DeepSpeed System Optimizations Enable Training Deep Learning

    DeepSpeed: System Optimizations Enable Training Deep Learning Models with Over 100 Billion Parameters

Global site tag (gtag.js) - Google Analytics