我正在开发一个可以在Tomcat上成功部署的Web项目。现在我想在jetty中运行该项目。我创建了一个启动jetty的main方法。 jetty从端口8080开始,但显示error 500 JSP support not configured
所以我添加 jetty jsp 依赖项。然后抛出异常org.apache.jasper.JasperException: /common/taglibs.jsp(2,80) PWC6188: The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
(其中 taglib.jsp 包含不同的标签库)
然后当我在tomcat上运行它时会启动一些信息INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
当我开始时,它会给java.lang.NoSuchMethodError: org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(Ljava/lang/String;Ljava/lang/Class;Ljavax/servlet/jsp/PageContext;Lorg/apache/jasper/runtime/ProtectedFunctionMapper;Z)Ljava/lang/Object;
maven依赖
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jettyjsp.version}</version>
</dependency>
编辑1:
当我将<scope>provided</scope>
添加到依赖关系时,tomcat成功启动,但是当启动jetty时,它仍会提供以下堆栈跟踪
org.apache.jasper.JasperException: /common/taglibs.jsp(2,80) PWC6188: The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:89)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:375)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:169)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:429)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:234)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:499)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:579)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1649)
at org.apache.jasper.compiler.Parser.parse(Parser.java:182)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:156)
at org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:391)
at org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:428)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:571)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1649)
at org.apache.jasper.compiler.Parser.parse(Parser.java:182)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:140)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:204)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:431)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:476)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.eclipse.jetty.servlet.JspPropertyGroupServlet.service(JspPropertyGroupServlet.java:127)
答案 0 :(得分:2)
你面临着不同的问题。
您不能将jetty声明为依赖项,而是将其作为插件声明,如果您真的想将其作为服务器运行。
Jetty只需将这些行添加到您的pom.xml中即可:
<build>
<!-- MORE CONF HERE -->
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.0.v20130308</version>
</plugin>
<!-- Maybe more plugins here -->
</plugins>
<!-- EVEN MORE Build CONF HERE -->
</build>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.3.v20120416</version>
</plugin>
它们是许多可用的插件配置,但基本配置就足够了。
您的java.lang.NoSuchMethodError意味着您正在尝试运行您的应用程序,在版本A中使用嵌入式Servlet API,而在另一个版本(例如版本B)中运行它的服务器。这些版本不兼容。
您应该仅在提供的情况下声明Servlet API,而不是默认范围(编译),并确保您的服务器支持它。