使用OpenJDK运行Jetty嵌入式将抛出PWC6188

时间:2019-01-16 20:25:35

标签: java jersey jetty jstl embedded-jetty

我正在运行一个使用Jersey 1.19.4和JSTL 1.2的Web应用程序。

这是嵌入式码头项目的Maven依赖树。


    [INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.4.14.v20181114:compile
    [INFO] |  +- org.eclipse.jetty:jetty-xml:jar:9.4.14.v20181114:compile
    [INFO] |  \- org.eclipse.jetty:jetty-servlet:jar:9.4.14.v20181114:compile
    [INFO] |     \- org.eclipse.jetty:jetty-security:jar:9.4.14.v20181114:compile
    [INFO] |        \- org.eclipse.jetty:jetty-server:jar:9.4.14.v20181114:compile
    [INFO] +- org.eclipse.jetty:jetty-servlets:jar:9.4.14.v20181114:compile
    [INFO] |  +- org.eclipse.jetty:jetty-continuation:jar:9.4.14.v20181114:compile
    [INFO] |  +- org.eclipse.jetty:jetty-http:jar:9.4.14.v20181114:compile
    [INFO] |  +- org.eclipse.jetty:jetty-util:jar:9.4.14.v20181114:compile
    [INFO] |  \- org.eclipse.jetty:jetty-io:jar:9.4.14.v20181114:compile
    [INFO] +- org.eclipse.jetty:jetty-jsp:jar:9.2.26.v20180806:compile
    [INFO] |  +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1.M0:compile
    [INFO] |  +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
    [INFO] |  +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:compile
    [INFO] |  +- org.glassfish.web:javax.servlet.jsp:jar:2.3.2:compile
    [INFO] |  +- org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:jar:1.2.0.v201105211821:compile
    [INFO] |  +- org.glassfish.web:javax.servlet.jsp.jstl:jar:1.2.2:compile
    [INFO] |  +- org.glassfish:javax.el:jar:3.0.0:compile
    [INFO] |  \- org.eclipse.jetty.orbit:org.eclipse.jdt.core:jar:3.8.2.v20130121:compile
    [INFO] +- org.eclipse.jetty.toolchain:jetty-jsp-jdt:jar:2.3.3:compile
    [INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
    [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
    [INFO] +- commons-io:commons-io:jar:2.4:compile
    [INFO] +- commons-logging:commons-logging:jar:1.1.3:compile
    [INFO] +- log4j:log4j:jar:1.2.17:compile
    [INFO] \- log4j:apache-log4j-extras:jar:1.2.17:compile

错误:



    com.sun.jersey.api.container.ContainerException:
          org.apache.jasper.JasperException: /test.jsp(2,62) 
             PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core 
             cannot be resolved in either web.xml or the jar files deployed with this application

3 个答案:

答案 0 :(得分:0)

org.eclipse.jetty:jetty-jsp:jar:9.2.26.v20180806:compile

org.eclipse.jetty.*中工件的所有版本都应为相同版本。

也将上述一项也升级到9.4.14.v20181114

答案 1 :(得分:0)

非常感谢您的即时答复。

我正在使用GlassFish JSP实现和可用的最稳定版本“ org.eclipse.jetty:jetty-jsp:jar:9.2.26.v20180806:compile”。 https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-jsp

我正在使用OpenJDK 11 + 28在Eclipse IDE 2018-09中运行此嵌入式码头程序。


    java -version
    openjdk version "11" 2018-09-25
    OpenJDK Runtime Environment 18.9 (build 11+28)
    OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

使用Oracle JDK时也存在相同的问题。


    java -version
    java version "11.0.2" 2018-10-16 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.2+7-LTS)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+7-LTS, mixed mode)

当我使用Oracle JDK 1.8时,该应用程序成功运行

为了在JDK 11中工作,我必须在JSP页面中更改TLD URI以充分了解名称,然后在WEB-INF目录下复制tld,并在web.xml文件中明确引用。

JSP (无错误),

<%@ taglib prefix="c" uri="jstl-core" %>
<%@ taglib prefix="fn" uri="jstl-functions" %>

web.xml

  <jsp-config>
    <taglib>
      <taglib-uri>jstl-core</taglib-uri>
      <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>jstl-functions</taglib-uri>
      <taglib-location>/WEB-INF/fn.tld</taglib-location>
    </taglib>
  </jsp-config>

早期的JSP (有错误)

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

我不确定我在这里做的正确,如果有人有正确的解决方案,请告诉我。

答案 2 :(得分:0)

非常感谢Joakim,将其更改为apache-jsp后效果很好。我已经恢复使用JSP中的URI。

+- org.eclipse.jetty:jetty-webapp:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-xml:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty:jetty-servlet:jar:9.4.12.v20180830:compile
|     \- org.eclipse.jetty:jetty-security:jar:9.4.12.v20180830:compile
|        \- org.eclipse.jetty:jetty-server:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-servlets:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-continuation:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-http:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-util:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty:jetty-io:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-annotations:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-plus:jar:9.4.12.v20180830:compile
|  |  \- org.eclipse.jetty:jetty-jndi:jar:9.4.12.v20180830:compile
|  +- javax.annotation:javax.annotation-api:jar:1.2:compile
|  +- org.ow2.asm:asm:jar:6.2:compile
|  \- org.ow2.asm:asm-commons:jar:6.2:compile
|     +- org.ow2.asm:asm-tree:jar:6.2:compile
|     \- org.ow2.asm:asm-analysis:jar:6.2:compile
+- org.eclipse.jetty:apache-jsp:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1:compile
|  +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
|  \- org.mortbay.jasper:apache-jsp:jar:8.5.24.2:compile
|     +- org.mortbay.jasper:apache-el:jar:8.5.24.2:compile
|     \- org.eclipse.jdt:ecj:jar:3.12.3:compile
+- jstl:jstl:jar:1.2:compile
+- org.slf4j:slf4j-api:jar:1.7.25:compile
+- org.slf4j:slf4j-log4j12:jar:1.7.25:compile

这是我对Jetty Embedded项目的新依赖关系树,

//org.eclipse.jetty.webapp.WebAppContext
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*jstl.*\\.jar$");

org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration","org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration","org.eclipse.jetty.annotations.AnnotationConfiguration");

我还在嵌入式码头服务器代码中添加了以下内容,

{{1}}

请告诉我上述方法是否需要更改。