Blog
Using Google Web Toolkit with Eclipse WTP
Marco Mulder
17 August, 2006
Capabilities:
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:
- It is possible to use external jars and other Eclipse projects from services that are implemented with the RemoteServiceServlet.
- It is easy to test the 'compiled' JavaScript version in tomcat without having to create and deploy a war file.
- It is easy to export a war file that can be deployed in any application server.
- Create a dynamic Web project MyProject in Eclipse WTP
- Use GWT projectCreator without overwriting the .project and .classpath files:
projectCreator.cmd -ignore -eclipse MyProject
- Use GWT applicationCreator to create a GWT application:
applicationCreator.cmd -eclipse MyProject com.mycompany.client.MyApplication
- Add gwt-user.jar and junit.jar to the .classpath file:
<classpathentry kind="lib" path="C:/gwt-windows-1.1.0/gwt-user.jar"/> <classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
- Search and replace "www" to "WebContent" in MyApplication.launch, MyApplication-compile.cmd and MyApplication-shell.cmd
- Copy gwt-servlet.jar to WebContent/WEB-INF/lib
- Compile Java source into JavaScript using MyApplication-compile.cmd
- Select "Run as --> Run on Server" from the context menu of MyProject
- Open a browser on the URL of the application:
https://xebia.com/blog:8080/MyProject/com.mycompany.MyApplication/MyApplication.html
- Use GWT.getModuleBaseURL() in the serviceEntryPoint:
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "myservice");
- Specify the full path in MyApplication.gwt.xml:
<servlet path=">/com.mycompany.MyApplication/myservice" class="com.mycompany.server.MyServiceImpl"/>
- Specify the path also in WebContent/WEB-INF/web.xml:
Marco Mulder
Contact
Let’s discuss how we can support your journey.