mergewebxml question

6 views
Skip to first unread message

Jeff Bowman

unread,
Sep 4, 2008, 6:39:44 PM9/4/08
to gwt-maven
I'm reading the book GWT In Action and trying to setup the
ServerStatus RPC example. I have created my web.xml to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>ServerStatusServlet</servlet-name>
<servlet-class>org.gwtbook.server.ServerServiceImpl</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>ServerStatusServlet</servlet-name>
<url-pattern>/org.gwtbook.ServerStatusApp/server-status</url-
pattern>
</servlet-mapping>
</web-app>

however after mvn package, the web.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>ServerStatusServlet</servlet-name>
<servlet-class>org.gwtbook.server.ServerServiceImpl</servlet-
class>
</servlet>
<!--inserted by gwt-maven-->
<servlet>
<servlet-name>org.gwtbook.server.ServerServiceImpl/
org.gwtbook.ServerStatusApp/server-status</servlet-name>
<servlet-class>org.gwtbook.server.ServerServiceImpl</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>ServerStatusServlet</servlet-name>
<url-pattern>/org.gwtbook.ServerStatusApp/server-status</url-
pattern>
</servlet-mapping>
<!--inserted by gwt-maven-->
<servlet-mapping>
<servlet-name>org.gwtbook.server.ServerServiceImpl/
org.gwtbook.ServerStatusApp/server-status</servlet-name>
<url-pattern>/org.gwtbook.ServerStatusApp/server-status</url-
pattern>
</servlet-mapping>
</web-app>

you'll notice the additional <servlet> and <servlet-mapping> stanzas
which "duplicate" what I had originally (ie, same class-name and url-
pattern - just a different name).

When I try to deploy this war to jetty or tomcat5.5, it doesn't work -
I get 404 errors when I try to go to org.gwtbook.ServerStatusApp/
ServerStatusApp.html which is the path I "know" since it is the one I
typed in.

Is this intended? Perhaps I didn't specify my web.xml correctly for
use with GWT? (finding examples of other web.xml files that work is
like splitting atoms.) Any guidance would be appreciated.

Jeff

Charlie Collins

