I am writing a GWT application and want to test this application both in the GWT shell and in Tomcat. The application uses different Eclipse projects for the GWT UI and for the business service layer.
I found out that this can easily be done if you use an Eclipse WTP dynamic web project instead of the standard Java project that is created by the GWT projectCreator.
Using a dynamic web project has the following advantages:
There is an Eclipse plugin for using GWT with WTP: Googlipse . However, this plugin does not (yet) support launching the 'compiled' JavaScript application. I will outline the steps that allow you to launch the JavaScript version of a GWT application in WTP.
How to create a GWT application in a dynamic web project
The recipe to create a GWT application in a dynamic web project is as follows:
projectCreator.cmd -ignore -eclipse MyProjectapplicationCreator.cmd -eclipse MyProject com.mycompany.client.MyApplication<classpathentry kind="lib" path="C:/gwt-windows-1.1.0/gwt-user.jar"/>
<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
Testing the application
You can use the generated launch configuration to test the application from the GWT shell. The WTP tooling ensures that libraries that are used by the web project will be on the classpath.
To test the 'compiled' JavaScript application:
http://localhost:8080/MyProject/com.mycompany.MyApplication/MyApplication.htmlImplementing and invoking a service
To invoke a service in a way that works both in the GWT shell and in the ‘compiled’ JavaScript application, you have to use GWT.getModuleBaseURL() when setting the endpoint.
For example, if you implement a service “myservice” in package com.mycompany.server.MyServiceImpl:
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "myservice");<servlet path=">/com.mycompany.MyApplication/myservice" class="com.mycompany.server.MyServiceImpl"/>
<servlet>
<servlet-name>MyService</servlet-name>
<servlet-class>com.mycompany.server.MyServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyService</servlet-name>
<url-pattern>/com.mycompany.MyApplication/myservice</url-pattern>
</servlet-mapping>
Filed under Java | 2 Comments »
There is a modified version of Googlipse. See: http://wagenknecht.org/blog/archives/2006/08/yet-another-gwt-plug-in.html
Even if there are toolkits for doing this job, this is a very good explanation
thanks