Starting GWT dev mode within Eclipse causes Maven-managed resources to disappear

295 views
Skip to first unread message

Chris

unread,
Nov 16, 2010, 11:41:37 AM11/16/10
to Google Web Toolkit
Hi,

I'm working on upgrading our development environment from GWT 2.0.4 to
2.1 - this involved upgrading GPE to 1.4 as well as the gwt-maven-
plugin to 2.1. So far things have gone pretty smoothly except for one
nagging problem.

We have in our code tree a POM module that holds just shared resources
- images & CSS - that we make available to all GWT modules in our
codebase. This is managed by maven-assembly-plugin that unpacks a zip
file from the repo into our target/<GWT module> directory.

'mvn package' builds the directory structure correctly, and the
resultant war file can be deployed to an external Tomcat server with
no problem. But when I try to run the app in developer mode it seems
that GPE is deleting the maven-assemly-plugin managed resources prior
to startup.

I've tried just about everything I can think of, but can't for the
life of me figure out why this resources directory is being removed.
Has anyone ever had a problem like this?

Thanks in advance for any help.

- C

---
Google Plugin for Eclipse 3.5 1.4.0.v201010280047
Eclipse Platform 3.5.2.R35x_v20100210-0800-9hEiFzmFst-
TiEn9hNYgDWg1XN8ulH_JvCNGB
Google Web Toolkit SDK 2.1.0 2.1.0.v201010280047

Thomas Broyer

unread,
Nov 17, 2010, 6:03:46 AM11/17/10
to Google Web Toolkit


On 16 nov, 17:41, Chris <crehb...@gmail.com> wrote:
> Hi,
>
> I'm working on upgrading our development environment from GWT 2.0.4 to
> 2.1 - this involved upgrading GPE to 1.4 as well as the gwt-maven-
> plugin to 2.1.  So far things have gone pretty smoothly except for one
> nagging problem.
>
> We have in our code tree a POM module that holds just shared resources
> - images & CSS - that we make available to all GWT modules in our
> codebase.  This is managed by maven-assembly-plugin that unpacks a zip
> file from the repo into our target/<GWT module> directory.
>
> 'mvn package' builds the directory structure correctly, and the
> resultant war file can be deployed to an external Tomcat server with
> no problem.  But when I try to run the app in developer mode it seems
> that GPE is deleting the maven-assemly-plugin managed resources prior
> to startup.
>
> I've tried just about everything I can think of, but can't for the
> life of me figure out why this resources directory is being removed.
> Has anyone ever had a problem like this?

Well, if your resources are to be shared with GWT apps only, then how
about making a GWT module and putting them in the "public" path, so
the GWT compiler copies them to the output folder?
Or maybe those resources shouldn't be put into that folder to begin
with (it has always been the case that the <module-name> folder is
"GWT controlled" and always cleared by the GWT compiler before it
actually generates anything; it might have not always been the case
for DevMode but I don't see an issue with DevMode doing the same thing
as the compiler).

As a last resort, you can still use -noserver...

Chris

unread,
Nov 17, 2010, 9:45:34 AM11/17/10
to Google Web Toolkit


On Nov 17, 6:03 am, Thomas Broyer <t.bro...@gmail.com> wrote:

> Well, if your resources are to be shared with GWT apps only, then how
> about making a GWT module and putting them in the "public" path, so
> the GWT compiler copies them to the output folder?

Because we have 5 GWT apps using the same web resources and the point
was to avoid duplicating them 5 times in source control.

> Or maybe those resources shouldn't be put into that folder to begin
> with (it has always been the case that the <module-name> folder is
> "GWT controlled" and always cleared by the GWT compiler before it
> actually generates anything; it might have not always been the case
> for DevMode but I don't see an issue with DevMode doing the same thing
> as the compiler).

This isn't a GWT compiler issue. Nothing in this folder is generated
by the compiler - all that goes to a subdirectory of target/<module
name>. Plus, this didn't happen with previous versions of GPE. It
started after upgrading to 1.4.0.

> As a last resort, you can still use -noserver...

As a last resort I can simply copy the resources back into the folder
after GPE deletes them and before I load the app in my browser. It
just seems broken that GPE is deleting whatever it wants from the
build output directory when starting Jetty.

Thomas Broyer

unread,
Nov 30, 2010, 10:42:47 AM11/30/10
to Google Web Toolkit


