Deploy error Unable to compile class for JSP

4.3k views Asked by At

I'm struggling with a weird problem. I built a jsp web app and test it on a local tomcat (ver 6.0.36) successfully.

I deployed the app on a web host -managed by cpanel 11- which a tomcat 5.5.36 is running on it. When I call a page I'll get such a error:

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


An error occurred at line: 6 in the generated java file
Only a type can be imported. com.raya.web.language.LanguageTool resolves to a package

An error occurred at line: 4 in the jsp file: /index.jsp
LanguageTool cannot be resolved to a type
1: <%@ page import="com.raya.web.language.LanguageTool" %>
2: <%@ page contentType="text/html;charset=UTF-8" language="java" %>
3: <%
4:     LanguageTool languageTool = new LanguageTool("fa");
5: %>
6: <!DOCTYPE HTML>
7: <html>


An error occurred at line: 4 in the jsp file: /index.jsp
LanguageTool cannot be resolved to a type
1: <%@ page import="com.raya.web.language.LanguageTool" %>
2: <%@ page contentType="text/html;charset=UTF-8" language="java" %>
3: <%
4:     LanguageTool languageTool = new LanguageTool("fa");
5: %>
6: <!DOCTYPE HTML>
7: <html>


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:307)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

I can't find a solution.

Any help is appreciated.

2

There are 2 answers

0
Syd On

Try to instantiate LanguageTool like

<%! LanguageTool languageTool = new LanguageTool("fa");%>

Be noticed <%!

0
Babak Behzadi On

I think the problem is because of dependencies and libraries. So I added file jsp-api.jar to '/WEB-INF/lib' and redeployed the web app and it's working well.