GWT & Tomcat in Eclipse: Tomcat loads its classes from gwt-dev.jar instead of its own.

134 views
Skip to first unread message

Bob Luo

unread,
Jan 25, 2010, 5:49:24 PM1/25/10
to Google Web Toolkit
Hi,

I am actually experimenting with GWT to replace our UI. (We actually
use struts) I like GWT a lot so far.

I thus pushed the experiment further by trying to integrate it in our
solutions. I must work within a few parameters set by my employer.
Among those, it must be possible for my team to debug/trace GWT stuff
(Take advantage of the devmode) but while the main application still
runs in tomcat 5.5.26. (-noserver switch). All of this inside the
same Eclipse.

I came close to get this to work, really close, but here's my problem:
The tomcat ClassLoader loads tomcat classes found in gwt-dev.jar
instead of reading its own jar files. If both those tomcats (Mine and
GWT's) were of the same version, I would probably not even know
there's a problem.

This is how i am set up:

1. I have a tomcat installed outside of my project, say, d:/
tomcat-5.5.26
2. I have an eclipse project which was created fully by the GWT
wizard. (say, d:/projects/myproject)
3. I activated the AJDT builder in this project.
Up until here, everything works great, but inside Google App Engine.
(no -noserver switch)

4. I deactivate the Google App Engine (add the -noserver switch)
5. I create a server.xml inside my project, rig everything up
6. I create a Run Configuration this way:
6a. Main class: org.apache.catalina.startup.Bootstrap
6b. Working directory: d:/tomcat-5.5.26/bin
7. I add bootstrap.jar in the classpath of my project.

I try to launch it, bang problems arise because of the mixup. I tried
tampering with the classpath in my Run Configuration to eliminate GWT,
and my tomcat loads allright. (Obviously the GWT classes on the
server-side fail to load since they extend RemoteService, which,
without GWT jars, is not found of course)

I suppose that if the tomcat jars were earlier in the classpath, I
would not have this problem?

A solution for me to try would be to open gwt-dev.jar and erase tomcat
classes. I don't like this solution. Would it even work? Is there a
better way?

Thanks a lot!
Bob

Cristian Nicanor Babula

unread,
Jan 27, 2010, 2:40:27 AM1/27/10
to google-we...@googlegroups.com
Hi,

I actually got lost at the part where you said that you disable the
google appengine server. It doesn't make sense, because if you intend to
deploy your application to an application server not equal to GAE you
must disable GAE support on your eclipse project. In fact, when you
create a GAE project, eclipse copies in your "WEB-INF/lib" jars that I'm
200% sure that would override some of the tomcat's classes.

So, try disabling GAE support for your eclipse project and try again.
Also make sure that in "WEB-INF/lib" you have gwt-servlet.jar

Regards,
Cristian.

Bob Luo

unread,
Jan 27, 2010, 9:13:50 AM1/27/10
to Google Web Toolkit
Hi Cristian,

Thank you for your answer!

You are right, the wizard did copy gwt-servlet.jar in my WEB-INF/lib.

I am sorry if I my post was not 100% clear, as I am new to GWT. This
is what I did: When I created the project, I used Google Web App
Wizard. I UNCHECKED GAE but kept GWT 2.0 CHECKED. Even though I
unchecked GAE at creation, the wizard created a "Web Application"
launch configuration, which I started and it worked.

When I wanted to integrate tomcat in my project, I went in this launch
configuration, I disabled "Embedded Server". I started tomcat and I
have the class path problems.

Bob

Cristian Nicanor Babula

unread,
Jan 27, 2010, 9:23:14 AM1/27/10
to google-we...@googlegroups.com
So it works now?

Bob Luo

unread,
Jan 27, 2010, 8:39:17 PM1/27/10
to Google Web Toolkit
Hi,

No, when I start tomcat from eclipse, it still have errors like:

java.lang.NoSuchFieldError: IS_DIR
at org.apache.catalina.startup.Bootstrap.createClassLoader
(Bootstrap.java:173)
at org.apache.catalina.startup.Bootstrap.initClassLoaders
(Bootstrap.java:98)

or, if I move bootstrap.jar higher than GWT SDK from the Java Build
Path of my project:

java.lang.ClassNotFoundException:
org.apache.catalina.core.AprLifecycleListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

It either finds wrong classes in gwt-dev.jar instead of from jars in
d:/tomcat-5.5.26/bin, d:/tomcat-5.5.26/common/lib or d:/tomcat-5.5.26/
server/lib or does not find classes at all.

I only added bootstrap.jar from the tomcat directory, because it is
the only jar we usually add to our projects.

I added gwt-servlet.jar to the Java Build Path with no difference.

If I add catalina.jar, tomcat-util.jar, catalina-storeconfig.jar to
the Java Build Path, it goes further. I don't like the idea but at
some point, I guess I would get it working if I added ALL the tomcat
jars.

If I completely remove gwt-dev.jar from the run configuration class
path, or if I disable GWT from my project, tomcat starts up no
problem.

Regards,
Bob

Bob Luo

unread,
Jan 29, 2010, 1:00:04 PM1/29/10
to Google Web Toolkit
Hello,

Just to let any reader know, I managed to solve my problem by
separating the backend stuff from the frontend stuff, with the
creation of 2 eclipse projects. I also created a source directory
named "shared" which is imported in both projects.

This way, I fixed every problem I had and would have had in the long
run.

I can:
Run tomcat in debug with the front-end compiled as production (Debug
in backend, no debug in front end) with only the backend project open
Run tomcat in debug with the front-end running in GWT in debug mode
(Debug in both projects means I can debug either side) requires both
projects open
I can easily deploy both sides compiled as production in a stand-alone
tomcat (No Eclipse at all)

We configure JNDI ressources etc, all of this included in Spring, with
AJDT. Using only the Google App Engine in an integrated project would
have come with its set of problems in the long run (I could not find
how to define JNDI ressources in GAE, etc)

We work the same way with our integration with Flex. We are used to
it.

Regards,
Bob

Rajeev Dayal

unread,
Jan 29, 2010, 3:06:53 PM1/29/10
to google-we...@googlegroups.com
Glad you got it working.


Regards,
Bob

--
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.


Reply all
Reply to author
Forward
0 new messages