On 17 nov, 15:45, Chris <crehb...@gmail.com> wrote:
> On Nov 17, 6:03 am, Thomas Broyer <t.bro...@gmail.com> wrote:
>
> > Well, if your resources are to be shared with GWT apps only, then how
> > about making a GWT module and putting them in the "public" path, so
> > the GWT compiler copies them to the output folder?
>
> Because we have 5 GWT apps using the same web resources and the point
> was to avoid duplicating them 5 times in source control.

Hence my proposal: use a GWT module with a "public" folder containing
the shared resources, and <inherits/> in all of your GWT apps. When
compiling a GWT app, everything from the public source will copied to
the app output folder (the subfolder in the "war" folder).
It might not be what you wanted though.

> > Or maybe those resources shouldn't be put into that folder to begin
> > with (it has always been the case that the <module-name> folder is
> > "GWT controlled" and always cleared by the GWT compiler before it
> > actually generates anything; it might have not always been the case
> > for DevMode but I don't see an issue with DevMode doing the same thing
> > as the compiler).
>
> This isn't a GWT compiler issue.  Nothing in this folder is generated
> by the compiler - all that goes to a subdirectory of target/<module
> name>.  Plus, this didn't happen with previous versions of GPE.  It
> started after upgrading to 1.4.0.

I just faced that very same issue, and a coworker too!
Eclipse 3.6 SR1
GPE 1.4.0
Maven projects using m2eclipse 0.10.2 with m2eclipse WTP integration.
Launching DevMode in -noserver, with src/main/webapp as the "war"
folder, it clears the whole src/main/webapp folder with the exception
of the WEB-INF/ folder, and it creates a subfolder where it puts the
*.nocache.js, hosted.html and clear.cache.gif.
The exact project layout is:
- myapp-shared: declares our GWT-RPC interfaces, depends on:
- gwt-servlet(scope=provided) for the RemoteService interface
- myapp-client: client-only code, depends on:
- myapp-shared(scope=provided) for the GWT-RPC interfaces
- myapp-shared:sources(scope=provided) so it has access to the Java
sources
- gwt-user(scope=provided)
This is a <packaging>war</packaging> project, the GWT app is
compiled through gwt-maven-plugin at the prepare-package stage (note
that because of the packaging and m2eclipse, it happens to be a WTP
project, but is not deployed by itself to any server; also, its src/
main/webapp is completely empty)
- myapp-server: server-only code, implements the GWT-RPC as
RemoteServiceServlet-s, depends on:
- myapp-shared, for the GWT-RPC interfaces
- gwt-servlet
- (several other maven modules)
This is a <packaging>jar</packaging> project
- myapp: this is the webapp, with <package>war</packaging>, depends
on
- myapp-client(type=war), will be used automatically as an overlay
by maven-war-plugin
- myapp-server
- guice-servlet
- (several other maven modules)
This is the WTP app that's being deployed (to a Jetty 7.x instance,
using the Jetty WTP plugin)

I'm launching the myapp-client project "as Web Application" and
selects myapp/src/main/webapp as the "war" folder (note, myapp, not
myapp-client; so that the *.nocache.js is created there, I refresh the
folder and WTP automatically publishes the files to the server)

Result: the src/main/webapp/myapp is correctly created with the
*.nocache.js file, but the rest of src/main/webapp is cleared out,
with the exception of src/main/webapp/WEB-INF.
it even messes up with SVN, as an "svn update" (outside Eclipse, I'm
not using subclipse) doesn't recover the missing files!

Thomas Broyer

unread,
Nov 30, 2010, 11:05:54 AM11/30/10
to Google Web Toolkit, Rajeev Dayal

On 30 nov, 16:42, Thomas Broyer <t.bro...@gmail.com> wrote:
> I just faced that very same issue, and a coworker too!

Forgot to precise: I'm on Win XP Pro SP3, my coworker is on Ubuntu
10.10; same configuration otherwise (Eclipse, m2eclipse, GPE)
It looks like this only happens if the server is started at the time I
launch the DevMode. If it's not, the src/main/webapp/myapp subfolder
is correctly created and nothing else is touched (i.e. my index.jsp,
myapp.css, etc. are still there in src/main/webapp).

