简体   繁体   English

Jetty 9.0 绝对uri:http://java.sun.com/jsp/jstl/core 无法解析

[英]Jetty 9.0 The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved

I'm using我正在使用

  • Jetty 9 embedded. Jetty 9 嵌入。
  • Maven马文
  • Java 1.7爪哇 1.7
  • JSTL JSTL

When I run my app in Eclipse and browse to my webpage which contains JSTL tags it works fine.当我在 Eclipse 中运行我的应用程序并浏览到包含 JSTL 标签的网页时,它工作正常。 When I bundle it in an executable jar and run from cmd prompt I get当我将它捆绑在一个可执行的 jar 中并从 cmd 提示符运行时,我得到

org.apache.jasper.JasperException: /jsp/pcReport.jsp(4,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 org.apache.jasper.JasperException:/jsp/pcReport.jsp(4,62) PWC6188:绝对 uri: http : //java.sun.com/jsp/jstl/core无法在 web.xml 或使用此应用程序部署的 jar 文件

My Dependencies我的依赖

    <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>

My Plugins我的插件

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.pricemon.server.Main</mainClass>
                        <classpathPrefix>webapp/WEB-INF/lib/</classpathPrefix>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>etc/</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptors>
                    <descriptor>assembly.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

web.xml网页.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

I've got my JSTL jar under WEB-INF/lib which is on my Manifest classpath我在 WEB-INF/lib 下有我的 JSTL jar,它在我的清单类路径上

I just cant figure out why this works when run under eclipse but wont work when run from executable jar.我只是想不通为什么这在 eclipse 下运行时有效,但在从可执行 jar 运行时不起作用。 I've also tried manually adding to classpath when launching with no effect我也试过在启动时手动添加到类路径没有效果

java -classpath ./jstl-1.2.jar -jar app.jar

Am I missing something obvious!?我错过了一些明显的东西!?

I've run into the same problem but found no answer recently.我遇到了同样的问题,但最近没有找到答案。 I had to debug glassfish code to solve it.我不得不调试 glassfish 代码来解决它。 I hope the following explanation can help others.我希望下面的解释可以帮助其他人。

About dependencies, to run with JSP with glassfish you will need:关于依赖项,要使用带有 glassfish 的 JSP 运行,您需要:

<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>

The reason why your embedded Jetty could not load core even if you have a jar of JSLT 1.2 (propably javax.servlet.jsp.jstl.jar from glassfish) is because of TldScanner class including in glassfish jars for JSP.即使您有一个 JSLT 1.2 jar(可能是来自 glassfish 的javax.servlet.jsp.jstl.jar ),您的嵌入式 Jetty 也无法加载核心的原因是因为TldScanner类包含在用于 JSP 的 glassfish 罐中。 To be clear this class has some static like:要清楚这个类有一些静态,如:

197    static {
198        systemUrisJsf.add("http://java.sun.com/jsf/core");
199        systemUrisJsf.add("http://java.sun.com/jsf/html");
200        systemUris.add("http://java.sun.com/jsp/jstl/core");
201    }

And it would not load TLD in the JAR because of the block in它不会在 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           ) {
            ...

There is no way it's gonna load your TLD if the url is " http://java.sun.com/jsp/jstl/core " and it is stored in a local jar.如果 url 是“ http://java.sun.com/jsp/jstl/core ”并且它存储在本地 jar 中,则它无法加载您的 TLD。 To make it NOT LOCAL, the application must be loaded by a class loader whose parent contains the JSTL jar.要使其非本地,应用程序必须由其父级包含 JSTL jar 的类加载器加载。 In short, you need to modify code to initialize WebAppContext as something like:简而言之,您需要修改代码以将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();
  ...

If this does not help, I'd like to learn how you embed Jetty in you application.如果这没有帮助,我想了解您如何在应用程序中嵌入 Jetty。

You have a conflicting / duplicate artifact for JSTL.您有一个用于 JSTL 的冲突/重复工件。

Simplify your dependencies.简化您的依赖项。

<dependencies>
  <!-- Meta Dependency - adds JSP support to the same version of Jetty -->
  <dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-jsp</artifactId>
    <version>9.0.6.v20130930</version>
  </dependency>
  <!-- NOT NEEDED
  <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>
  <!-- NOT NEEDED
  <dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jsp-2.1-glassfish</artifactId>
    <version>2.1.v20100127</version>
 </dependency> -->
</dependency>

You can see that we don't use the JSTL artifact and org.mortbay.jetty provided jsp support level.您可以看到我们没有使用 JSTL 工件和 org.mortbay.jetty 提供的 jsp 支持级别。
Jetty has provided a meta dependency to pull in the artifacts to support JSP on the same version of Jetty as your jetty-webapp artifact. Jetty 提供了一个元依赖项来拉入工件以支持与您的 jetty-webapp 工件相同版本的 Jetty 上的 JSP。

You should use:你应该使用:

    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>apache-jstl</artifactId>
        <version>${jetty-version}</version>
    </dependency>

Instead of:而不是:

 <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

I also meet same problem but it was blown after I make that change.我也遇到了同样的问题,但在我做出改变后它就被炸毁了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 绝对URI:无法解析http://java.sun.com/jsp/jstl/core - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved 绝对URI:[http://java.sun.com/jsp/jstl/core]无法解决错误 - The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved error Apache Tomcat 10.0.0-M1 使用 JSP Absolute uri http://java.sun.com/jsp/jstl/core 无法解析 - Apache Tomcat 10.0.0-M1 using JSP Absolute uri http://java.sun.com/jsp/jstl/core cannot be resolved 绝对的uri:http://java.sun.com/jsp/jstl/core无法在web.xml或使用此应用程序部署的jar文件中解析 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this app 在Eclipse WTP中从Tomcat 7迁移到8:绝对uri:http://java.sun.com/jstl/core无法解析 - Migrating from Tomcat 7 to 8 in Eclipse WTP: The absolute uri: http://java.sun.com/jstl/core cannot be resolved “绝对 uri:http://java.sun.com/jstl/core 无法解析” - “The absolute uri: http://java.sun.com/jstl/core cannot be resolved” JSTL错误:绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或与此应用程序一起部署的jar文件中解析 - JSTL error: 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 JSTL:绝对uri:无法在web.xml或与此应用程序一起部署的jar文件中解析http://java.sun.com/jsp/jstl/core - JSTL: 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 错误HTTP状态500-绝对URI:无法在web.xml或jar文件中解析http://java.sun.com/jsp/jstl/core - Error HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files 绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或tomcat中与此应用程序错误一起部署的jar文件中解决 - Absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application error in tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM