myahya
myahya

Reputation: 3181

Referencing An Eclipse Java Project from a GWT Project

I have a java project already in eclipse, and I need to use the classes there in the server code of my GWT project, also in eclipse. I have a package, let's call it com.example with lots of subpackages.

I followed the instructions here: Eclipse 3.4 GWT 1.6 project - how to reference source from other projects? by defining the following file in the root package

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='example'>
    <inherits name='com.google.gwt.user.User' />
    <source path="*" />
</module>

and in GWT XML file, I added

<inherits name="com.example" />

But I keep getting

java.lang.NoClassDefFoundError

for classes defined in com.example

Any idea what I am doing wrong?

Upvotes: 1

Views: 212

Answers (2)

Kurtcebe Eroglu
Kurtcebe Eroglu

Reputation: 1954

I have a similar project setup, except I'm using get 2.3, and it works without problems. But I get warning messages as below;

 [WARN] Server class '<CLASS_IN_OTHER_PROJECT>' could not be found in the web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/workspace/<OTHER PROJECT>/src/' to the web app classpath for this session
For additional info see: file:/Downloads/gwt-2.3.0/doc/helpInfo/webAppClassPath.html

May be you are using an older version of gwt which does not have the above workaround put in place. You may check info mentioned in above warning message here.

At sum, it is stated that;

All server classes and dependencies should to be placed in your war directory: libraries (jars) should be placed in war/WEB-INF/lib/ and classes that don't live in jars should be placed in war/WEB-INF/classes/.

So I guess you won't have problems if you export your utility project (the one to which you depend for server side classes) as a jar file and drop it into war/WEB-INF/lib/ folder of your module.

Upvotes: 0

Thomas Broyer
Thomas Broyer

Reputation: 64541

If you only want to reference classes for use on the server-side (i.e. not by GWT actually), then you don't need all that stuff. The GWT modules are only about client-side code to be processed by the DevMode and ultimately the GWT Compiler.

Upvotes: 2

Related Questions