2

嗨,我在 Eclipse 中使用嵌入式 Jetty 8.x 并收到此错误,同时使用 JSP 和 Servlet制作简单的Hello Web 应用程序。我在 Build Path 中缺少一些 jar 吗?

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

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_20\jre
Detected OS: Windows XP
parsing buildfile jar:file:/C:/Documents%20and%20Settings/ashish.s/NewEclipseJuno/JServer/WebContent/WEB-INF/lib/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Documents%20and%20Settings/ashish.s/NewEclipseJuno/JServer/WebContent/WEB-INF/lib/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml from a zip file
parsing buildfile jar:file:/C:/Documents%20and%20Settings/ashish.s/My%20Documents/Downloads/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Documents%20and%20Settings/ashish.s/My%20Documents/Downloads/ant-1.8.3.jar!/org/apache/tools/ant/antlib.xml from a zip file
Project base dir set to: C:\Documents and Settings\ashish.s\NewEclipseJuno\JServer
    [javac] warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
4

1 回答 1

0

我将继续在答案中提供更多细节,因为我也遇到了同样的问题(或足够接近),当运行形式 eclipse 并抛出时应用程序运行良好

java.lang.NoSuchMethodError: org.apache.jasper.compiler.JspUtil.expandClassPath(Ljava/util/List;)Ljava/util/List;

当导出并运行形成一个可运行的 jar 时。

解决方案(如上面的评论中所述)是在导出之前在 eclipse中添加jasper-compiler-*.jar和类路径(其中星号是版本号)。jasper-runtime-*.jar这些我分别在:jasper-compiler.jarjasper-runtime.jar

如果这些链接在阅读时已失效,那么 Google 搜索(或使用类似jar finder的服务)应该可以帮助您找到上述所需的 jar。

于 2013-05-15T09:09:50.927 回答