Andre Dietishei [
http://community.jboss.org/people/adietish] modified the document:
"Use JBoss Tools with Google GWT Plugin"
To view the document, visit:
http://community.jboss.org/docs/DOC-15593
--------------------------------------------------------------
h1. A few simple steps to have GWT running on JBoss
If you develop web applications with GWT you most likely end up using Eclipse and the
Google Plugins for Eclipse. These Plugins offer to run your application on a jetty
instance. If you want to use JBoss instead, you'll have to define a war project
archive and make sure it gets published to the JBoss instance of your choice. This article
shows you the simple steps you'll have to take to achieve this.
h1. Premise
The google web toolkit, GWT is a pretty nice framework to develop web applications. Google
even delivers a plugin for Eclipse so that developing with GWT is a very pleasant
experience. The GWT plugin uses an embedded jetty to run the application that you develop.
The authors unfortunately did not use standard connectors. So if you want to use Jboss
instead of jetty the approach to take is not as intuitive as it could be. This article
shall show you how what steps to take so that you can run develop your GWT application
while running on JBoss.
h1. Solution
Either you already have a project or you want to start from scratch. So that the howto
here's complete, we'll show you the step to create a new GWT project, too.
h2. Install Google Plugin for Eclipse
Install the Google plugin for Eclipse in your JBDS by adding the following update site:
Choose and install the Google Plugin for Eclilpse among the availble ones.
http://community.jboss.org/servlet/JiveServlet/showImage/4313/install-gwt...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4313/install...
h2. Create a Web Application Project
In order to get the support you need for GWT projects, you'll need to create a new
*Web Application Project*. You may do so with the toolbar or with entries in the file
menu.
http://community.jboss.org/servlet/JiveServlet/showImage/4286/create-web-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4286/create-...
We will call it
*gwt-jboss*.
http://community.jboss.org/servlet/JiveServlet/showImage/4318/new-wizard-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4318/new-wiz...
h2. Create a new Project WAR
We'll work with a JBoss application server instead of the embedded jetty that's
provided with the google plugins. We therefore need to provide JBoss with a *War Archive*
that bundles your project resources. The JBDS *Project archives* view allows you to do so.
Select your GWT project and go to the *Project archives* view. You can now define a new
war archive.
http://community.jboss.org/servlet/JiveServlet/showImage/4289/create-new-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4289/create-...
The wizard that pops up allows you pick an archive name, the path at which it'll be
created and the type (packed or unpacked). Choose the settings that fit your needs.
http://community.jboss.org/servlet/JiveServlet/showImage/4290/create-new-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4290/create-...
The wizard created a default fileset, that determines what project files shall be included
in the war. We'll replace it by a fileset that includes all files within the *war
directory*. This is the location the google plugins compile and package the code to.
http://community.jboss.org/servlet/JiveServlet/showImage/4291/create-new-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4291/create-...
Your war archive shows up in the *Project archives* soon as you hit *finish*.
http://community.jboss.org/servlet/JiveServlet/showImage/4292/create-new-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4292/create-...
h1. Build and publish your war
We now have to make sure the war gets published to our JBoss instance. Choose the
appropriate entry in the context-menu of your war-archive and hit *Edit publish
settings*.
http://community.jboss.org/servlet/JiveServlet/showImage/4293/adjust-war-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4293/adjust-...
The developer studio comes with a preconfigured jboss-eap. You therefore already get that
server in the list of the available servers. Select it and choose to publish to it in the
way that fits your needs:
http://community.jboss.org/servlet/JiveServlet/showImage/4294/adjust-war-...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4294/adjust-...
Your war now's assiociated to your server and will be published to it if your GWT
project's been built. The *Servers* view show you that:
http://community.jboss.org/servlet/JiveServlet/showImage/4295/war-on-serv...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4295/war-on-...
h2. Cross compile
GWT allows you to write your client code in (almost) plain java instead of funky
javascript. GWT ships a cross compiler that generates javascript out of your java classes.
You need to start that cross compiler so that the client codes gets into your war.
http://community.jboss.org/servlet/JiveServlet/showImage/4319/cross-compi...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4319/cross-c...
The Google cross compiler will inform you in the console view whether's he succeeded
in his job. Check the output and wait until it terminated its compilation task.
Now you're almost done, the archive has all it needs. *B**uild* and *publish* your
war.
http://community.jboss.org/servlet/JiveServlet/showImage/4298/build-archi...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4298/build-a...
http://community.jboss.org/servlet/JiveServlet/showImage/4299/publish-arc...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4299/publish...
h2. *Launch your Browser*
The project archive we created was deployed to the base url *gwt-jboss*. The jBoss server
that's included in the JBoss developer studio is configured (by default) to run on
port *8080*. Your application's therefore accessible at the url:
**
*http://community.jboss.org/servlet/JiveServlet/showImage/4317/browser.png
http://community.jboss.org/servlet/JiveServlet/downloadImage/4317/browser...
h2. Speed up my development cycle!
The approach we've choosen so far uses an extra step to deploy the application after
each change. That's very reliable but it get tedious at development time. Google
delivers a so called hosted mode. Its major benefit is that your java classes dont get
cross-compiled but interpreted to javascript at runtime. Changing, testing, changing,
testing etc. gets much faster and pleasant, the cross-compilation step's not needed
any more. You need a browser plugin, a slightly different url for your application and a
google runtime to achieve that.
h2.
h2. Launch Google
If you start this launch configuration you wont have to cross compile your java client
classes to javascript. It will get interpreted by the google browser plugin. On the other
hand the browser plugin needs access to your java classes. The google runtime you just
launched allows it to get your java code. The url parameter you add when you access your
application tells the plugin at what ip and port he may get served.
Create a *Web Application* launch configuration for that matter.
http://community.jboss.org/servlet/JiveServlet/showImage/4296/new-run-con...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4296/new-run...
We want to use our JBoss instance, we therefore disable the embedded jetty that's
provided by the GWT plugins.
http://community.jboss.org/servlet/JiveServlet/showImage/4297/new-run-con...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4297/new-run...
Now that we want not to cross-compile on each change, we'll need to tell the google
browser-plugin where to fetch the code from. We do that by adding an url parameter:
**
Convince yourself that there's no cross compilation needed any more. Go to the
client-package and chage any java directive that's in there. You may for instance
change the label of a button and reload your browser (without launching the google
cross-compiler).
http://community.jboss.org/servlet/JiveServlet/showImage/4311/button-labe...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4311/button-...
http://community.jboss.org/servlet/JiveServlet/showImage/4312/button-labe...
http://community.jboss.org/servlet/JiveServlet/downloadImage/4312/button-...
--------------------------------------------------------------
Comment by going to Community
[
http://community.jboss.org/docs/DOC-15593]
Create a new document in JBoss Tools at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=102&am...]