Archive for March, 2009

HOWTO: Remove GWT package from url when using gwt-maven

Friday, March 13th, 2009

Seriously, who wants a url like /my.long.package.name.Application/Application.html

To remedy this use the following steps:

  1. Make the webapp directory the same as the output for your gwt code.
    ...
    <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-war-plugin</artifactId>
    	<configuration>
    		<webappDirectory>${project.build.directory}/${project.build.finalName}/my.long.package.name.Application	</webappDirectory>
    	</configuration>
    </plugin>
    ...
  2. Ensure that your rpc servlets don’t have the package as a prefix.
    ...
    <plugin>
    	<groupId>com.totsp.gwt</groupId>
    	<artifactId>maven-googlewebtoolkit2-plugin</artifactId>
    	...
    	<configuration>
    		...
    		<webXmlServletPathAsIs>true</webXmlServletPathAsIs>
    	</configuration>
    	...
    </plugin>
    ...
  3. Change your index.html file to point to your app.
    From:

    <meta http-equiv="REFRESH" content="0;url=my.long.package.name.Application/Application.html">

    To:

    <meta http-equiv="REFRESH" content="0;url=Application.html">
  4. Your done.

Additional resources:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f8b06676098b8cc6

http://groups.google.com/group/gwt-maven/browse_thread/thread/a46f540ca823e3d3/7d5febf0776958db?lnk=gst&q=rename#7d5febf0776958db

HOWTO: Run your java web app as the root context on Tomcat

Friday, March 13th, 2009

If you have a context XML fragment in your war (META-INF/context.xml) then it’s as easy as renaming your war file to ROOT.war

If you’re using the maven build system then just alter your pom to have:

<build>
	<finalName>ROOT</finalName>
	...
</build>

Simple when you know how…