1

我正在努力解决一个奇怪的问题。我构建了一个 jsp Web 应用程序并在本地 tomcat(版本 6.0.36)上成功测试它。

我将应用程序部署在由 cpanel 11 管理的 web 主机上,该主机上运行着一个 tomcat 5.5.36。当我调用页面时,我会收到这样的错误:

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)

我找不到解决方案。

任何帮助表示赞赏。

4

2 回答 2

1

我认为问题在于依赖项和库。所以我将文件 jsp-api.jar 添加到 '/WEB-INF/lib' 并重新部署了 Web 应用程序,它运行良好。

于 2013-12-10T16:24:40.820 回答
0

尝试像实例化 LanguageTool

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

注意 <%!

于 2013-12-10T16:09:14.470 回答