I tried using myapp/target/myapp-0.0.1-SNAPSHOT as the "war" folder
for DevMode, but it doesn't work (m2eclipse WTP doesn't seem to
publish that folder directly, which is what I expected)

(some time passes)

...and now I try back with src/main/webapp as the "war" folder and it
works, with the server started !!! (tried using a full path, and then $
{resource_loc:myapp/src/main/webapp} in the launcher, both work,
without deleting anything).
And if I stop the server and launch the DevMode, I now have a
NullPointerException. I re-start the server, launch the DevMode:
exception still there!
Restarting Eclipse fixes it.

java.lang.RuntimeException:
com.google.gwt.dev.shell.remoteui.MessageTransport$RequestException:
java.lang.NullPointerException
at
com.google.gwt.dev.shell.remoteui.ViewerServiceClient.waitForResponseOrThrowUncheckedException(ViewerServiceClient.java:
351)
at
com.google.gwt.dev.shell.remoteui.ViewerServiceClient.initialize(ViewerServiceClient.java:
256)
at
com.google.gwt.dev.shell.remoteui.RemoteUI.moduleLoadComplete(RemoteUI.java:
133)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:798)
at com.google.gwt.dev.DevMode.main(DevMode.java:282)
Caused by: com.google.gwt.dev.shell.remoteui.MessageTransport
$RequestException: java.lang.NullPointerException
at
com.google.gwt.dev.shell.remoteui.MessageTransport.processFailure(MessageTransport.java:
376)
at
com.google.gwt.dev.shell.remoteui.MessageTransport.processMessage(MessageTransport.java:
401)
at com.google.gwt.dev.shell.remoteui.MessageTransport.access
$300(MessageTransport.java:44)
at com.google.gwt.dev.shell.remoteui.MessageTransport
$3.run(MessageTransport.java:314)
at java.lang.Thread.run(Thread.java:662)

I'm lost. I'm very new to Eclipse WTP (a couple of weeks) and not much
less to Maven (5 months), so maybe it's just me; but really, I don't
understand why it worked, then deleted everything, then now works
again...

Chris

unread,
Dec 22, 2010, 12:04:08 AM12/22/10
to Google Web Toolkit
On Nov 30, 11:05 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 30 nov, 16:42, Thomas Broyer <t.bro...@gmail.com> wrote:
>
> > I just faced that very same issue, and a coworker too!
>
> Forgot to precise: I'm on Win XP Pro SP3, my coworker is on Ubuntu
> 10.10; same configuration otherwise (Eclipse, m2eclipse, GPE)

<arbitrary snip>

> NullPointerException. I re-start the server, launch the DevMode:
> exception still there!
> Restarting Eclipse fixes it.

I'm now working with STS 2.5 (and ... some GWT) and Maven, and I'm
still running into the same problem. My original problem seems to be
more of a Maven/Eclipse interaction issue. Eclipse-clean !=
mvn:clean, and sometimes publishing an app to a Spring tc server in
Eclipse fails to copy over resources in target/<foo> that mvn:package
is supposed to copy over.

Lesson learned: be sure if you ever do a mvn:clean to do an Eclipse
project clean, and rebuild from Eclipse before doing a mvn:package
(and GWT compile, if stale). This should keep the two environments in
sync, and the right things should copy over.

Thomas Broyer

unread,
Dec 22, 2010, 5:33:13 AM12/22/10
to google-we...@googlegroups.com, Rajeev Dayal


On Tuesday, November 30, 2010 5:05:54 PM UTC+1, Thomas Broyer wrote:

I'm lost. I'm very new to Eclipse WTP (a couple of weeks) and not much
less to Maven (5 months), so maybe it's just me; but really, I don't
understand why it worked, then deleted everything, then now works
again...

I forgot to reply after solving my issue: it was obviously a PEBKAC, a misunderstanding on my part.

1. I changed my "client" project to no longer be a packaging=war so m2eclipse doesn't make it a WTP project (so when I start the DevMode it doesn't try to "publish" the project); I'm using the maven-assembly-plugin to package the complied GWT app to a ZIP, that I then use as an overlay in my "main" "war" project.

2. I'm now using WTP with the Jetty WTP plugin, i.e. I no longer use the embedded server in DevMode.

I can now follow the recommendations from the GPE FAQ about working with WTP and Maven projects.
Reply all
Reply to author
Forward
0 new messages