Howto configure GWT-Maven with external Tomcat and Eclipse

121 views
Skip to first unread message

Johan Lundberg

unread,
Feb 6, 2008, 5:47:52 AM2/6/08
to Google Web Toolkit
I have written a post about "Howto configure GWT-Maven with external
Tomcat and Eclipse". Figuring this out was very time consuming so I
decided to share my experience and hopefully make it easier for
someone that wants to create this development setup. You can read it
here: http://joepoe.blogspot.com/

Also, if you know of any easier way to accomplish the same thing,
please let me know.

VBR
johan

Charlie Collins

unread,
Feb 6, 2008, 7:10:24 AM2/6/08
to Google Web Toolkit
Very comprehensive post there Johan, good work and nice write up.

I would note though that I do think you went through a few extra
steps. GWT-Maven can copy a SOURCE web.xml file (and context.xml file
for Tomcat) over to the hosted mode Tomcat locations for you,
automatically. You can use the built in Tomcat with GWT-Maven to do
absolutely anything that an external Tomcat can do. GWT-Maven adds the
deps, sets up the web.xml and context.xml, etc. Also, GWT-Maven keeps
the same config when it builds a WAR, so you know that your hosted
mode stuff is the same as your WAR once you deploy.

If you have src/main/webapp/WEB-INF/web.xml in your project, GWT-Maven
will use it and *merge* it with the embedded Tomcat ROOT.xml (same for
context.xml - and you can change the paths with config params, the
defaults that are normally used are the Maven conventions).

The reasons to keep with the embedded Tomcat are several, sharing
modules with others (if you use noserver, you pass on all the
configuration outside of your build, you have to provide instructions
and deps, etc), and testing (GWTTestCase tests won't work with
noserver in hosted mode).

That said though, GWT-Maven also includes support for noserver too.
If you add a the "noServer" configuration parameter, and then set the
runTarget to your external URL, it will not launch the embedded
Tomcat, and instead will hit the external one.

If you feel like we need to add more documentation, or do a better job
of explaining stuff on the GWT-Maven site (or you have any other GWT-
Maven issues/suggestions) please ping me. I am trying to clean all of
that up and improve it.

Johan Lundberg

unread,
Feb 6, 2008, 8:15:55 AM2/6/08
to Google Web Toolkit
On 6 Feb, 13:10, Charlie Collins <charlie.coll...@gmail.com> wrote:
> Very comprehensive post there Johan, good work and nice write up.
>
Thank you.

> I would note though that I do think you went through a few extra
> steps. GWT-Maven can copy a SOURCE web.xml file (and context.xml file
> for Tomcat) over to the hosted mode Tomcat locations for you,
> automatically.

I struggled with this but could not get it working. Maybe I am not the
tomcat wizard that I have to be to know the inner workings of that
container.

> You can use the built in Tomcat with GWT-Maven to do
> absolutely anything that an external Tomcat can do.

This was new for me. My impression from other posts is that I have to
use the external Tomcat when reading from the server file system or
doing other 'advanced' things. I use iBatis and when I wanted to load
the ibatis config file I tried to get the servlet context for file
access. In the built-in tomcat I got null but the external tomcat gave
me the real context. Maybe I didn't configure the built-in Tomcat as I
should have done.

> GWT-Maven adds the
> deps, sets up the web.xml and context.xml, etc. Also, GWT-Maven keeps
> the same config when it builds a WAR, so you know that your hosted
> mode stuff is the same as your WAR once you deploy.
>
> If you have src/main/webapp/WEB-INF/web.xml in your project, GWT-Maven
> will use it and *merge* it with the embedded Tomcat ROOT.xml (same for
> context.xml - and you can change the paths with config params, the
> defaults that are normally used are the Maven conventions).
>
I have an empty web.xml which gwt-maven modifies but I never
understood how-to deal with the context, which might explain my
comment above.

> The reasons to keep with the embedded Tomcat are several, sharing
> modules with others (if you use noserver, you pass on all the
> configuration outside of your build, you have to provide instructions
> and deps, etc), and testing (GWTTestCase tests won't work with
> noserver in hosted mode).
>
I can tell you, I would have preferred using the embedded cat in this
setup.

> That said though, GWT-Maven also includes support for noserver too.
> If you add a the "noServer" configuration parameter, and then set the
> runTarget to your external URL, it will not launch the embedded
> Tomcat, and instead will hit the external one.
>
This feature is what I use in my pom.xml

> If you feel like we need to add more documentation, or do a better job
> of explaining stuff on the GWT-Maven site (or you have any other GWT-
> Maven issues/suggestions) please ping me. I am trying to clean all of
> that up and improve it.
>

The issue with my context configuration might be more gwt related, but
could most probably be solved by gwt-maven, right?

Well, I tried to tie together gwt-maven with eclipse and this is
something I would like to have without all the manual configuration
needed.

I would like to get this setup easier to achieve so maybe we can start
by getting rid of the external Tomcat and I'll update my blog post
accordingly.

VBR
johan

Eric Ponthiaux

unread,
Feb 6, 2008, 2:38:36 PM2/6/08
to Google-We...@googlegroups.com
Take a looks at http://gwtforge.com

hope it will help .

Kind regards .

Eric Ponthiaux

unread,
Feb 6, 2008, 2:39:18 PM2/6/08
to Google-We...@googlegroups.com
Thanks joe .

----- Original Message -----
From: "Johan Lundberg" <joe...@gmail.com>
To: "Google Web Toolkit" <Google-We...@googlegroups.com>

Johan Lundberg

unread,
Feb 6, 2008, 3:27:52 PM2/6/08
to Google Web Toolkit
Thank's Eric

I'll have a look at it.

VBR johan

Charlie Collins

unread,
Feb 6, 2008, 8:58:45 PM2/6/08
to Google Web Toolkit
GwtForge has no bearing on this conversation. Eric, does it? Can
GwtForge configure the embedded Tomcat instance, or help with running
the shell at all, noserver or not? Looks to me like all it does is
run the GWT compiler?

I only ask because you seem to have a habit of not reading the posts
you are replying to and simply stating the name and link of your own
personal project, rather than actually trying to help anyone, and it
gets old fast. (And, it seems to happen here, and on other forums, I
can cite about 10 separate examples, including this gem:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/6fef00f60eaa895c
- you really should cut it out, and I am trying to be nice and
constructive here, if you have something worthwhile to say, then by
all means say it, but if you just want to add your GwtForge link again
without reading the posts, then that is noise that is inappropriate
for this forum. Also, like you did last time we had this conversation,
go ahead and five me one star, looking forward to it ;).)

Charlie Collins

unread,
Feb 6, 2008, 9:00:16 PM2/6/08
to Google Web Toolkit
Johan, please feel free to send me an email if you have specific
questions. Maybe we can work on the sample together and get better
docs out there for GWT-Maven (making it nice for the people is the
goal after all ;)).

Johan Lundberg

unread,
Feb 7, 2008, 3:47:10 AM2/7/08
to Google Web Toolkit
I'd be happy to.
/johan

Ed Zwart

unread,
Jul 29, 2008, 12:08:13 PM7/29/08
to Google-We...@googlegroups.com
I'm just teaching myself Maven, which has its suggested layout and
supports alternatives. If I'm going to use Maven with my GWT project,
what's a good reason for abandoning GWT's suggested layout for
Maven's? Mainly I'm wondering if there are any costs of NOT using
GWT's suggested layout. (The benefits of using the Maven layout seem
clear enough -- I think!)

Thanks

e.

Matt Bishop

unread,
Jul 30, 2008, 10:03:41 AM7/30/08
to Google Web Toolkit
The Maven layout is preferable to the GWT layout IMO because it is
easier to use the other maven plugins on your project as well. My
maven apps that have GWT look like this:

src/main/gwt/ [public/server/client]
src/main/java (server-side libraries go here)
src/main/webapp (WEB-INF, other things go in here)

I configure my gwt plugin to find it's src in the src/main/gwt dir and
let the maven compiler plugin build the rest--java dir, build WAR
file, etc.

One thing I do not do is let the gwt maven plugin "merge" web.xml. It
doesn't like to use the paths I specify in gwt.xml but instead builds
up it's own paths. I add the servlet/servlet-mapping elements into
web.xml directly.

From this POM I can run gwt in hosted mode, I can run it in debug mode
and attach to it from my IDE as well as benefit from the wonderful
edit-reload lifecycle that GWT offers. I don't have to shut down
Hosted mode and rebuild that often this way.

Ed Zwart

unread,
Jul 31, 2008, 11:24:06 AM7/31/08
to Google Web Toolkit
Thanks Matt, I suspected as much, but I thought I'd ask on here, in
case any hardcore gwt'rs had a reason why their layout was better...

e.

olivier nouguier

unread,
Jul 31, 2008, 1:03:17 PM7/31/08
to Google-We...@googlegroups.com
Hi all

On Wed, Jul 30, 2008 at 4:03 PM, Matt Bishop <ma...@re-entry.ca> wrote:

The Maven layout is preferable to the GWT layout IMO because it is
easier to use the other maven plugins on your project as well. My
maven apps that have GWT look like this:

src/main/gwt/ [public/server/client]
I've used to do so, but finally we found this "optimization" more confusing :-/

src/main/java (server-side libraries go here)
src/main/webapp (WEB-INF, other things go in here)

I configure my gwt plugin to find it's src in the src/main/gwt dir and
let the maven compiler plugin build the rest--java dir, build WAR
file, etc.

One thing I do not do is let the gwt maven plugin "merge" web.xml. It
doesn't like to use the paths I specify in gwt.xml but instead builds
up it's own paths. I add the servlet/servlet-mapping elements into
web.xml directly.

When using a DI container (spring/guice) to dispatch the GWT request it no more  a problem !
 

From this POM I can run gwt in hosted mode, I can run it in debug mode
and attach to it from my IDE as well as benefit from the wonderful
edit-reload lifecycle that GWT offers. I don't have to shut down
Hosted mode and rebuild that often this way.

And what about wtp ? To make it work, my GWT mojo output are directed in a target/gwt-wtp which is added to the wtp wb-ressources .
I didn't find  a way to let maven manged this wtp addon :(

Also, you'll need package the sources of the project used by GWT compiler.

In general I agree that the maven layout fill very well, but sometime it a little cryptic to refresh some resources special mention to WTP.







--
"Quand le dernier arbre sera abattu, la dernière rivière asséchée, le dernier poisson péché, l'homme va s'apercevoir que l'argent n'est pas comestible"
- proverbe indien Cri
Reply all
Reply to author
Forward
0 new messages