Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to use non-GWT jar in GWT project

 
John Danek
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a GWT application, foo, that imports a jar (bar) I previously made that is solely Java. In the jar, I have a folder src/ in the top level that contains all of the source code. Yet, when I try to build foo, I get the error:

[java] [ERROR] Line 185: No source code is available for type bar; did you forget to inherit a required module?

Since bar is not a GWT application, I don't know what to do. I know using an "inherit" tag would help in foo's foo.gwt.xml, but bar isn't GWT. What to do to get it to work? I've scoured the web and this forum for a solution but have yet to find anything. Is there a way to tell the GWT compilier that the source is located in bar.jar's src/ folder?

Any help is greatly appreciated!
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little rusty here but I will do my best:
In order to be able to use third party code in your GWT client page, GWT should translate it to JavaScript.
So you can take the source you want to use and put it in the directory that GWT will translate it to JavaScript (I don't remember what was its name).
BTW, GWT official docs discuss this pretty well, check it.
 
John Danek
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response!

GWT translates all of the Java source code in the package "client" to JavaScript. In my case, one of these classes uses bar. The project has the jar on its build path, and the jar has the source code in it. I'm just wondering if there's a way to tell GWT that "bar's source code is in bar.jar." That way, everyone implementing my jar in their GWT project doesn't have to manually create a client.bar subpackage and put the source code there.

Anyways, I'm currently trying to just send a RPC to a server where bar will be used, circumventing the need for compiling it in client, but this is rather tedious.

Does anyone know if my wished-for method is possible?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be wrong but as you are using class from boo.jar in you client code, you have to put the source under client directory so GWT can translate it.
 
Federico Kereki
author
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

You must have the source code for the JAR; otherwise, GWT won't be able to compile it into JavaScript.

When you build modules for GWT (GWT code, for use in other GWT projects) you have to include the source code; I dealt with this in Chapter 15, "Modules", in ESSENTIAL GWT.

Hope this helps!
 
Federico Kereki
author
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Danek wrote:
GWT translates all of the Java source code in the package "client" to JavaScript.


Just a little detail: With the latest GWT 2 versions, there's also a "shared" package, for code that is supposed to be used both client- and server-side.

Hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic