Eclipse JavaEE tools + GWT Development mode

2,598 views
Skip to first unread message

Chris Lercher

unread,
Feb 14, 2010, 1:23:03 PM2/14/10
to Google Web Toolkit
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.

Chris Lercher

unread,
Feb 15, 2010, 5:27:06 AM2/15/10
to Google Web Toolkit
Additional steps to integrate with EJBs (3.1, probably similar for
3.0) This is more straightforward, but there are a few minor stumbling
blocks:

7. Enterprise Archive
------------------------------

Create a "JavaEE/Enterprise Application project". Let's call it
"myEar".
Add "myProject" to its module dependencies.

Important: Generate an application.xml deployment descriptor!
In the application.xml, set <context-root>/</context-root>

GWT-Compile myProject once again (I don't really know why this is
necessary, however it didn't work for me without this step. Does
anybody have an explanation?)

In the Servers view, remove the myProject deployment. Then add myEar
instead.

Run the application server and the GWT code server again. The
application should work as before - only difference is, that it's now
bundled in an EAR (Note: Bundling as an EAR shouldn't be absolutely
necessary for Java EE 6, but Eclipse 3.5 still seems to require that
layout.)

8. EJB Project
---------------------

Create an "EJB/EJB Project". Let's call it "myEjb".
Add it to "myEar" as a Java EE module dependency.
Add at least one EJB to the project source code (otherwise, deployment
will be refused (!))

Add "myEjb" as a Java EE module dependency to "myProject" (Properties -
> Java EE Module Dependencies)

Now you can inject your EJBs into GreetingServiceImpl by using the
@EJB annotation. But: It won't work with Deployment Descriptor v2.3
(which was generated by WebAppCreator). So open your web.xml, remove
the DTD declaration, and replace the opening tag with this:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://
java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

Try using an injected EJB from GreetingServiceImpl. GWT-Recompile
"myProject", and run the application server and the GWT code server.

I hope it worked! Ideally there would be an Eclipse wizard for the
entire setup of course ;-)

Chris

Keith Platfoot

unread,
Feb 18, 2010, 11:40:43 AM2/18/10
to google-we...@googlegroups.com
Hi Chris,

Thanks for posting this.  It's a good explanation of how to get WTP and GPE 1.2 working together, which is not a trivial task.  However, in the next release of the plugin we're planning on making this integration a whole lot easier.

With GPE 1.3, you'll be able to adapt an existing Dynamic Web Project as a GWT project and debug using hosted/dev mode quite easily.  Here's a sneak preview of how this will work in GPE 1.3:

1. In your project's Properties dialog, select Google > Web Toolkit and check the box: Use Google Web Toolkit.

2. Switch to the Web Application property page and change WAR source directory to "WebContent" and uncheck the box: Also use this directory as the output WAR directory.

3. Start your project's server (be it GlassFish, Tomcat, etc.) using your configured WTP server adapter.

