Thursday, August 20, 2009

Developing a real Java EE application with GWT

To make you life easier when developing a real Java EE application with GWT as a
front-end marvel, follow the next few lines. In about 10 minutes, you will be smiling!


1) follow this tutorial: http://cwiki.apache.org/GMOxSAMPLES/5-minute-tutorial-on-enterprise-application-development-with-eclipse-and-geronimo.html
2) When this 5 minutes tutorial works, then go to step number 3.
3) To enable your regular WST Web project into a GWT aware project, manually add GWT nature to the Dynamic Web Project.

In the .project file add after :


org.eclipse.jdt.core.javabuilder




these lines:


com.google.gdt.eclipse.core.webAppProjectValidator




com.google.gwt.eclipse.core.gwtProjectValidator




4) GWT uses the folder war by default and you can't change that. WST is using WebContent by default The WST Dynamic Web App wizard
lets you change that. So if you these lines before creating the WST Web App, change the default WebContent folder to war.
If you are like me, you will need to change the following line in the your /.settings/org.eclipse.wst.common.component file:

Change line:


To:


5) Add the GWT Library to you classpath. Right Click on the WAR project -> Java Build path -> Libraries -> Add Library -> Select
the Google Web Toolkit variable.


6) We are almost there. To insert you GWT compiled server side classes in the deployment path, you need to right click on you WAR project
-> Properties -> Java Build Path -> Select the Source tab and change the Default Output Dir to:
change the default output to :

/war/WEB-INF/classes

7) Now you have to compile you GWT project. You must see a new folder in the ./war folder appear and it
should be the name of your gwt module. Right click on your war project -> Google -> GWT Compile.

8) WST relies on the JAVA EE Project Dependencies to see other projects classes. But GWT does not. So right
Click on the WAR project -> Java Build path -> Projects -> (and add the EJB project).

9) Recompile and republish. You should be able to see you fully integrated GWT application using real EJBs

- Erick Audet

No comments: