Jetty 9.0绝对uri:http://java.sun.com/jsp/jstl/core 无法解决
我正在使用Jetty 9.0绝对uri:http://java.sun.com/jsp/jstl/core 无法解决,java,maven,jstl,embedded-jetty,Java,Maven,Jstl,Embedded Jetty,我正在使用 码头9嵌入 马文 Java 1.7 JSTL 当我在Eclipse中运行我的应用程序并浏览到包含JSTL标记的网页时,它工作正常。当我把它捆绑在一个可执行的jar中并从cmd提示符运行时,我得到 org.apache.jasper.JasperException:/jsp/pcReport.jsp(4,62)PWC6188:绝对uri:无法在web.xml或与此应用程序一起部署的jar文件中解析 我的依赖关系 <dependency> <
- 码头9嵌入
- 马文
- Java 1.7
- JSTL
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.0.6.v20130930</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
</dependency>
我是不是漏掉了什么明显的东西 JSTL有一个冲突/重复的工件 简化依赖关系
org.eclipse.jetty
码头
9.0.6.v20130930
org.eclipse.jetty
jetty网络应用程序
9.0.6.v20130930
您可以看到,我们没有使用JSTL工件和org.mortbay.jetty提供的jsp支持级别。Jetty提供了一个元依赖项,用于在与Jetty webapp工件相同的Jetty版本上拉入工件以支持JSP。我遇到了同样的问题,但最近没有找到答案。我不得不调试glassfish代码来解决它。我希望下面的解释能帮助其他人 关于依赖项,要使用JSP与glassfish一起运行,您需要:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jsp-jdt</artifactId>
<version>2.3.3</version>
</dependency>
它不会在JAR中加载TLD,因为
515 private void mapTldLocation(String resourcePath, TldInfo tldInfo,
516 boolean isLocal) {
517
518 String uri = tldInfo.getUri();
519 if (uri == null) {
520 return;
521 }
522
523 if ((isLocal
524 // Local tld files override the tlds in the jar files,
525 // unless it is in a system jar (except when using myfaces)
526 && mappings.get(uri) == null
527 && !systemUris.contains(uri)
528 && (!systemUrisJsf.contains(uri) || useMyFaces)
529 ) ||
530 (!isLocal
531 // Jars are scanned bottom up, so jars in WEB-INF override
532 // thos in the system (except when using myfaces)
533 && (mappings.get(uri) == null
534 || systemUris.contains(uri)
535 || (systemUrisJsf.contains(uri) && !useMyFaces)
536 )
537 )
538 ) {
...
如果url是“”,并且存储在本地jar中,它就不可能加载TLD。要使其不是本地的,应用程序必须由其父级包含JSTL jar的类加载器加载。简而言之,您需要修改代码以初始化WebAppContext
,如下所示:
...
WebAppContext webapp = new WebAppContext();
// classURLs may contains URL to WEB-INF/classes or WEB-INF/lib/additional_jar of you web app
URLClassLoader classLoader = new URLClassLoader(classURLs.toArray(new URL[classURLs.size()]),
Thread.currentThread().getContextClassLoader());
webapp.setClassLoader(classLoader);
...
ContextHandlerCollection contextCollection = new ContextHandlerCollection();
contextCollection.addHandler(webapp);
...
Server server = new Server(threadPool);
server.setHandler(contextCollection);
server.start();
...
如果这没有帮助,我想了解如何在应用程序中嵌入Jetty。您应该使用:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<version>${jetty-version}</version>
</dependency>
org.eclipse.jetty
ApacheJSTL
${jetty版本}
而不是:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
javax.servlet
jstl
1.2
我也遇到了同样的问题,但在我做了那个更改后,它被吹了。可能是希望的重复,您已经查看了这个链接,尝试了那个链接,它确实清理了依赖项,现在它在eclipse中也不工作,我在那里得到了相同的错误:(jetty jsp不适用于9.4.3)。v20170317@SergeiRodionov用于码头9.4.x(还有,升级,9.4.40现在已经过时)是的,谢谢你的提示。我将应用升级到9.4.35.v20201120,但会在某个时候尝试9.4.40。考虑到所有问题,决定不使用taglib。这是最简单的修复方法,因为我只使用了
c:url
。
515 private void mapTldLocation(String resourcePath, TldInfo tldInfo,
516 boolean isLocal) {
517
518 String uri = tldInfo.getUri();
519 if (uri == null) {
520 return;
521 }
522
523 if ((isLocal
524 // Local tld files override the tlds in the jar files,
525 // unless it is in a system jar (except when using myfaces)
526 && mappings.get(uri) == null
527 && !systemUris.contains(uri)
528 && (!systemUrisJsf.contains(uri) || useMyFaces)
529 ) ||
530 (!isLocal
531 // Jars are scanned bottom up, so jars in WEB-INF override
532 // thos in the system (except when using myfaces)
533 && (mappings.get(uri) == null
534 || systemUris.contains(uri)
535 || (systemUrisJsf.contains(uri) && !useMyFaces)
536 )
537 )
538 ) {
...
...
WebAppContext webapp = new WebAppContext();
// classURLs may contains URL to WEB-INF/classes or WEB-INF/lib/additional_jar of you web app
URLClassLoader classLoader = new URLClassLoader(classURLs.toArray(new URL[classURLs.size()]),
Thread.currentThread().getContextClassLoader());
webapp.setClassLoader(classLoader);
...
ContextHandlerCollection contextCollection = new ContextHandlerCollection();
contextCollection.addHandler(webapp);
...
Server server = new Server(threadPool);
server.setHandler(contextCollection);
server.start();
...
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>