4. Create a new Web Application launch configuration.  On the Server tab, uncheck: Run built-in server (since we want to use WTP's server adapter) and on the GWT tab, change the -startupUrl argument to point to your server (e.g. http://localhost:8080/WebApp)

5. Run/Debug your new launch configuration.  The first time you do this, you'll have to select the location of the WAR directory WTP is publishing to (this is configurable, but I think by default it is <workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/<project>).

6. Presto!  GWT hosted/dev mode is now running in your own server, and you can debug either server-side or client-side code, and get automatic redeploy of modified class files or static resources thanks to WTP's auto-publish mechanism.

We're going to be uploading a preview built of GPE 1.3 later this month so you can try it out for yourself and let us know what you think, ahead of the official release.  Stay tuned!

Keith


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


GPE 1.3 Web App project properties.png
GPE+WTP.png
GWT on Tomcat.png

Chris Lercher

unread,
Feb 19, 2010, 6:17:32 AM2/19/10
to Google Web Toolkit
Wow, that sounds good! I'm really happy to hear that GPE will make
this available.

There's one additional thing I'd like to be able to do: Split up the
WebContainer part and the GWT part into two projects. This is
currently not so easy, because
- you'll need to have the web.xml in both projects and keep them in
sync. I'd really like to have the web.xml in the Web project, not in
the GWT project.
- it's necessary to copy the GWT-compiled output folder from the GWT
project into the Web project (I think, at least every time the
serialization policy file changes (?)).

Are there any plans for GPE to support this kind of project splitting?

Chris

On Feb 18, 5:40 pm, Keith Platfoot <kplatf...@google.com> wrote:
> Hi Chris,
>
> Thanks for posting this.  It's a good explanation of how to get WTP and GPE
> 1.2 working together, which is not a trivial task.  However, in the next
> release of the plugin we're planning on making this integration a whole lot

> easier<http://groups.google.com/group/google-web-toolkit/msg/8ff67143cce64e1...>


> .
>
> With GPE 1.3, you'll be able to adapt an existing Dynamic Web Project as a
> GWT project and debug using hosted/dev mode quite easily.  Here's a sneak
> preview of how this will work in GPE 1.3:
>
> 1. In your project's Properties dialog, select Google > Web Toolkit and

> check the box: *Use Google Web Toolkit*.
>
> 2. Switch to the Web Application property page and change *WAR source
> directory* to "WebContent" and uncheck the box: *Also use this directory as
> the output WAR directory.*
> *
> *


> 3. Start your project's server (be it GlassFish, Tomcat, etc.) using your
> configured WTP server adapter.
>
> 4. Create a new Web Application launch configuration.  On the Server tab,

> uncheck: *Run built-in server* (since we want to use WTP's server adapter)


> and on the GWT tab, change the -startupUrl argument to point to your server

> (e.g.http://localhost:8080/WebApp)

Keith Platfoot

unread,
Feb 23, 2010, 5:52:03 PM2/23/10
to google-we...@googlegroups.com
Hi Chris,

We don't have any specific plans to add support to 1.3 for the sort of project splitting you describe, but feel free to add an issue to the GWT issue tracker and we'll look into working it into a future release if there's enough interest.

Thanks,

Keith

Neciu

unread,
Mar 15, 2010, 3:41:45 PM3/15/10
to Google Web Toolkit
Hi Keith,

can you tell how to configure Eclipse + Google Plugin for Eclipse (the
newest version), so I can debug my GWT project with DB connections?
Your previous solution doesn't work anymore (I can't find anythig
about WAR in "Web Application property").

Thanks in advance,
Neciu.

On 18 Lut, 17:40, Keith Platfoot <kplatf...@google.com> wrote:
> Hi Chris,
>
> Thanks for posting this.  It's a good explanation of how to get WTP and GPE
> 1.2 working together, which is not a trivial task.  However, in the next
> release of the plugin we're planning on making this integration a whole lot

> easier<http://groups.google.com/group/google-web-toolkit/msg/8ff67143cce64e1...>


> .
>
> With GPE 1.3, you'll be able to adapt an existing Dynamic Web Project as a
> GWT project and debug using hosted/dev mode quite easily.  Here's a sneak
> preview of how this will work in GPE 1.3:
>
> 1. In your project's Properties dialog, select Google > Web Toolkit and

> check the box: *Use Google Web Toolkit*.
>
> 2. Switch to the Web Application property page and change *WAR source
> directory* to "WebContent" and uncheck the box: *Also use this directory as
> the output WAR directory.*
> *
> *


> 3. Start your project's server (be it GlassFish, Tomcat, etc.) using your
> configured WTP server adapter.
>
> 4. Create a new Web Application launch configuration.  On the Server tab,

> uncheck: *Run built-in server* (since we want to use WTP's server adapter)


> and on the GWT tab, change the -startupUrl argument to point to your server

> (e.g.http://localhost:8080/WebApp)

Keith Platfoot

unread,
Mar 18, 2010, 11:33:29 AM3/18/10
to google-we...@googlegroups.com
Hi Neciu,

We just released the 1.3 version of the Google Plugin for Eclipse on Tuesday, which should have a Google > Web Application project property page with the WAR directory field.  Are you certain your plugin version is 1.3?

Keith

David

unread,
Mar 31, 2010, 2:14:43 AM3/31/10
to Google Web Toolkit

Cris, your notes were really helpfully.

However I would like to know how you manage to debug your application
using your Glassfish (tomcat in my case) in order to use breakpoints
and those stuff.

Thanks you so much

Chris Lercher

unread,
Mar 31, 2010, 1:47:44 PM3/31/10
to Google Web Toolkit
Hi David,

I haven't tried the same setup with Tomcat yet, but I expect it should
be the same procedure: In the "Servers" view in Eclipse, select the
server you deployed the EAR to. Right-click it and choose "Debug".
This allows you to set breakpoints in your server side code.

To debug the client side code, you can additionally start your GWT
code server (the one that's usually on port 9997) in Debug mode
(Select your GWT project, then "Debug As... > Web Application"). You
should actually modify that debug configuration to uncheck the
checkbox "Run built-in server"! (Because you're using Tomcat instead
of the built-in Jetty). Now you'll only start the code server, without
Jetty. Then, if you're using default values for your ports, you can
browse your application with something like:

http://127.0.0.1:8080/MyProject.html?gwt.codesvr=127.0.0.1:9997

(instead of http://127.0.0.1:8888/MyProject.html?gwt.codesvr=127.0.0.1:9997)

HTH
Chris

PS I'd really be interested, if it works with Tomcat, too - please
report back.

ekr

unread,
Apr 5, 2010, 10:22:31 PM4/5/10
to Google Web Toolkit
Hi Keith,

I'm very encouraged - I was able to get my existing project updated
using Google -> Web Application properties and the Web Toolkit
properties. I'm using GWT 2.0.3 and Google Plugin for Eclipse 3.5 -
1.3.2.v201003242055. I have a manual build (Ant) working with a
Dynamic Web Project with a WebContent directory.

Now the GWT Compile Project recognizes the project but when I try to
run it I have a problem. I'm using OC4J 10.1.3.5.0 which includes the
Oracle Parser which doesn't like the feature. Any Ideas?

Thanks, Eric

[ERROR] Failure while parsing XML
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/nonvalidating/load-external-dtd
at
oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:
128)
at com.google.gwt.dev.util.xml.ReflectiveParser
$Impl.parse(ReflectiveParser.java:320)
at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access
$100(ReflectiveParser.java:48)
at
com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:
398)
at
com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:
257)
at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:
169)
at
com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:
283)
at
com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:
141)
at com.google.gwt.dev.Compiler.run(Compiler.java:184)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
87)
at
com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:
81)
at com.google.gwt.dev.Compiler.main(Compiler.java:159)
[ERROR] Unexpected error while processing XML
com.google.gwt.core.ext.UnableToCompleteException: (see previous log
entries)
at com.google.gwt.dev.util.xml.ReflectiveParser
$Impl.parse(ReflectiveParser.java:351)
at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access
$100(ReflectiveParser.java:48)
at
com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:
398)
at
com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:
257)
at com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:
169)
at
com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:
283)
at
com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.java:
141)
at com.google.gwt.dev.Compiler.run(Compiler.java:184)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
87)
at
com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:
81)
at com.google.gwt.dev.Compiler.main(Compiler.java:159)

> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs­cr...@googlegroups.com>


> > .
> > For more options, visit this group at

> >http://groups.google.com/group/google-web-toolkit?hl=en.- Hide quoted text -
>
> - Show quoted text -

Keith Platfoot

unread,
Apr 8, 2010, 5:11:14 PM4/8/10
to google-we...@googlegroups.com
Hi Eric,

Hm, I'm not really sure about that error.  Is it possible to use another parser rather than the Oracle Parser?  Also, are there DTD references in your module file?  The error mentions a missing http://apache.org/xml/features/nonvalidating/load-external-dtd feature, which might only be an problem if you actually have references to external DTD's in your XML.  Just a guess.

Keith

To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

ekr

unread,
Apr 9, 2010, 6:47:09 PM4/9/10
to Google Web Toolkit
Hi Keith,

I played and played with Eclipse build path order etc. to see if I
could get the GWT plugin to use the JDK parser, not the one from the
J2EE app server OC4J. No Luck. Not sure what is driving this.

I looked at the source code In the dev subproject
com.google.gwt.dev.util.xml.ReflectiveParser.java
and found that it sets the feature http://apache.org/xml/features/nonvalidating/load-external-dtd
to false.

From http://xerces.apache.org/xerces-j/features.html

http://apache.org/xml/features/nonvalidating/load-external-dtd
True: Load the external DTD.
False: Ignore the external DTD completely.
Default: true
Note: This feature is always on when validation is on.

Not sure what the JAXP spec says but the code here is assuming (I
think) a Apache (xerses) parser which in this case
may not be a good assumption. Perhaps the ReflectiveParser should
catch this exception explicitly
"org.xml.sax.SAXNotRecognizedException" and log it or something. Not
sure if the Oracle impl should ignore features that it doesn't
understand but we have no control over that. Anyway, hopefully this
can be fixed and until then ...

Workaround for GWT compile for OC4J
Advanced->VM arguments
-
Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

Thanks for the pointers - gave me some motivation to dig deeper,
Eric

> > com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.ja­va:


> > 141)
> >        at com.google.gwt.dev.Compiler.run(Compiler.java:184)
> >        at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
> >        at
> > com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
> > 87)
> >        at
>

> > com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRu­nner.java:


> > 81)
> >        at com.google.gwt.dev.Compiler.main(Compiler.java:159)
> > [ERROR] Unexpected error while processing XML
> > com.google.gwt.core.ext.UnableToCompleteException: (see previous log
> > entries)
> >        at com.google.gwt.dev.util.xml.ReflectiveParser
> > $Impl.parse(ReflectiveParser.java:351)
> >        at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access
> > $100(ReflectiveParser.java:48)
> >        at
> > com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:
> > 398)
> >        at
> > com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:
> > 257)
> >        at
> > com.google.gwt.dev.cfg.ModuleDefLoader$1.load(ModuleDefLoader.java:
> > 169)
> >        at
> > com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:
> > 283)
> >        at
>

> > com.google.gwt.dev.cfg.ModuleDefLoader.loadFromClassPath(ModuleDefLoader.ja­va:


> > 141)
> >        at com.google.gwt.dev.Compiler.run(Compiler.java:184)
> >        at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
> >        at
> > com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
> > 87)
> >        at
>

> > com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRu­nner.java:

> > > >http://groups.google.com/group/google-web-toolkit?hl=en.-Hide quoted


> > text -
>
> > > - Show quoted text -
>
> > --
> > 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-we...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs­cr...@googlegroups.com>
> > .
> > For more options, visit this group at

> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> 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-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

> For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages