Hey all,
Ok, now that the Google Plugin for Eclipse 1.3.2 is out, here are some
instructions for setting up a GWT application split across multiple projects
(client, server, and shared code in separate projects). Note that this will
*only *work in *Eclipse for Java EE* with *GPE 1.3.2*, so verify that you
have both installed before attempting. This procedure *won't* work if
you're using App Engine, since there is no WTP server adapter for App
Engine.
Also, I'm assuming that your application uses *GWT 2.0.3* and you're using
GWT RPC, so your server will provide at least one RPC service. If you're
not using RPC, just skip the relevant parts,
1. Create 3 projects: we'll call them FooServer, FooClient, and FooShared
for the purposes of this walkthrough. FooClient will contain your GWT
client-side code, FooServer will contain your server-side code and WAR
directory + static resources (HTML, CSS, etc.), and FooShared will contain
code that is shared between the client and server (e.g. GWT RemoteService
interfaces). FooServer should be a Dynamic Web Project; FooClient and
FooShared can be regular Java projects.
2. Enable GWT for all 3 projects (project properties > Google > Web
Toolkit). *NOTE: If you're not using GWT RPC, you don't need to enable
GWT on FooServer*).
3. If your project uses the Apache Tomcat library, ensure that the GWT
SDK library is above it on your project's classpath (project properties >
Java Build Path > Order and Export). Otherwise, you may get a
java.lang.NoSuchMethodError when launching your application in development
mode.
4. Add code to FooClient. You'll need at least one GWT module and an
entrypoint class. If you're using GWT RPC, you'll also need your service
async interfaces as well (see the GWT docs for more details). If don't have
existing code to work with, just generate a new Web Application project and
pilfer the files from there (renaming things as necessary, of course).
5. Add code to FooShared. If you're using GWT RPC, this is where your
RPC synchronous interfaces go. Also, any classes that you use on both the
client and the server should go here.
6. Add code to FooServer. Add your HTML pages, CSS files, etc. to
WebContent. If you're using GWT RPC, your RPC servlet code lives in
FooServer. Update WebContent/WEB-INF/web.xml to point to your welcome page,
set your servlet mappings, etc.
7. Link the projects. Add FooShared as a project dependency of FooClient
(project properties > Java Build Path > Projects). Add FooShared as a
module dependency of FooServer (projects properties > Java EE Module
Dependencies). If you're using GWT RPC, you'll also need to add the
gwt-servlet.jar as a module dependency of FooServer. Eclipse will ensure
that your runtime WAR directory's WEB-INF/lib and WEB-INF/classes will
always contain up-to-date copies of its module dependencies.
8. All 3 projects should now compile, but if you're using GWT RPC you
probably have some errors caused by missing asynchronous interfaces. Of
course, ours aren't missing, they're just in a different project
(FooClient). Ignore the errors via Preferences > Google > Errors/Warnings >
GWT Remote Procedure Calls (RPC).
9. Set up a server for FooServer. If you don't already have a server
configured, right-click inside the Servers view and select New > Server.
Use the server of your choice (I used Tomcat v6) and add FooServer to it.
If you already have a server, you can link it by right-clicking it and
selecting Add and Remove.
10. Start FooServer's server.
11. Create a Web Application launch configuration for FooClient. The
default main type will be GWTShell; change this to com.google.gwt.DevMode.
On the Server tab, uncheck the box: Run built-in server (we'll use
FooServer's server instead). On the GWT tab, enter the URL for the GWT host
page in the URL field. This will be the address of FooServer's server plus
FooServer's context root (project props > Web Project Settings). In my
case, the startup URL is: http://localhost:8080/Foo
12. Run the new launch configuration. The first time you launch, you'll
be prompted to select the runtime WAR directory. Select the staging
directory WTP created for FooServer. This location is configurable but by
default it is: <eclipse
workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/<project
name>.
13. In the Development Mode view that appears at the bottom of the
workbench, there should be a URL displayed. Right-click and select Copy,
then paste this into your web browser's address bar. If your browser
doesn't have the GWT Developer Plugin installed, you'll be redirected to a
page where you can install it.
14. If all went well, you now have your GWT code running in development
mode on top of your custom server. You should be able to edit code in any
of the 3 projects and have the changes reflected when you refresh your
browser (server-side changes may not require a refresh but do take a few
moments to propagate).
15. Bonus step: To create a WAR file for deployment, you'll first need to
compile FooClient to JavaScript. Select the FooClient project and click the
GWT Compile toolbar button. Click Advanced and enter the following
argument: -war /path/to/FooServer/WebContent and click Compile. Once
compilation finishes refresh the FooServer project. You should see a new
directory under WebContent containing the compiled JavaScript. Now, select
the FooServer project and select File > Export > Web > WAR file.
Hope folks find this useful, and let me know if I forgot any steps or
something does't work for you!
Keith
On Wed, Mar 24, 2010 at 3:11 PM, aish sundar <[email protected]> wrote:
> Thats sounds gr8!! Thanks a lot. will look out for the reply
>
> On Mar 24, 1:51 pm, Keith Platfoot <[email protected]> wrote:
> > Hi aish,
> >
> > Yes, this type of configuration is definitely possible. However, as of
> > right now, using it with the current version of the Google Plugin for
> > Eclipse requires a few hacky workarounds. The good news is that we're
> > releasing an update today or tomorrow (1.3.2) with a few surgical fixes
> that
> > will make the process more seamless. After we release the new version,
> I'll
> > post back to this thread with instructions for setting up a multiple
> project
> > configuration (projects for client code, server code, and optionally
> shared
> > code).
> >
> > Keith
> >
> > On Tue, Mar 23, 2010 at 12:50 PM, aish sundar <[email protected]>
> wrote:
> > > I am a newbie to GWT and have some integrating a GWT project to an
> > > existing web project running on Tomcat within Eclipse. It will be
> > > great if any one of you can help out. Heres the scenario.
> >
> > > 1) I have a separate GWT project I created using GWT plugin for
> > > Eclipse. Lets call it TestUI
> > > 2) I already have an existing web project within eclipse, called
> > > TestWeb, which runs on Tomcat6.0
> > > 3) Now I am somehow looking to integrate TestUI (in form of a war file
> > > or something) into TestWeb, so that I can get to the GWT UI pages
> > > through the tomcat server.
> >
> > > Is this even feasible? Could you elaborate steps required to achieve
> > > #3 above?
> >
> > > Thanks,
> > > aish
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google Web Toolkit" group.
> > > To post to this group, send email to
> [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-web-toolkit%[email protected]>
> <google-web-toolkit%[email protected]<google-web-toolkit%[email protected]>
> >
> > > .
> > > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.