Hi Matt. You really don't need to do any URLRewriting. The key here
is that the artifacts produced by GWT are relative. This means that
you shouldn't care if you have the package name while running in
hosted mode, but your war can have it all w/o the package name. If
you really do want to run in hosted mode w/o the package name, then I
would recommend using the jetty maven plugin and use Hosted mode in
the noserver configuration. Here is a quick walk through...
The secret in the sauce is using the jetty maven plugin's semi-new
overlay feature. This allows you to merge your webapp directory with
the GWT output. Here I am using jetty with HSQL and my module name is
com.example.MyApp:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
<dependencies>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>${commonsDbcpVersion}</
version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>${commonsPoolVersion}</
version>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldbVersion}</version>
</dependency>
</dependencies>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
<!--- LOOKY HERE ... THIS IS THE KEY -
USING OVERLAYS -->
<baseResource
implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>${basedir}/src/main/
webapp,${basedir}/target/myapp/com.example.MyApp</resourcesAsCSV>
</baseResource>
</webAppConfig>
<!-- My jetty config - I think you can
figure this part out yourself -->
<jettyConfig>${basedir}/src/test/jetty/
hsql/jetty.xml</jettyConfig>
<scanIntervalSeconds>5</
scanIntervalSeconds>
<scanTargets>
<scanTarget>${basedir}/src/main/
resources</scanTarget>
<scanTarget>${basedir}/src/main/
webapp</scanTarget>
<scanTarget>${basedir}/target/myapp/
com.example.MyApp</scanTarget>
</scanTargets>
<systemProperties>
<!-- Just some HSQL config stuff - just
ignore for now -->
<systemProperty>
<name>dbtest</name>
<value>${basedir}/src/test/db/
testdb</value>
</systemProperty>
<systemProperty>
<name>hibernate_driver</name>
<value>org.hsqldb.jdbcDriver</
value>
</systemProperty>
<systemProperty>
<name>hibernate_dialect</name>
<value>com.example.myapp.util.CustomHSQLDialect</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
The next part is telling the war packager to get rid of the package
name, so when you deploy, you don't have that nasty module name:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${project.build.directory}/$
{project.build.finalName}/com.example.MyApp</webappDirectory>
</configuration>
</plugin>
Now you can run mvn jetty:run and then run GWT in --noserver mode.
You will notice that you can startup GWT with
http://localhost:8080/index.html.
You can put your index.html as your launch pad for your application.
Now, if you want to run it all in hosted mode, including Spring,
Hibernate, etc under Tomcat... I can post that configuration as its
much more involved. However, you will have to live with the module
name when running it in full hosted mode, but your deployment/war will
not have the module name (due to the maven war config posted above).
Just be sure you are not hard-coding URLs in your code and that
everything is relative.
I hope this helps. If you have issues...post the results and I will
see if I can fill in the blanks.