Run RPC sample code from scratch with Eclipse WTP Tomcat WinXP SP2

25 views
Skip to first unread message

uwfrog

unread,
Aug 18, 2006, 3:42:02 PM8/18/06
to Google Web Toolkit
I have seen many threads about problems running RPC sample coming with
GWT sdk. Here I compile a couple of tutorials from web to show how I
set up and run the RPC sample. There are various ways to do it, and
this is just the way how I did it.


JDK1.5Update07
The latest is JDK1.5Update08. Download the windows version and follow
the default install.

Eclipse 3.2
http://download.eclipse.org/eclipse/downloads/drops/R-3.2-200606291905/index.php
download eclipse-SDK-3.2-win32.zip

WTP1.5.1 (WTP1.5.0 has a bug displaying JSP page in host mode)
http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R1.5/M-1.5.1-200608032139/wtp-sdk-M-1.5.1-200608032139.zip
pick a server to download wtp-sdk-M-1.5.1-200608032139.zip

WTP requires some other plug-ins.
EMF driver
http://download.eclipse.org/tools/emf/downloads//drops/2.2.1/M200607270021/emf-sdo-xsd-SDK-M200607270021.zip

GEF driver
http://download.eclipse.org/tools/gef/downloads/drops/R-3.2-200606270816/GEF-SDK-3.2.zip

Java EMF Model Runtime driver
http://download.eclipse.org/tools/ve/downloads/drops/R-1.2-200606280938/JEM-SDK-1.2.zip

GWT1.1.0 (GWT1.0.21, you have to modify the launch file. I am using the
latest one to make my life easier.)

Tomcat 5.5.17
http://apache.mirrors.northco.net/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17.zip
Here we use the zip file to have more control on tomcat, and it is more
convenient.
Notice we use the zip file, not the windowz bin file.

Setup

Make a new directory <eclipse-home> wherever you like, eclipse doesn't
install anything in registry. Unzip eclipse-SDK-3.2-win32.zip under
<eclipse-home>. Then you will see a directory called
eclipse-SDK-3.2-win32, which contains the eclipse files,i.e,
eclipse.exe, which starts the IDE. You can rename eclipse-SDK-3.2-win32
as you like, here we will call it <eclipse-dev>.

So now, you will have <eclipse-home>\<eclipse-dev>. Let s look into
<eclipse-dev> for now, you will see a directory called plugin. It is
usually where you install the plugins. However, I would like to
seperate the ide and plugins, since I know I am going to update the
plugins or the ide sooner or later. Therefore, I create a directory
called links under <eclipse-dev>(links is in the same directory as
eclipse.exe), and create a directory <eclipse-plugins> under
<eclipse-home>. You now have <eclipse-home>\<eclipse-plugins> and
<eclipse-home>\<eclipse-dev>\links\.

Unzip each eclipse plugin into <eclipse-plugins>. In words, create a
directory for each plugin, unzip in this directory, under which you
will have a single fold "eclipse". Something like this,
<eclipse-plugins>\<plugin1>\eclipse\pluginfiles. On the other hand,
create a .link file for each plugin in <eclipse-dev>\links. Put the
path to the plugin in the .link file, like
"path=..\\..\\<eclipse-plugins>\\<plugin1>". Note that use double back
slash, DO NOT include quotation mark, and replace with the actual
directory names you use.

After you have done these, you are all set to launch the IDE, make sure
the WTP plugin starts up. Check in the menu Window->Preferences, in the
left column you should see "server". If there is problem, please make
sure you have the right path in the link file.

Fun Part:

Start Eclipse IDE, you might have to install/set JDK and server.
JDK: Window->Preference, on the left column, find Jave->installed JREs,
choose a jdk you like to use.
Server: Unzip apache-tomcat-5.5.17.zip to <apache-tomcat>. Then,
Window->Preference, on the left column, find Server->installed
Runtimes. Click Add, find Apache Tomcat v5.5, fill in name, the
directory where you install tomcat, and the jre tomcat will use(select
jdk for safety), and finish.

Create WTP project. File->new->project, choose Dynamic Web project,
next Project Name DynaTable, and finish. IDE will ask you to switch to
J2EE perspective, choose yes.
In Project Explorer, Right click DynaTable->src, new package, Package
name: com.google.gwt.sample.dynatable, finish.
Unzip GWT1.1.0 to <gwt>. Open a command box, go to
<workspace>\DynaTable, run
<gwt>\applicationCreator -eclipse DynaTable
com.google.gwt.sample.dynatable.client.DynaTable (in a single line)

Switch back to eclipse, Right click DynaTable in the project explorer,
Properties, find Java build path, choose add external JARs, add
gwt-user.jar in <gwt>, and ok.

Refresh project explorer.

Copy <gwt>\samplse\DynaTable\src to <workspace>\DynaTable\src,
overwrite the whole src directory.

Refresh project explorer. You will see client and server show up
instead of original only single client fold showing under src. You will
also notice that there are several unresolved compilation error(little
red marks), which leads us to next step.

Copy <gwt>\gwt-servlet.jar to
<workspace>\DynaTable\WebContent\WEB-INF\lib

Refresh. The compile error should go away.

