how to make gwt eclipse plugin compiler see other projects

341 views
Skip to first unread message

Joe Hudson

unread,
Apr 17, 2009, 1:10:50 AM4/17/09
to Google Web Toolkit
Hi,

I have a separate eclipse project containing code used on the server-
side of the RPC. When I use the google plugin to recompile my GWT
app, I get the error messages saying that the source code can't be
found. I can get this to work by exporting the project to a jar (with
source) and referencing the jar (as opposed to the project directly)
in the classpath of the GWT project.

This is do-able but I would really like to know if this is possible
and if there is anything special that has to be done for the plugin to
recognize the source from another project.

I am pretty sure that the plugin sees the classpath as it is not
giving an error that the imported gwt.xml file can not be found.

Thank you very much for any help you might have to offer.

Joe

Salvador Diaz

unread,
Apr 17, 2009, 4:13:56 AM4/17/09
to Google Web Toolkit
Add the other project to the classpath instead of adding the jar

Joe Hudson

unread,
Apr 17, 2009, 8:31:27 AM4/17/09
to Google Web Toolkit
Thank you Salvador for your reply,

I am have tried that (I think) and that was when I experience
described above. Please let me explain how I am doing that because
maybe I am doing something wrong:

1) Open the Run Configurations menu
2) Select my target under "Web Application" (with the google icon)
3) Go to the "Classpath" tab, select "User Entries", click "Add
Project" and select my project
4) Go to the "Source" tab, click "Add", select "Java Project" and
select my project
5) Click "Apply"

So, this is what I have tried and I get errors when I start up the app
that it can not find the source of the classes from my server
project. Any ideas?

Thanks

Joe

Salvador Diaz

unread,
Apr 17, 2009, 8:38:50 AM4/17/09
to Google Web Toolkit
Try adding the source folders directly to the classpath (remember that
GWT needs the java source to all the objects that will be compiled to
javascript) because I think that adding the project just adds the
default output folder to your classpath:
1) Open the Run Configurations menu
2) Select my target under "Web Application" (with the google icon)
3) Go to the "Classpath" tab, select "User Entries", click "Advanced"
and select "folders" and add the root source folder of your other
project here
5) Click "Apply"

Let me know if it helps,

Salvador

Jason Parekh

unread,
Apr 17, 2009, 11:19:15 AM4/17/09
to Google-We...@googlegroups.com
Hey Joe,

It looks like you're hitting an issue where the Eclipse plugin does
not include a dependent project's compiled classes into the packaged
WAR that is deployed to the server. We're aware of the issue and it
will be fixed in a future release.

