Trouble running application on Tomcat but runs fine through Eclipse

25 views
Skip to first unread message

laredotornado

unread,
Nov 28, 2011, 10:30:21 AM11/28/11
to Google Web Toolkit
Hi,

I'm using GWT 2.4. When I run my module through Eclipse Indigo (by
right clicking on my project and selecting Run As -> Web Application),
my application runs fine, but when I copy my WAR file to my locally
running Tomcat server and visit the URL

http://localhost:8080/cme-productplus-web/productplus.html

I get the alert dialog error

GWT module 'productplus' may need to be (re)compiled

Any ideas how to get more info on this error? I don't know if this
makes a difference, but in Eclipse, the URL I visit is

http://127.0.0.1:8888/productplus.html?gwt.codesvr=127.0.0.1:9997

Anyway, thanks for any hints, - Dave

Thomas Broyer

unread,
Nov 28, 2011, 10:39:36 AM11/28/11
to google-we...@googlegroups.com
Did you run the GWT compiler before packaging your WAR?

If you did, then delete the *.nocache.js generated by the DevMode (Run As -> Web Application) and re-GWT-compile your project.

The thing is: when running DevMode, if there's no *.nocache.js or it seems to be stale, a new one is generated, containing only the minimum code required to run in DevMode. You need to GWT-compile just before you package your WAR, make sure the *.nocache.js is a "full" one (and of course that the rest of the compiled code, the *.cache.* files, are up-to-date too).

laredotornado

unread,
Nov 28, 2011, 11:53:41 AM11/28/11
to Google Web Toolkit
Ah, brilliant.  That did it.
Here's a follow up.  I have my project set up Maven-style (using Maven
3.0.3).  What can I do to my configuration such that running "mvn
clean install" will build a functioning WAR each time?  My only idea
is to add an antrun plugin directive to delete the src/main/webapp/
*nocache.js files that are generated, but maybe there's something I
should be doing in the configuration.  Configuration is ...
<!-- GWT Maven Plugin --> <plugin> <groupId>org.codehaus.mojo</
groupId> <artifactId>gwt-maven-plugin</artifactId> <version>$
{gwtVersion}</version> <executions> <execution>
<goals> <goal>clean</goal> <goal>compile</goal>
<goal>test</goal> </goals> </execution> </executions>
<!-- Plugin configuration. There are many available options, see gwt-
maven-plugin  documentation at codehaus.org -->
<configuration> <runTarget>index.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.myco.clearing.product.client.Messages</
i18nMessagesBundle> </configuration> </plugin>
Thanks, - Dave

Thomas Broyer

unread,
Nov 28, 2011, 12:28:12 PM11/28/11
to google-we...@googlegroups.com
You shouldn't EVER run DevMode from your src/main/webapp. "src" is for the *sources* in Maven, nothing should be generated in there that you wouldn't want to commit/push to your SCM.
It's also a bad idea because you wouldn't have your dependencies in the WEB-INF/lib, so a few things will break (loading resources for instance, the way JPA, JDO, or Spring DI do it).

laredotornado

unread,
Nov 28, 2011, 1:59:09 PM11/28/11
to Google Web Toolkit
Are you sure these instructions are safe? One of the steps recommends

"On the Web Module page, set the Content directory to src/main/webapp
and click Finish"

so wouldn't that cause things to be generated in src/main/webapp when
you said it shouldn't? - Dave

Thomas Broyer

unread,
Nov 28, 2011, 3:34:42 PM11/28/11
to google-we...@googlegroups.com
Later on, it says to "uncheck the box Launch and deploy from this directory" which later allows to "select the location of the WAR directory that WTP is publishing to".

Or you can use the "If you're not able to use Eclipse for Java EE" path (and point your Tomcat to serve the webapp directly from your target/<final-name>).

I personally prefer (and use) that latter approach, but I've used the former one too with no problem (besides WTP's own isses ;-) ).
Reply all
Reply to author
Forward
0 new messages