Hi,

today I set up a GWT project that should use GlassFish v3 instead of
Jetty for GWT's development mode. It was important for me to make it
work seamlessly with the Eclipse JavaEE (WST/WTP) tools. Turns out,
it's not perfectly straightforward, at least not, if you want auto
rebuild/deploy. I've written down some notes. So if you want to do GWT
development, but you need to use a different server than Jetty during
development, they might be useful. If someone finds an easier way,
please let me know :-)

Chris


0. Create a server domain
-----------------------------------

e. g. on GlassFish v3, from command line:
/path/to/glassfish/bin/asadmin
asadmin> create-domain mydomain
asadmin> exit

1. Create Eclipse server runtime environment
-------------------------------------------------------------

Preferences -> Server -> Runtime Environments -> Add...
Download additional server adapters, if necessary. Then follow the
wizard to add the server environment (e. g. GlassFish v3 Java EE 6).
For Domain Name, select "mydomain".

2. Use WebAppCreator to create project
-------------------------------------------------------

>From command line:
- Add the GWT SDK dir to your path (e. g. /path/to/eclipse/plugins/
com.google.gwt.eclipse.sdkbundle.2.0.2_2.0.2.v201002121411/gwt-2.0.2)

- cd to your workspace directory. Then invoke:
webAppCreator -out myProject -junit $JUNIT_JAR myProject.MyProject
(where $JUNIT_JAR is something like /path/to/eclipse/plugins/
org.junit_3.8.2.v20090203-1005/junit.jar)

3. Convert to a Dynamic Web project
--------------------------------------------------

We will let Eclipse create a Dynamic Web project on top of the project
we just created (!)

- First remove the .project file, otherwise Eclipse won't let you
create a new project on top of the existing one.

- Then create the project

New -> Project -> [Web/Dynamic Web Project]

Project name: [myProject]
Target runtime: [GlassFish v3 Java EE 6] (or similar)

Next

Default output folder: [war/WEB-INF/classes]

Next

Context root: [/]
Content directory: [war]

Finish

4. Merge the Web project and GWT project natures and classpathes
--------------------------------------------------------------------------------------------

Open the .project file. Insert the lines:

        ...
                <buildCommand>
                        
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>

And
        ...
                <nature>com.google.gwt.eclipse.core.gwtNature</nature>
                <nature>com.google.gdt.eclipse.core.webAppNature</nature>
        </natures>

Then open .classpath. Insert the following line:

        <classpathentry kind="con"
path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>

(I inserted it directly after <classpathentry kind="src" path="src"/>)

5. Run Development mode
------------------------------------

- First you must GWT-compile the project *once*. I know, we'll be
running in development mode, but this step is necessary according to
http://code.google.com/webtoolkit/doc/latest/FAQ_DebuggingAndCompiling.html#How_do_I_use_my_own_server_in_hosted_mode_instead_of_GWT's

- In the servers view, start your GlassFish/... server. Then right-
click it, select Add/Remove... and add myProject. (Make sure that you
haven't deployed any other application with a context root of "/"!)

- Now start the GWT code server:
Run -> Run Configurations... -> Web Application
Select New launch configuration

Project: [myProject]
Uncheck [ ] Run built-in server

Run

The "Development Mode"-view should suggest a URL like:
http://127.0.0.1:8888/MyProject.html?gwt.codesvr=127.0.0.1:9997

Copy it and paste it to a browser. But: Replace 8888 with the port of
your GlassFish/... server (probably 8080).

The Web Application Starter Project should show up. When you click
Send, the dialog box should tell you, that you're running
GlassFish/... instead of the usual Jetty.

6. Develop
--------------
When you change anything on the server or client, it will be published
automatically. If you want to change this behaviour for the server,
double-click on your server in the Servers view. Then under
"Publishing", select the options you want.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to