您好,我在 Eclipse 中使用嵌入式 Jetty 8.x 并遇到此错误,同时使用 JSP 和 Servlet 制作简单的 Hello Web 应用程序。我是否在构建路径中遗漏了一些 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
最佳答案
我将继续并在答案中提供更多细节,因为我也遇到了同样的问题(或足够接近),应用程序在从 eclipse 运行并抛出时运行良好
java.lang.NoSuchMethodError: org.apache.jasper.compiler.JspUtil.expandClassPath(Ljava/util/List;)Ljava/util/List;
当从可运行的 jar 中导出并运行时。
解决方案(如上面评论中所述)是将 jasper-compiler-*.jar
和 jasper-runtime-*.jar
添加到类路径中导出前的 eclipse(星号是版本号)。这些我分别在:jasper-compiler.jar找到和 jasper-runtime.jar
如果这些链接在阅读时已失效,那么 Google 搜索(或使用类似 jar finder 的服务)应该可以帮助您找到上述所需的 jar。
关于java - 面对 java.lang.NoSuchMethodError : Jetty + Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12419243/