Trying to get GWT app deployed in local Tomcat (using Eclipse)

115 views
Skip to first unread message

mmo

unread,
Aug 6, 2021, 11:05:55 AMAug 6
to GWT Users
I am (trying to) upgrade our GWT-based legacy application to use newer Hibernate, Spring and other library versions. After some (substantial) pull-ups this works mostly fine by now when deploying a fully generated and packaged .war file, but building this thing always takes forever and day (the infamous permutations and other steps...).

Since the Jetty that's built into the GWT plugin has issues with newer (multi-release) .jar files (see my different discussion) I had to switch deployment of the application to Tomcat (which is our target server anyway) also for development.

To speed up the development cycle I am thus trying to get this thing also to run as unpacked file using Eclipse's Tomcat "server bridge". This plugin deploys a web application to a temporary directory in the eclipse workspace and then starts Tomcat passing it the proper settings using VM options like: -Dcatalina.base="<workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0" -Dcatalina.home="C:\Program Files\Apache Software Foundation\Tomcat 8.5" -Dwtp.deploy="<workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps".

With that the application begins to start up, I get to the point where I login and get the initial index.html page but as soon as some GWT-generated Java-script has to be loaded things stall. As I had to learn the entire GWT generated code which - as I found out - gets compiled into directories named like C:\Users\<user>\AppData\Local\Temp\gwt-codeserver-8682038074388630768.tmp\<java_package_name>.WebWar\compile-1\war\<application_name> is *not* copied over or linked into the wtpwebapps directory.

I experimented a bit and if one creates a Junction (a kind of soft-link in Windows) in the wtpwebapps\<application>   directory pointing to that generated GWT code then  the application indeed starts loading the UI. However, at some point it invariably dies with a popup that it couldn't load the application from Super Dev Mode Server at http://localhost:9876.
So there are (at least) two things missing: the GWT code has to be hooked or copied into the generated server configuration and apparently there must also be a Dev Server available. At this point - since I don't understand this (Super) Dev Mode well enough - I decided to ask in this forum:

Has anyone got this working so that one can deploy a GWT application to a local Tomcat instance without first having to pack everything up and deploy as a .war file, so that one can essentially continue to run and debug as one used to using Jetty before using the maven goals gwt:run or gwt:debug?

Is that described or documented anywhere? Or would some kind soul mind to share his/her knowledge on how to get this working?
It doesn't have to be for Eclipse - IntelliJ would be ok as well. The point is that it should not require the lengthy build-package-deploy cycle because a cycle-time of >10 minutes is just unbearable for development.

Any suggestions welcome!

Frank Hossfeld

unread,
Aug 6, 2021, 3:15:35 PMAug 6
to GWT Users
For example: if you are using Maven, you can switch to Thomas Broyer's GWT Maven Plugin and create a Multi module project with separate modules for shared, client & server. This configuration will work with newer Java version (> 8) without any problems. Personally I have switch to Spring Boot on the server side.  server starts not more than 20s. 

Jens

unread,
Aug 8, 2021, 9:10:58 AMAug 8
to GWT Users
When you start SuperDevMode it will generate some minimalistic output that should be stored in the (exploded) war directory produced by your eclipse plugin. That output basically is a special index.html file for development (which loads resources from SuperDevMode server instead of your war) and all files that your GWT app has defined as public resources (by default directories named "public" on the root of your GWT module).

In order to place that output into your exploded war directory you would use the SuperDevMode parameter "-launcherDir", e.g. "-launcherDir <workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\<project-name>". For a learning experience you could also point launcherDir to some tmp directory first and see what it actually generates.

Given you are using Maven to launch things, you should look up how to start SuperDevMode with the GWT Maven plugin you are using. For example I know this one: https://tbroyer.github.io/gwt-maven-plugin/ which uses gwt:codeserver to start SuperDevMode and also lets you configure the launcherDir parameter.

When using SuperDevMode you do not need to GWT compile your app during the build of your *.war file/directory. SuperDevMode will do an initial, unoptimised compile and then will only compile incrementally any source changes. So maybe it is possible for you to skip GWT compilation while building the *.war directory to save some minutes.

