13

I'm trying to get GWT Hosted mode working in Eclipse, à la this HOWTO. Servlets work fine, as does my GWT code, but all my JSPs fail because with errors such as the following:

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

This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse. I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.

Update: I'm no longer using Eclipse; I've switched (back!) to Intellij IDEA. So I can't honestly evaluate the answers you kind folks have posted. Once some voting action happens, or someone else reports success with one of these methods, I'll accept the appropriate answer. Thanks.

George Armhold
  • 30,824
  • 50
  • 153
  • 232
  • 1
    Hard to believe that nearly 7 years later, this is still an issue. So many SO answers for the problem of resolving JSTL URIs in general, but no solution specifically for GWT & Jetty, which, hidden somewhere deep, dark and not very obvious, have a weird dependency on old JSTLs that mess up any attempt to import newer JSTL dependencies. (Once the GWT is deployed to Tomcat, for instance, it all works.) My best hope at this stage is that someone like @BalusC will start doing GWT (if he doesn't already) and finally post a fix for this problem. :-P – Amos M. Carpenter Jan 13 '16 at 07:33

4 Answers4

1

I feel your pain. I've gone thru the same pain trying to get gwt, maven, and eclipse to work together.

I've been able to get it working with maven using the following pom.xml. This way you can use mvn gwt:run to run in hosted mode, but unfortunately, I could never get the mvn goal mvn gwt:eclipse for generating an eclipse launch run time config to work.

Here's the relevant snippets from my pom.xml. Note that I've found it easier to install gwt in separate location and point maven to use that instead of having mvn download gwt from repo. The "system" level scope in the mvn dependencies are what make this happen.

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

Another technique I've had success with is to use the eclipse google gwt plugin. Just use the wizard to create a new gwt project, make sure that you can run it from eclipse, then modify with your own code.

Upgradingdave
  • 12,916
  • 10
  • 62
  • 72
1

This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse. I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.

You apparently have the JSTL JAR file(s) in Tomcat/lib instead of WEB-INF/lib. You can fix this in at least three ways:

  1. Move/copy the JSTL JAR file(s) into WEB-INF/lib.
  2. Move/copy the JSTL JAR file(s) into Tomcat/lib of your development machine.
  3. Associate the right Tomcat server containing the JSTL JAR file(s) with web project in Eclipse. If not done yet, add the Tomcat server in Servers view. Then in project properties go to Java Build Path > Libraries > Add Library > Server Runtime > select the server in question.
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

Add the Jar files in eclipse project classpath. if you already had this file tomcat lib. This option will works for you. Second option is add jar in Web-Inf lib folder if you have eclipse web project.

Kamahire
  • 2,149
  • 3
  • 21
  • 50
1

Did you try to mark the "jsf-api.jar" as "exported" in your Java project ?
(as mentioned in this thread)

1.) Go into the java-project properties and mark the "jsf-api.jar" as exported. (project>properties>java build path>order and exports)
2.) Go into the advanced global tomcat preferences and add your project to the tomcat classpath (windows>preferences>tomcat>advanced>add projects to tomcat classpath)

Then, try again to run your webapp under eclipse.

Here is an article describing the same procedure/setup, not for JSF but Hudson (same problem though)

You can clearly see the two steps I mentioned above:


(source: hudson-ci.org)


(source: hudson-ci.org)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Hmm, why jsf? Did you mean to say jstl? I already have that as a dep in my maven config, so it should already be on the classpath. But I'll go ahead and try adding it manually to the build path. Thanks. – George Armhold May 15 '09 at 17:51
  • 1
    JSTL is more like it :) But the general principle described in this answer still stands. So, did it worked for your case ? – VonC May 15 '09 at 19:19
  • 1
    Nope. I already have jstl listed as a dependency via Maven; it appears under the Maven deps on the "Libraries" tab, and I do have "Maven Dependencies" checkmarked on the "Order and Export" tab. Still no joy. :-( – George Armhold May 19 '09 at 18:03
  • 1
    Sorry to hear, err... read that. If you do find a solution, do not forget to post it here ;) – VonC May 19 '09 at 18:12
  • Will do. Thanks for your help in any case. – George Armhold May 19 '09 at 18:14