GWT und tomcat: .war erzeugen mit eclispe um .war auf tomcat zu deployen
Wie man mit eclipse kompfortabel ein .war aus einem GWT-Projekt erzeugt, um es auf einem tomcat-Server zu deployen.
Im Grunde genommen sind es nur zwei einfache Schritte, um aus dem GWT-Projekt ein .war zu erzeugen:
Kurzversion:
Als erstes wird ein .jar aus dem “src”-Verzeichnis des Projektes generiert, welches in das “lib”-Verzeichnis des “war”-Verzeichnisses des GWT-Projektes gelegt werden muß. Der zweite Schritt ist dann das eigentliche generieren der .war-Datei, welche dann auf den tomcat-server deployed werden kann. Um den zweiten Schritt etwas kompfortabler zu gestalten habe ich hierfür ein Ant-Script geschrieben, welches das eigentliche .war erzeugt.
Detailierte Version – Schritt 1:
| 1) Rechts-Klick auf das src Verzeichnis innerhalb des Projektes. | |
| 2) Das nebenstehende PopUp erscheint.
Aus diesem Menü “Export …” wählen. |
|
| 3) Nun “JAR file” als Export-Format wählen | |
| 4) Es darf nur das “src”-Verzeichnis des Projektes ausgewählt sein.
Als Ziel für den Export muß folgender Pfad angegeben werden: <Verzeichnis des Projektes>/war/WEB-INF/lib/<projectname>.jar – dann auf “Finish” klicken. |
Nun ist das GWT-Projekt soweit vorbereitet, daß es in ein .war gepackt werden kann um auf einem tomcat-Server deployed zu werden.
Detailierte Version – Schritt 2:
1) Es wird ein neues ANT-Script innerhalb des Projektes erstellt (Rechts-Klick auf das Projektverzeichnis, dann “New” und vom Untermenü “File” auswählen. Die neue Datei sollte z.B. “warbuilder.xml” heissen).
2) Folgender Inhalt muß in diese Datei kopiert werden. Dabei <projectname> durch den Namen des Projektes ersetzen:
<project name="<projectname>" basedir="." default="default"> <target name="default" depends="buildwar,deploy"></target> <target name="buildwar"> <war basedir="war" destfile=" <projectname>.war" webxml="war/WEB-INF/web.xml"> <exclude name="WEB-INF/**" /> <webinf dir="war/WEB-INF/"> <include name="**/*.jar" /> </webinf> </war> </target> <target name="deploy"> <copy file=" <projectname>.war" todir="." /> </target> </project>
3) Die ersten beiden Schritte müssen für jedes Projekt nur einmal ausgeführt werden. Danach kann der warbuilder.xml immer wieder benutzt werden. Um das .war nun zu erzeugen klickt man einfach mit der rechten Maustaste auf den warbuilder.xml und wählt vom PopUp-Menü den Punkt “Run as” und vom Submenü “Ant Build” aus.
Die .war-Datei wird dann durch das ANT-Script erzeugt. You will find the .war-file in your ProjectFolder.
If you enjoyed this post, make sure you subscribe to my RSS feed!




thanks !! works well
Hey,
absolutely perfect; this is what i would like to call “missing manual” for GWT-Deployment!
Thank you so much!
Mikel from Germany
I mean how to deploy it on tomcat . Any command line commands for the same
@Nikhil Dhavale: After running the ant-script, you have to deploy the generated .war to your tomcat, using the default-upload service of your tomcat-manager. If you have no access to the tomcat-manager, you can also directly copy the file into the “webapps”-folder of your tomcat.
Thanks a lot, it’s working fine.
I can confirm this works as well. Thanks!
You are the man o/
Thanks for the help!
thank you very much !
Man!! you save me a bunch of time to resolve this f… problem.
Greetings from Mexico.
thanks dear, you saved my plenty of hours…thanks a lot from india
thanks a lot! I wish google was this clear on this
its shows that gwt modules recompile when i deploye that war file on to the tomcat 5.5
@Mehul
What do you mean by that?
It is important to note, that prior to performing any of these steps, you need to (in Eclipse):
- perform a clean on the project making sure the “Start a build automatically ” checkbox is NOT checked;
- right click on the project and select Google, followed by GWT Compile
- Then build the jar and war file as described above.
Otherwise, after you deploy the war to Apache Tomcat the error “gwt module may need to be (re)compiled” will appear, when you click on the application to bring it up in a browser.
Btw, excellent instructions on how to build the jar and war file. Thanks a lot!
Thanks a lot!!! It was very useful for me.
thanks a lot, Google should implement this feature for eclipse.
perfect. Thank you for the tip