Go to SchoolCalendarWidget.java . Two places to modify to enable real
RPC.
line 108: set USE_STATIC_RPC_ANSWERS = false;
line 39: in constructor, change
target.setServiceEntryPoint("/calendar");
to
target.setServiceEntryPoint(GWT.getModuleBaseURL()+"/calendar");

Right click Depolyment Descriptor, open with text editor,
add the following before <welcome-file-list>:
<servlet>
<servlet-name>SchoolCalendar</servlet-name>

<servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SchoolCalendar</servlet-name>
<url-pattern>/calendar</url-pattern>
</servlet-mapping>

Don't forget to save the xml file, or it will give an error.

Before you give it a shot in host mode, right click
DynaTable->Properties, click Server on the left column, and choose
apache-tomcatv5.5 as the default server for the project.

Go to Run->Run...
Left column, find Java Application->DynaTable, choose it, you will see
its main class is com.google.gwt.dev.GWTShell, if it isn't, try the
search button next to it. Then click run, the program should run in
host mode. My computer is slow, so it takes a while to show data, be
patient. And now you can play with it.

Last step, deploy it onto server. If you follow this tutorial through,
the last step would be pretty trival. Sit back and a cup of coffe. You
will see the beauty of gwt in the next few minutes.
Go to <workspace>\DynaTable, execute DynaTable-compile.cmd, it takes
about a minute to generate a new directory called www. Go down to
www\com.google.gwt.sample.dynatable.Dynatable, copy everything to
<workspace>\DynaTable\WebContent. Remember we unzip apache-tomcat in
<apache-tomcat>? Go to <apache-tomcat>/bin. Execute startup.bat, it
will pop up one console window. This means your tomcat is on. Switch
back to eclipse, right click on DynaTable->Export->WAR file. Choose the
Destination location as <apache-tomcat>\webapps\DynaTable.war, and
finish. Take a look at the tomcat console window, you will see a
message showing DynaTable is automatically deployed, you don't have to
reboot.
Try http://localhost:8080/DynaTable/DynaTable.html, you should see the
page.

I found out this setup minimizes the repeated work everytime, and it is
really smooth from debugging in host mode to deploying on local/remote
server.

Anyways, this is the end of the tutorial. I hope everyone has a
pleasant start with gwt.

Al

Gabe

unread,
Aug 30, 2006, 2:30:27 AM8/30/06
to Google Web Toolkit
I followed your steps but didnt get the same result - when i run the
project it the rpc throws an exception - this is what i got:

Failed to access data: <html><head><title>Apache Tomcat/5.0.28 - Error
report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 500 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b>
<u></u></p><p><b>description</b> <u>The server encountered an internal
error () that prevented it from fulfilling this
request.</u></p><p><b>exception</b>
<pre>javax.servlet.ServletException: Servlet execution threw an
exception
</pre></p><p><b>root cause</b>
<pre>java.lang.UnsupportedClassVersionError: Bad version number in
.class file
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.access$100(Unknown Source)
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Unknown Source)

com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:660)

com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:165)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is
available in the Apache Tomcat/5.0.28 logs.</u></p><HR size="1"
noshade="noshade"><h3>Apache Tomcat/5.0.28</h3></body></html>

what really confuses me is i have tomcat 5.5.17 not 5.0.28

Gabe

unread,
Aug 30, 2006, 2:51:31 AM8/30/06
to Google Web Toolkit
Ok - I ignored that error and tried to export the war file which seemed
to go ok - however when i browsed to the page i got a 404 saying that
'/DynaTable/DynaTable.html' was not available (it was deployed though)

this time the error came from tomcat 5.5.17

any help in this would be much appreciated.

Alfred Yang

unread,
Aug 30, 2006, 9:11:22 AM8/30/06
to Google-We...@googlegroups.com
Double check the compiled javascript/html files do exist under WebContent directory. The error you got is because DynaTable.html could not be found in WebContent.

Al

Sandy

unread,
Sep 15, 2006, 4:02:05 AM9/15/06
to Google Web Toolkit
HI Alfred
grt tutorial U should send it to the GWT for adding this into there
getting started.
This got the DynaTable app start workin and it should show me the way
to deploy my app onto tomcat.

Grt work dude
I really appreciate that

Sandy

Rafael Lessa Barreto

unread,
Sep 15, 2006, 9:29:45 AM9/15/06
to Google-We...@googlegroups.com
How can i get this tutotiral?

Rafael Lessa Barreto

-----Mensagem original-----
De: Google-We...@googlegroups.com
[mailto:Google-We...@googlegroups.com] Em nome de Sandy
Enviada em: sexta-feira, 15 de setembro de 2006 05:02
Para: Google Web Toolkit
Assunto: Re: Run RPC sample code from scratch with Eclipse WTP Tomcat WinXP
SP2

Sandy

unread,
Sep 16, 2006, 5:33:18 AM9/16/06
to Google Web Toolkit
Just follow the steps in the first post in the thread :-D

uwfrog

unread,
Sep 19, 2006, 10:47:59 AM9/19/06
to Google Web Toolkit
For those using GWT 1.1.10, to run the actual RPC, you don't have to
modify line39 in file SchoolCalendarWidget.java any more, simply do

line 108: set USE_STATIC_RPC_ANSWERS = false;

GWT team "Normalized behavior of GWT.getModuleBaseURL() with respect to
hosted mode" in this version.

Reply all
Reply to author
Forward
0 new messages