unread,
Sep 5, 2008, 9:50:02 AM9/5/08
to gwt-maven
GWT-Maven uses a naming convention based on whats in your GWT module
file. It inspects every servlet element there, and during the war
phase, creates servlet and servlet-mapping entries in your
distrubution web.xml (not the source web.xml, it doesn't touch that -
that's the idea).

Here is a full Maven example (using the snapshot branch build of GWT-
Maven) with a source web.xml and client code that calls RPC:
http://gwt-maven.googlecode.com/svn/branches/cc_20080814_automaticrefactor/simplesample/.

Also, for the record, GWT in "Practice" has some web.xml examples that
work with Maven, get that one, I hear it's fantastic ;).

Mirko Nasato

unread,
Sep 5, 2008, 11:02:05 AM9/5/08
to gwt-...@googlegroups.com
I've never actually used mergewebxml before, we've always added all servlets manually to our web.xml so far.

I've given it a try now, but it fails saying it can't find my Module.gwt.xml file. I think the problem is that the Module.gwt.xml is in a jar dependency, not in the current project, but the plugin is only looking in the current project.  Sounds possible?

Thanks

Mirko


2008/9/5 Charlie Collins <charlie...@gmail.com>

Charlie Collins

unread,
Sep 5, 2008, 4:27:13 PM9/5/08
to gwt-maven
@module in jar dependency - that shouldn't matter, I don't think, so
long as the module is at the root of the classpath "/" if it's
anywhere else it won't be found "/something".

GwtWebInfProcessor from the support jar handles this. If this can be
made smarter, that would be good -
http://code.google.com/p/gwt-maven/source/browse/trunk/maven-googlewebtoolkit-support/src/main/java/com/totsp/mavenplugin/gwt/support/GwtWebInfProcessor.java.




On Sep 5, 11:02 am, "Mirko Nasato" <mirko.nas...@gmail.com> wrote:
> I've never actually used mergewebxml before, we've always added all servlets
> manually to our web.xml so far.
>
> I've given it a try now, but it fails saying it can't find my Module.gwt.xml
> file. I think the problem is that the Module.gwt.xml is in a jar dependency,
> not in the current project, but the plugin is only looking in the current
> project.  Sounds possible?
>
> Thanks
>
> Mirko
>
> 2008/9/5 Charlie Collins <charlie.coll...@gmail.com>
>
>
>
> > GWT-Maven uses a naming convention based on whats in your GWT module
> > file.  It inspects every servlet element there, and during the war
> > phase, creates servlet and servlet-mapping entries in your
> > distrubution web.xml (not the source web.xml, it doesn't touch that -
> > that's the idea).
>
> > Here is a full Maven example (using the snapshot branch build of GWT-
> > Maven) with a source web.xml and client code that calls RPC:
>
> >http://gwt-maven.googlecode.com/svn/branches/cc_20080814_automaticref...
> > .

Mirko Nasato

unread,
Sep 8, 2008, 1:08:48 PM9/8/08
to gwt-...@googlegroups.com
2008/9/5 Charlie Collins <charlie...@gmail.com>

@module in jar dependency - that shouldn't matter, I don't think, so
long as the module is at the root of the classpath "/"  if it's
anywhere else it won't be found "/something".

I'm not clear. For a GWT module "com.example.Example" the path to the XML descriptor would be "/com/example/Example.gwt.xml", not in the root.

Anyway MergeWebXmlMojo only seems to look for a .gwt.xml file in src/main/java and src/main/resources, not in jar dependencies.

I'll have a more in depth look when I can and open an issue if appropriate.

Cheers

Mirko


Charlie Collins

unread,
Sep 8, 2008, 3:18:28 PM9/8/08
to gwt-maven
Ok, yes, I meant at the root of the project so I should have said "/
com/example" rather than "/com/example/somewhere/else" - it uses the
module NAME as an indication of where to look. That may be too
primitive, but that's what it does (I believe - haven't looked at it
in a while).

On Sep 8, 1:08 pm, "Mirko Nasato" <mirko.nas...@gmail.com> wrote:
> 2008/9/5 Charlie Collins <charlie.coll...@gmail.com>
>
>
>
> > @module in jar dependency - that shouldn't matter, I don't think, so
> > long as the module is at the root of the classpath "/"  if it's
> > anywhere else it won't be found "/something".
>
> I'm not clear. For a GWT module "com.example.Example" the path to the XML
> descriptor would be "/com/example/Example.gwt.xml", not in the root.
>
> Anyway MergeWebXmlMojo only seems to look for a .gwt.xml file in
> src/main/java and src/main/resources, not in jar dependencies.
>
> I'll have a more in depth look when I can and open an issue if appropriate.
>
> Cheers
>
> Mirko
>
> > GwtWebInfProcessor from the support jar handles this. If this can be
> > made smarter, that would be good -
>
> >http://code.google.com/p/gwt-maven/source/browse/trunk/maven-googlewe...
> > .

Jeff Bowman

unread,
Sep 8, 2008, 5:57:11 PM9/8/08
to gwt-maven
Ok, so I changed my web.xml file to only this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
</web-app>

and then ran mvn package. I then deployed the resulting war file in
both jetty 5.1 and tomcat 5.5. I had to "fix" jetty by telling it not
to validate the web.xml file (it wasn't finding the web-app node and
this seems to be a known issue in jetty 5.1) and after turning off
(for the moment - it's a local dev box and I'm just testing anyway)
security in tomcat so I could get to the vm statistics (number of
threads, memory, etc), it all just worked. I had also removed the -
SNAPSHOT from the version in my pom beforehand.

Everything seems to be going just fine now.

I also spent some time reading the "in practice" book which was
helpful, but didn't explain (or I missed it) how the mergewebxml
actually merges (ie, what it matches on). I like only having to
mention things in my module descriptor and the maven plugin just makes
it work. Very nice indeed.

Thanks for the replies, I'll continue reading and trying more
complicated examples.

Jeff

On Sep 5, 8:50 am, Charlie Collins <charlie.coll...@gmail.com> wrote:
> GWT-Maven uses a naming convention based on whats in your GWT module
> file.  It inspects every servlet element there, and during the war
> phase, creates servlet and servlet-mapping entries in your
> distrubution web.xml (not the source web.xml, it doesn't touch that -
> that's the idea).
>
> Here is a full Maven example (using the snapshot branch build of GWT-
> Maven) with a source web.xml and client code that calls RPC:http://gwt-maven.googlecode.com/svn/branches/cc_20080814_automaticref....

Charlie Collins

unread,
Sep 8, 2008, 7:06:53 PM9/8/08
to gwt-maven
Sorry if the in practice thing doesn't elaborate on it enough. I
don't even remember at this point what all ended up in the final
version, and what got cut, but a lot of the Maven talk got yanked
because we were over space (and that was considered a low priority by
all the reviewed it and such). I will look around at my copies and
see if I can find a section that explains it (and if so I will add it
to the docs, if not I will create one - at some point, it's on my
list).

The general idea is that any existing JEE servlets in your source
web.xml get added to the hosted mode web.xml automatically *AND*
conversely, any gwt servlet entries in your module descriptor get
added to your deploy time (not source) web.xml file too. It "merges"
your servlets, and gwt service servlets (and tries not to overwrite
anything that exists by the same name).

It has a few issues, some people want to have an adjustable path to
the service servlets, it's not very robust, and the like - but when
using the default setup and it works, its very handy. The workaround
if you have issues, is just don't use that goal and setup your hosted
mode and deploy time web.xmls the old fashioned way, manually.
Reply all
Reply to author
Forward
0 new messages