org.apache.jasper.JasperException: Unable to compile class for JSP

I made a project on Netbeans on my local machine with JDK 1.7 (32-bit) On running the application (using tomcat 8.0 server on netbeans), it works perfectly on http://localhost:8080/WebApplication1.

I copied the war file from the dist directly and transferred it to my Windows VM server with tomcat 8.0 and jdk 1.8 installed (64-bit). Then the war file was uploaded through tomcat's manager web app.

Note: 'localhost:8080/' and 'localhost:8080/manager' ran without any issue.

However, when I go and run the application (http://localhost:8080/WebApplication1) - it throws the following errors.

org.apache.jasper.JasperException: Unable to compile class for JSP
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:579)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.lang.IllegalArgumentException: Page directive: invalid value for import
    org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:610)
    org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:593)
    org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:344)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:458)
    org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1782)
    org.apache.jasper.compiler.Parser.parse(Parser.java:136)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
    org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:117)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

The <%page import %> I have in my JSPs are 'java.util.*' and 2 java classes which are part of my project. Rest my java classes import some 'java.' packages

Additional info:

  • I have set 'Path' environment variable to 'C:\Program Files\Java\jdk 1.8\bin'
  • I have tried including 'org.apache.jasper.jar' to my project (& war) too
  • jdbc4.jar is also imported in library

What seems to be the problem? I am unable to make out the source of the problem. Is it because of 32-bit vs 64-bit? or jdk 1.7 vs 1.8? or missing environment variable? or problem in tomcat configuration? something else?

share | improve this question
 
 
Could it be an issue with Tomcat's 'compilerSourceVM' setting? By default Tomcat will compile JSPs using Java 1.6. tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html –   dnault  Dec 2 '14 at 20:35

1 Answer

up vote 3 down vote accepted

Problem was in my import statement, which included:

Original code

 <%@page contentType="text/html" pageEncoding="UTF-8" language="java" import="java.util.*,mypackage.one.*,mypackage.two.*;"%>

The issue was the ; at the end of the import statement!

Corrected code:

 <%@page contentType="text/html" pageEncoding="UTF-8" language="java" import="java.util.*,mypackage.one.*,mypackage.two.*"%>

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值