How to exclude server-side jar file from GWT compile / validation

179 views
Skip to first unread message

Rob Wood

unread,
Jan 6, 2010, 12:23:49 PM1/6/10
to Google Web Toolkit
In my GWT app my RemoteService implementation executes code from
abc.jar that has server-side only Java code. I have included abc.jar
in my project's class path, but it does not belong to any module
inherited by this project's module. When I run this app in Hosted
Mode I get tons of Error messages in the console for classes in
abc.jar, such as: Validating newly compiled units ... No source code
is available for type ...; did you forget to inherit a required
module?

Since these classes are server-side only the GWT compiler should not
be considering them at all. What is curious is that on the server
side also I'm using some Spring jar files and GWT does not complain
about these. The application runs in spite of these errors, but
writing them to the console really slows down debugging.
My environment: GWT 2.0, Eclipse 3.5 (SpringSource Tool Suite), JDK
1.5

Thanks for any guidance you can give me.

Rohit Bansal

unread,
Jan 6, 2010, 1:03:21 PM1/6/10
to Google Web Toolkit
Hi

I think there are client packages in your abc.jar. And GWT is giving
you warning about these client packages as on server there should not
be client packages.

Regards

Rohit

Rob Wood

unread,
Jan 6, 2010, 4:10:55 PM1/6/10
to Google Web Toolkit
The abc.jar does not include any client packages as far as I can
tell.

Since the above post I've changed this project so that a few files
from abc.jar now implement IsSerializable so they can be passed to the
client. As a result, abc is now a GWT module which I import into my
GWT app. Most of the functionality in abc.jar, however, is strictly
server side.
When I try to GWT compile my GWT app (using mvn gwt:compile) I now get
lots of import errors such as: No source code is available for type
java.io.InputStream; did you forget to inherit a required module?

This problem just became more urgent now as I cannot deploy to Tomcat
to test there.

Any help on this would be greatly appreciated.

Open eSignForms

unread,
Jan 6, 2010, 4:58:04 PM1/6/10
to google-we...@googlegroups.com
On Wed, Jan 6, 2010 at 1:10 PM, Rob Wood <rob.a...@gmail.com> wrote:
The abc.jar does not include any client packages as far as I can
tell.

Since the above post I've changed this project so that a few files
from abc.jar now implement IsSerializable so they can be passed to the
client.  As a result, abc is now a GWT module which I import into my
GWT app.  Most of the functionality in abc.jar, however, is strictly
server side.

If you can "pass to the client" then it should be in the client package.  All classes referenced by code in the client classes must be available to the client, and thus must be translated to javascript, etc.  The fact that you didn't put it in the client package is why it's complaining it can't find the code.

So I'd recommend putting anything with IsSerializable (or otherwise is referenced by client code -- even if you just pass the object into a client constructor and otherwise don't send it directly) in the client package so it can be compiled.

Rob Wood

unread,
Jan 6, 2010, 5:40:24 PM1/6/10
to Google Web Toolkit
OK, I see I mispoke, causing some confusion. The classes that are
passed to the client are not in the client package, but in abc's
gwt.xml I use the <source> tag to tell GWT where to find them.
These classes are passing through to the client just fine when I run
in Hosted Mode. The problem is when I run gwt:compile to deploy to
Tomcat (running in production, for instance) I get errors due to
external dependencies which are server-side only: dependencies on
java.io.InputStream, and SimpleDateFormat. How can I get GWT compiler
to ignore these?


On Jan 6, 2:58 pm, Open eSignForms <yoz...@gmail.com> wrote:

Open eSignForms

unread,
Jan 6, 2010, 6:10:43 PM1/6/10
to google-we...@googlegroups.com
Without knowing your code, I cannot be sure, but somehow those classes are being referenced directly or as parameters something in your client classes.  All references in the client code must be translatable, and most likely neither InputStream nor SimpleDateFormat are.  So your client classes must not have any references to them.

Rob Wood

unread,
Jan 6, 2010, 6:49:17 PM1/6/10
to Google Web Toolkit
I've done some further analysis: I'm only getting errors for server
side classes that have a reference to one of the classes implementing
IsSerializable (either directly or through inheritance). GWT Compiler
does not complain about the classes implementing IsSerializable (or
their child classes) or classes with no references to a class
implementing IsSerializable.
Meanwhile, I've confirmed that the only classes the the client code
sees are the few classes implementing IsSerializable. The fact that
this runs successfully in Hosted Mode verifies that as well.

Perhaps there is some kind of compiler configuration that is set too
aggressively. I'm pretty confident that I was able to GWT compile
this project using GWT 1.7.1 because I successfully deployed to
Tomcat. Was there a change from GWT 1.7.1 to 2.0 that might explain
this?

Reply all
Reply to author
Forward
0 new messages