-- J.

mmo schrieb am Freitag, 6. August 2021 um 17:05:55 UTC+2:

Vassilis Virvilis

unread,
Aug 8, 2021, 12:23:05 PMAug 8
to google-we...@googlegroups.com
So maybe it is possible for you to skip GWT compilation while building the *.war directory to save some minutes.

In my case this is a huge understatement. In superdevmode the compilation is nearly instant (1-2secs maybe less)  instead of 90sec of the full compile.

I don't know how it behaves in really big codebases that take several minutes to compile but I bet it would make a big difference.

So follow Jens' advice and try to setup superdevmode for development. For production you still need the final compilation step.

The other solution is to use code splitting http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html but a) I have never done it and b) certainly looks more invasing.
--
Vassilis Virvilis

mmo

unread,
Aug 20, 2021, 1:54:26 PMAug 20
to GWT Users
Thanks all! Meanwhile I got this starting up nicely from inside eclipse and - boy - this is really much faster!

Things that don't work, yet:
1. As far as I understand, the CodeServer should be started up automatically when starting the WebServer. There even is a flag in the GWT settings "Sync the CodeServer state with the WTP server. The WTP server start and stop will also start and stop the CodeServer".
That is not working for me. I always have to start the CodeServer separately. Strange enough it sometimes gets stopped, when I stop Tomcat, but it is never started, when I start Tomcat. So this feature seems to work only in one direction and then unreliably. But fortunately that's not such a big deal...
2. The CodeServer reliably appears with its URL in the "Development Mode"-view of the GWT plugin. However, the Tomcat server does so not always. Sometimes it appears, sometimes it does not. And right now it seems to refuse altogether. I have started and restarted it maybe 10 times now but its URL does not show up in that view. Any idea what setting or state could influence that?
The issue with the Web-server's URL not being listed there is, that I then can not right-click on the URL and choose to "Run with SDBG Chrome JS debugger". I would like to try that mode to see if that's working and helpful to debug client code.

Any advice on these topics?

Craig Mitchell

unread,
Aug 21, 2021, 9:05:07 AMAug 21
to GWT Users
1.  I've never seen an option to start the code server automatically, and I couldn't find the option you're talking about.  I always start the code server manually.  However, I not running Tomcat, I'm running Google App Engine Standard.
2.  I think you mean the CodeServer doesn't always show in the Development mode.  I've seen this happen too on my old Eclipse install, haven't seen it happen on the new 2021-06 install.  I just use a "Launch Chrome" launcher to start Chrome in debug, so I don't need it to show up.

mmo

unread,
Aug 23, 2021, 9:01:20 AMAug 23
to GWT Users
@Craig Mitchell

> I've never seen an option to start the code server automatically
Right-click on the mode --> GTW --> Settings --> GWT - Facet Settings: There is a checkbox under "Super Development Mode" labeled "Sync the CodeServer state with the WTP server. The WTP server start and stop will also start and stop the CodeServer".


> I think you mean the CodeServer doesn't always show in the Development mode.
No - as I wrote: the CodeServer shows up reliably in this view, but the Web-Server doesn't anymore. It used to, though, so I am puzzled why this is not working anymore.


> I just use a "Launch Chrome" launcher to start Chrome in debug, so I don't need it to show up.
These "Connect to Chrome" and "Launch Chrome" entries usually appear in the "Run As"/"Debug As"-context menu but often they don't. And once they disappeared, they don't show up anymore until the next Eclipse-restart. Very odd and annoying!  :-(

Craig Mitchell

unread,
Aug 24, 2021, 9:41:34 AMAug 24
to GWT Users
Interesting.  I don't have that setting:

screenshot.png

I'm using the standard Eclipse for Java Developers.  Not Eclipse for Enterprise Java.

mmo

unread,
Aug 24, 2021, 10:09:28 AMAug 24
to GWT Users
Really odd!
Here is how this looks on my side:
GWT-Facet-Settings.png
Reply all
Reply to author
Forward
0 new messages