There are a couple workarounds, one of which you've tried (package the
dependent project into a JAR, and statically link that into the main
project). The other is to set the dependent project's output
directory to the main project's output directory. When the hosted
mode server runs (or the app engine tools upload to app engine), all
classes in this directory will be included (including the dependent
project's).

jason

Jason Parekh

unread,
Apr 17, 2009, 11:31:56 AM4/17/09
to Google-We...@googlegroups.com
BTW, another related issue when dealing with dependent projects is
ensuring GWT inheritance is defined properly.

For example, imagine project A has a GWT module MA and project B has a
GWT module MB. If the types in MA refer to the types in MB then MA
must inherit from MB.

To properly configure, please ensure that:
- the Java project A depends on the Java project B in Eclipse, and
- MA's XML file declares its inheritance of MB

jason

Ivan M

unread,
May 4, 2009, 8:23:01 AM5/4/09
to Google Web Toolkit
Could you (or somebody) be more specific about this?. I can't run the
project in hosted mode, I get the following error:

java.lang.IllegalStateException: No such servlet: GwtLoginService

The service is in another project and it looks like it isn't started
when starting the main project. I have ticked the GwtLogin in
Eclipse's Project References of the main project. Also, I have added
this to the "web.xml" of the main project:

<servlet>
<servlet-name>gwtLoginServiceImpl</servlet-name>
<servlet-class>x.gwtlogin.server.GwtLoginServiceImpl</servlet-
class>
</servlet>

<servlet-mapping>
<servlet-name>GwtLoginService</servlet-name>
<url-pattern>/gwtlogin/GwtLoginService</url-pattern>
</servlet-mapping>

I have copied the module from GwtLogin to the main project, excluding
the server implementation.
Thank you,
Ivan
> >> So, this is what I have tried and I get errors when Istartup the app
> >> that it can not find the source of the classes from my server
> >> project.  Any ideas?
>
> >> Thanks
>
> >> Joe
>
> >> On Apr 17, 4:13 am, Salvador Diaz <diaz.salva...@gmail.com> wrote:
> >>> Add the other project to the classpath instead of adding the jar
>
> >>> On Apr 17, 7:10 am, Joe Hudson <joe...@gmail.com> wrote:
>
> >>> > Hi,
>
> >>> > I have a separate eclipse project containing code used on the server-
> >>> > side of the RPC.  When I use the google plugin to recompile my GWT
> >>> > app, I get the error messages saying that the source code can't be
> >>> > found.  I can get this to work by exporting the project to a jar (with
> >>> > source) and referencing the jar (as opposed to the project directly)
> >>> > in the classpath of the GWT project.
>
> >>> > This is do-able but I would really like to know if this is possible
> >>> > and if there is anything special that has to be done for the plugin to
> >>> > recognize the source from another project.
>
> >>> > I am pretty sure that the plugin sees the classpath as it is not
> >>> > giving an error that the imported gwt.xml file can not be found.
>
> >>> > Thank you very much for any help you might have to offer.
>
> >>> > Joe- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

Rajeev Dayal

unread,
May 4, 2009, 12:18:22 PM5/4/09
to Google-We...@googlegroups.com
Hi Ivan,

As Jason mentioned below, there is an issue where the Google Eclipse Plugin does not automatically copy the artifacts from web app projects that your project depends on into the server's WEB-INF/lib directory. This means that classes from these projects will not be available to the server at runtime, which is why you're getting a "No Such Servlet" error.

We're planning on addressing this in a future version of the plugin. For now, you can work around the problem via the suggestions that Jason mentioned.


Rajeev

John

unread,
May 15, 2009, 2:13:27 PM5/15/09
to Google Web Toolkit
Could anyone elaborate on the setting the dependent project's output
directory technique?

Right now I have set my dependent project's output directory to be the
war/WEB-INF/classes directory of my main project. Additionally, I
have added the dependent projects source to MainProject/Properties/
Java Build Path/Source Tab via the "Link Source" button and to
MainProject/Debug Configurations/My Main Configuration Name/Source
Tab. I have also added my dependent project to my main project's
build path just for good measure. However, I am still getting the "No
source code is available for type
class.found.in.dependent.project.Name" errors.

This method doesn't seem like it would work anyway because all I am
doing is including the class files in the project and not the java
source code, which is what the error message claims it is missing in
the first place.

I am going to attempt the jar file technique since that is known to
work.

Lastly, is there any place I can check periodically to see if this bug
has been fixed so that I will know when I can stop trying to
workaround this bug?

Thanks,
John

Tim McCormack

unread,
May 15, 2009, 2:52:38 PM5/15/09
to Google Web Toolkit
On May 15, 2:13 pm, John <john.set...@gmail.com> wrote:
> I am going to attempt the jar file technique since that is known to
> work.

I'm encountering the same issue. Can you explain exactly what you are
doing with the Jar file approach?

- Tim McCormack

John

unread,
May 15, 2009, 3:49:00 PM5/15/09
to Google Web Toolkit
Disregard my previous post I figured out what was wrong. Both Jason's
jar method and the output folder method work.

I have two different modules in my main project only one of them uses
a java references to my dependent project. However in order to get
GWT to compile I had to put <inherits> tags to my dependent project in
both modules. When I reexamined the compile log I realized that the
module I thought wasn't compile was and the module that shouldn't care
about my dependent project was not compiling.



On May 15, 2:13 pm, John <john.set...@gmail.com> wrote:

John

unread,
May 15, 2009, 3:58:44 PM5/15/09
to Google Web Toolkit
Tim,

Jar Method:
1. Remove any Buid Path references between your two projects.
2. Build a jar file from your project that is a dependency. Make sure
to check the boxes that say "Add directory entries" and "Add Java
Source...".
3. Add this jar file to your main projects build path.
4. Try to compile GWT.

John

unread,
May 15, 2009, 4:48:58 PM5/15/09
to Google Web Toolkit
Version 1.0.1 released two days ago partially fixes this issue.

Check out Rajeev's post on this thread
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/46cf35719329b30

Tim McCormack

unread,
May 15, 2009, 4:59:22 PM5/15/09
to Google Web Toolkit
On May 15, 3:58 pm, John <john.set...@gmail.com> wrote:
> Jar Method:
> 1. Remove any Buid Path references between your two projects.
> 2. Build a jar file from your project that is a dependency.  Make sure
> to check the boxes that say "Add directory entries" and "Add Java
> Source...".
> 3. Add this jar file to your main projects build path.
> 4. Try to compile GWT.

Thanks for the walkthrough, John, but compile still fails with the
same errors as before:

"No source code is available for type com.example.shared.Foo; did you
forget to inherit a required module?"

Maybe GWT can only see other GWT projects?

- Tim McCormack

Donald.W.Long

unread,
May 15, 2009, 9:15:45 PM5/15/09
to Google Web Toolkit
I had the same issue.

First lets look at the depent project.

You must create this project as a GWT project.

You must also remove the entry point in the application. Remember
this is a library.

Then create your jar file for this project.

On the primary project you must not set the other project as a
dependancy,

Just add the jar file as an external jar file to your project. I
recommend that you move the jar file to the lib of your war directory.

The inherits is strange. If you have the following project

package com.thelongsfamily.ButtonMenu.client;

then the inherits is done as below.

<inherits name='com.thelongsfamily.ButtonMenu.ButtonMenu'/>

this took me a while to figure out also.

then in your your build path add the jar file as an external jar and
also do not forget to set the order and export area. Mark the jar
file as an export.

This is what I did and its worked very nice.


Hope this helps.

Donald W. Long

Tim McCormack

unread,
May 16, 2009, 4:16:12 PM5/16/09
to Google Web Toolkit
On May 15, 9:15 pm, "Donald.W.Long" <donald.w.l...@thelongsfamily.com>
wrote:
> First lets look at the depent project.
>
> You must create this project as a GWT project.

But then I can't choose the package name I want, correct? It'll be
something.client, right?

Salvador Diaz

unread,
May 17, 2009, 6:37:23 AM5/17/09
to Google Web Toolkit
Hi Tim,

> But then I can't choose the package name I want, correct?

No, you're wrong, you can choose whatever package name you want, as
long as you specify in your module definition which one it is. Read
the following section of the developer's guide:
http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html#DevGuideModuleXml
And take a look at the 3rd bullet point of the section called "XML
Element reference"

Hope that helps,

Salvador

Dan Batten

unread,
Jun 17, 2009, 6:15:26 AM6/17/09
to Google Web Toolkit
Hi All,

Just wanted to share my experience because I've got things working.

I have 2 eclipse projects:

1) webgwt - main app
2) dtos - contains only dtos

Both projects have *.gwt.xml files configured as per the google
documentation:

http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html#DevGuideModuleXml

To get this working in HostedMode I did the following:

1) added the root src folder to the 'Run Configuration' of webgwt
under the 'User Entries' of the 'classpath' tab
2) in the 'Project Properties' of webgwt I added the output folder of
'dtos' to the project libraries: 'Libraries' -> 'Add Class Folder' ->
Folder
3) back in 'Run Configuration' -> 'User Entries', I made sure that the
src entries was above the output folder.
4) updated the compile.cmd to include the path to the 'dtos' src,
which in my case was '..\dtos\src'
- obviously this is only needed when compiling the code.

I did NOT add the 'dtos' to the 'Projects' tab of webgwt.

Hope this helps.

Cheers,
Dan.

On May 17, 8:37 pm, Salvador Diaz <diaz.salva...@gmail.com> wrote:
> Hi Tim,
>
> > But then I can't choose the package name I want, correct?
>
> No, you're wrong, you can choose whatever package name you want, as
> long as you specify in your module definition which one it is. Read
> the following section of the developer's guide:http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects....
Reply all
Reply to author
Forward
0 new messages