【问题标题】:GWT/Eclipse/Jetty issue: Jasper can't resolve tag librariesGWT/Eclipse/Jetty 问题:Jasper 无法解析标记库
【发布时间】:2010-10-25 09:45:59
【问题描述】:

我正在尝试让 GWT 托管模式在 Eclipse 中工作,就像 this HOWTO。 Servlet 可以正常工作,我的 GWT 代码也是如此,但我的所有 JSP 都失败了,因为出现以下错误:

[WARN] /view/lniExecutiveSummary.htm
org.apache.jasper.JasperException: /WEB-INF/jsp/lni/lniExecutiveSummary.jsp(1,1) The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    [ trimmed ]

这个 webapp 在 Tomcat 5x 下部署时运行良好;在 Eclipse 中运行时,我似乎无法让它解析标记库。 我是 Eclipse 的新手,让它与 GWT+Maven 所需的所有移动部件一起工作让我大吃一惊。

更新:我不再使用 Eclipse;我已经切换(返回!)到 Intellij IDEA。所以我不能诚实地评估你们这些好心人发布的答案。一旦发生某些投票操作,或者其他人使用其中一种方法报告成功,我将接受适当的答案。谢谢。

【问题讨论】:

  • 很难相信近 7 年后,这仍然是一个问题。解决 JSTL URI 的问题有很多 SO 答案,但没有专门针对 GWT 和 Jetty 的解决方案,它们隐藏在某个深、暗且不太明显的地方,对旧 JSTL 有一种奇怪的依赖,这会扰乱任何导入更新的尝试JSTL 依赖项。 (例如,一旦将 GWT 部署到 Tomcat,一切正常。)在这个阶段,我最大的希望是像 @BalusC 这样的人将开始执行 GWT(如果他还没有)并最终发布此问题的修复程序。 :-P

标签: eclipse gwt jetty jstl taglib


【解决方案1】:

您是否尝试在 Java 项目中将“jsf-api.jar”标记为“已导出”?
(如this thread中提到的)

1.) 进入 java-project 属性并将“jsf-api.jar”标记为已导出。 (project>properties>java build path>order and exports)
2.)进入高级全局tomcat首选项并将您的项目添加到 tomcat 类路径 (windows>preferences>tomcat>advanced>add projects to tomcat classpath)

然后,再次尝试在 eclipse 下运行您的 webapp。

这里是 an article 描述相同的过程/设置,不是针对 JSF,而是针对 Hudson(虽然同样的问题)

你可以清楚地看到我上面提到的两个步骤:


(来源:hudson-ci.org


(来源:hudson-ci.org

【讨论】:

  • 嗯,为什么是 jsf?你的意思是说jstl吗?我已经将它作为我的 maven 配置中的一个 dep,所以它应该已经在类路径上。但我会继续尝试将其手动添加到构建路径中。谢谢。
  • JSTL 更像它:) 但是这个答案中描述的一般原则仍然有效。那么,它对你的情况有用吗?
  • 不。我已经通过 Maven 将 jstl 列为依赖项;它出现在“库”选项卡上的 Maven 部门下,并且我确实在“订购和导出”选项卡上选中了“Maven 依赖项”。仍然没有喜悦。 :-(
  • 很抱歉,错误...请阅读。如果您确实找到了解决方案,请不要忘记在此处发布;)
  • 会的。无论如何感谢您的帮助。
【解决方案2】:

在 Eclipse 项目类路径中添加 Jar 文件。如果你已经有了这个文件 tomcat lib.此选项适用于您。如果您有 Eclipse Web 项目,第二个选项是在 Web-Inf lib 文件夹中添加 jar。

【讨论】:

    【解决方案3】:

    这个 webapp 在 Tomcat 5x 下部署时可以正常工作;在 Eclipse 中运行时,我似乎无法让它解析标记库。我是 Eclipse 新手,让它与 GWT+Maven 所需的所有移动部件一起工作让我大吃一惊。

    您显然在Tomcat/lib 而不是WEB-INF/lib 中拥有JSTL JAR 文件。您至少可以通过三种方式解决此问题:

    1. 将 JSTL JAR 文件移动/复制到 WEB-INF/lib
    2. 将 JSTL JAR 文件移动/复制到您的开发机器的 Tomcat/lib
    3. 将包含 JSTL JAR 文件的正确 Tomcat 服务器与 Eclipse 中的 Web 项目相关联。如果尚未完成,请在 Servers 视图中添加 Tomcat 服务器。然后在项目属性中转到 Java Build Path > Libraries > Add Library > Server Runtime > 选择服务器问题。

    【讨论】:

      【解决方案4】:

      我感觉到你的痛苦。我经历了同样的痛苦,试图让 gwt、maven 和 eclipse 一起工作。

      我已经能够使用以下 pom.xml 使其与 maven 一起使用。这样您就可以使用 mvn gwt:run 在托管模式下运行,但不幸的是,我永远无法让 mvn 目标 mvn gwt:eclipse 生成 eclipse 启动运行时配置工作。

      这是我的 pom.xml 中的相关 sn-ps。请注意,我发现在单独的位置安装 gwt 并指向 maven 使用它而不是让 mvn 从 repo 下载 gwt 更容易。 mvn 依赖项中的“系统”级别范围是导致这种情况发生的原因。

        <properties>
      
            <!-- convenience to define GWT version in one place -->
            <gwt.version>1.7.1</gwt.version>
            <google.webtoolkit.home>${env.GWT_HOME}</google.webtoolkit.home>
      
            <!--  tell the compiler we can use 1.5 -->
            <maven.compiler.source>1.6</maven.compiler.source>
            <maven.compiler.target>1.6</maven.compiler.target>      
      
        </properties>
      
        <dependencies>
      
            <!--  GWT dependencies (from central repo) -->
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.version}</version>
            <scope>system</scope>
            <systemPath>${env.GWT_HOME}/gwt-servlet.jar</systemPath>
          </dependency>
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
            <scope>system</scope>
            <systemPath>${env.GWT_HOME}/gwt-user.jar</systemPath>
          </dependency>
      
          ... other dependencies...
        </dependencies>
      
        <build>
          <outputDirectory>war/WEB-INF/classes</outputDirectory>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>gwt-maven-plugin</artifactId>
              <version>1.1</version>
              <executions>
                <execution>
                  <goals>
                    <goal>compile</goal>
                    <goal>generateAsync</goal>
                    <goal>test</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                  <runTarget>com.gwt.example/Application.html</runTarget>
                  <extraJvmArgs>-Xmx512m</extraJvmArgs>
              </configuration>
            </plugin>
            <!--
                If you want to use the target/web.xml file mergewebxml produces,
                tell the war plugin to use it.
                Also, exclude what you want from the final artifact here.
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-war-plugin</artifactId>
                      <configuration>
                          <webXml>target/web.xml</webXml>
                          <warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
                      </configuration>
                  </plugin>
                  -->
      
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                  <source>${maven.compiler.source}</source>
                  <target>${maven.compiler.target}</target>
                  <module>com.gwt.example</module>
                </configuration>
            </plugin>
          </plugins>
      
          ...rest of pom.xml...
      

      我成功使用的另一种技术是使用 eclipse google gwt plugin。只需使用向导创建一个新的 gwt 项目,确保您可以从 eclipse 运行它,然后使用您自己的代码进行修改。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-04
        • 2011-12-15
        • 1970-01-01
        • 1970-01-01
        • 2015-05-08
        • 1970-01-01
        • 2012-08-31
        • 2016-03-21
        相关资源
        最近更新 更多