Xerces and GWT Compiler

298 views
Skip to first unread message

Brian Chapman

unread,
Dec 8, 2011, 4:38:26 PM12/8/11
to Google Web Toolkit
I have a maven based project that uses the jts library by
vividsolutions. jts uses an old version of xerces which is included in
the project's war (in WEB-INF/lib/).

When I go and compile this project, I get an error from the GWT
compiler. If I exclude it during compilation (using <scope>runtime</
scope> in the pom) everything compiles fine. Perhaps I don't
understand how the GWT compiler works under the hood, but I'd expect
the compile time class path to be independent from the actual
compiler's class path.

The problem comes when I want to use the hosted mode in eclipse. When
the project starts up with hosted mode, GWT uses the old xerces lib
provided by jts and throws an error. If I start the app in hosted mode
outside of eclipse using maven (mvn gwt:run) I don't get the error.
The problem with this is that I now don't have access to the debugging
capabilities of eclipse and it is a bit clunky.

There appears to be some class loading issue with the GPE that is
using the war's class path for the GWT compiler rather than have the
GWT compiler have its own class path that is unaffected by what is
used by the project.

Has anyone seen this and do you know of any workarounds?

Thanks,
Brian

Thomas Broyer

unread,
Dec 9, 2011, 4:19:22 AM12/9/11
to google-we...@googlegroups.com


On Thursday, December 8, 2011 10:38:26 PM UTC+1, Brian Chapman wrote:
I have a maven based project that uses the jts library by
vividsolutions. jts uses an old version of xerces which is included in
the project's war (in WEB-INF/lib/).

When I go and compile this project, I get an error from the GWT
compiler. If I exclude it during compilation (using <scope>runtime</
scope> in the pom) everything compiles fine. Perhaps I don't
understand how the GWT compiler works under the hood, but I'd expect
the compile time class path to be independent from the actual
compiler's class path.

It's not. GWT (compiler and DevMode) load files from the classpath. See http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html
 

The problem comes when I want to use the hosted mode in eclipse. When
the project starts up with hosted mode, GWT uses the old xerces lib
provided by jts and throws an error. If I start the app in hosted mode
outside of eclipse using maven (mvn gwt:run) I don't get the error.
The problem with this is that I now don't have access to the debugging
capabilities of eclipse and it is a bit clunky.


You can simply edit the classpath of the launcher in Eclipse, to move gwt-dev.jar before jts.
...or actually, you should simply remove jts from the classpath of the DevMode, as server-side code is loaded from the war's WEB-INF/classes and WEB-INF/lib (as expected for a webapp).
But GWT has no mean to know whether a particular dependency is client-side or server-side (or both), and neither Eclipse or Maven have a mean to configure it either, so by default the Google Plugin for Eclipse includes everything in the DevMode's classpath (and you can later manually fine-tune it).

This is also one reason that makes me believe the proper way of developping with Maven is to have separate modules for client-side and server-side code (and possibly another one for shared code). It makes initial configuration a bit less straightforward: you have to run your server-side webapp in a servlet container (jetty, tomcat, whatever) and launch the DevMode in -noserver mode, and you need an additional step at build-time to copy the compiled GWT/JS code to the webapp.
 

There appears to be some class loading issue with the GPE that is
using the war's class path for the GWT compiler rather than have the
GWT compiler have its own class path that is unaffected by what is
used by the project.

Has anyone seen this and do you know of any workarounds?


Workaround is to either have separate projects (hence separate classpaths) for client-side and server-side code; or fine-tune the DevMode classpath in Eclipse. 

Brian Chapman

unread,
Dec 9, 2011, 11:32:30 AM12/9/11
to google-we...@googlegroups.com
Wow thanks! I've been banging my head against a wall on this issue for far to long now ...
Reply all
Reply to author
Forward
0 new messages