Adding jars to GWT project - gwt

this may be a stupid question but after 30minutes of Googleing, I still havent found an answer..
I want to build the example program "gwt-beans-binding" ( http://code.google.com/p/gwt-beans-binding/.
I download the *jar file and copied it into the the lib folder and added it to Properties-->Java Build Path -- >Libaries --> Add JARs.
When I'm build the project, I'm geting "java.lang.ClassNotFoundException"s...
What am I missing (do I have to write something in the *.gwt.xml?

For building inside Eclipse it should be enough with adding the library jar to the Libraries. But for GWT compiling (or executing inside Developer Mode) your module file (*.gwt.xml) has to point to the library module file. The library module file will say where the GWT source code is located.
<!-- this will declare where the source code is for the library GWT classes -->
<inherits name='org.gwt.beansbinding.Main' />
<!-- OR THIS... I don't really know -->
<inherits name='org.gwt.beansbinding.BeansBinding' />

The GWT compiler needs the sources to comile Java code to JavaScript. So you have to add the source folder to the class path too.
Can you give us the full stacktrace, what class is missing?

Related

.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

I am new to Gwt i am trying to create a web application and invoke it using an maven plugin. But the problem is during invocation of code server i am getting an error like unable to find xxxx..gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source? I have tried to add the .gwt.xml file into class path in serveral ways like include additional classpath etc.., but nothing helps... is there is any way to add it to the maven class path.
It seems that the gwt-maven-plugin is not able to find the configured module.
Please see the configuration of this plugin in the pom.xml, i.e. the section:
<modules>
<!-- this refers to xxxx..gwt.xml -->
<module>xxxx</module>
</modules>
If you cant resolve the problem you could compare your project with a minimal working "Hello-World-GWT-Project".
You could create such a template-project with a maven archetype:
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.7.0

GWT Compiler cannot find Collect.gwt.xml, but I have Guava as a dependency

I'm moving over to a new computer, and in the processing I'm creating new Intellij 12 projects from my git source.
I have a gwt module file containing the following:
<!-- Other module inherits -->
<inherits name="com.google.common.collect.Collect" />
<inherits name="com.google.common.base.Base" />
<inherits name="com.bdl.message.Message" />
<inherits name="com.bdl.universal.Universal" />
<inherits name="com.bdl.appengine.AppEngine" />
<inherits name="com.bdl.gwt.BdlGwt" />
<inherits name="com.google.gwt.inject.Inject"/>
The com.bdl.* entries are from another library I've written and I have their jar files (and sources) in the module dependencies. I can confirm that removing those dependencies causes the corresponding inherits nameto turn red, indicating an error.
I also have as a dependency, a global library Guava (GWT) which contains:
classes:
guava-14.0-rc2.jar
sources:
guava-14.0-rc2-sources.jar
guava-gwt-14.0-rc2.jar
javadoc
guava-14.0-rc2-javadoc.jar
But despite this, the inherits for Collect and Base are red and the GWT compiler fails, saying it can't find Collect.gwt.xml.
On my old system I have an Intellij 11 project, which is set up the same way (there must be some difference somewhere, but I've been looking for hours to find it and can't)
That also has the same library as a dependency, and the inherits lines in my app's module are still red, but the GWT compiler succeeds, finding the Collect.gwt.xml right where it should be, at:
jar:file:/[path-to-guava]/guava-gwt-14.0-rc2.jar!/com/google/common/collect/Collect.gwt.xml
There must be something simple and stupid that I'm missing, but I can't find it.
You probably need to add guava-gwt-14.0-rc2.jar to your dependencies. Notice that the name has -gwt- embedded in it and you said that you have just these as dependencies:guava-14.0-rc2.jar sources: guava-14.0-rc2-sources.jar guava-gwt-14.0-rc2.jar javadoc guava-14.0-rc2-javadoc.jar
You can check that the jar is the appropriate one because when you open it (it is just a zip file) you should see the Collect.gwt.xml file somwhere within.

Adding external jar in GWT

I have a jar file with source code packed.
i inserted the jar in war/WEB-INF/lib/xxx.jar Add to build path
but when i run the project i got an error
Edited Added gwt.xml
<module rename-to='bookmanagementsystem'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name='com.example.Book'></inherits>
<entry-point class='com.example.Book.client.Index'/>
</module>
Edited
I solved
Plugin failed to connect to Development Mode server at 127.0.0.1:9997
Now i got a problem
Loading inherited module 'com.example.book'
[ERROR] Unable to find 'com/example/book.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 6: Unexpected exception while processing element 'inherits'
If you want to include external jar to GWT then make sure you did the following
check the jar has .gwt.xml file and it must specify the source.
add it to lib folder
configure build path and add jar to libraries
select the jar from Order and Export
inherits this module in your .gwt.xml file
Eg. if you have a package in jar named "sample.source" and your .gwt.xml file in jar is "Source.gwt.xml" and this .gwt.xml file in "sample" folder and classes or entities in "source" folder
Then your current project must inherits it. ie it must have the following tag
<inherits name='sample.Source'/>
Eg :
Sorce.gwt.xml in jar file
<module>
<source path="">
<include name="**/MyEntity.java"/>
</source>
</module>
For reference :http://jonathan.lalou.free.fr/?p=1077
GWT is not supporting serialization in client side so try to use RPC and use these classes from jar in server or you just copy the packages of jar and add to src of gwt project.
OR
I solved the problem the jar files must have java source code along with class files or pack java source code into jar and use.

how do I force the compilation of a widgetset in Vaadin?

I am trying to use the sparklines add on in my application. However, eclipse systematically refuses to compile the corresponding widgetset, i.e. if I specify the inherit tag in my widgetset that refers to the sparklines widgetset as follows:
<inherits name="org.vaadin.artur.icepush.IcepushaddonWidgetset" />
<inherits name="org.vaadin.hezamu.googlemapwidget.widgetset.GooglemapwidgetWidgetset" />
<inherits name="org.vaadin.sparklines.SparklinesWidgetset" />
<inherits name="com.fluxtream.widgets.FluxtreamwidgetsWidgetset" />
...eclipse complains with the following error:
Loading inherited module 'com.fluxtream.widgets.FluxtreamwidgetsWidgetset'
Loading inherited module 'com.fluxtream.dashboard.widgetset.FlxDashboardWidgetset'
Loading inherited module 'org.vaadin.sparklines.SparklinesWidgetset'
[ERROR] Unable to find 'org/vaadin/sparklines/SparklinesWidgetset.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 26: Unexpected exception while processing element 'inherits'
However, I have verified that the widgetset was indeed declared as a dependency in my project's pom, and I have also verified that it appears under the "Maven Dependencies" library icon in the eclipse IDE.
Also, whenever I attempt to recompile my widgetset, and after the aforementioned error is displayed, I can see that my original widgetset.gwt.xml file has been modified, and as a result would look as follows:
<inherits name="org.vaadin.artur.icepush.IcepushaddonWidgetset" />
<inherits name="org.vaadin.hezamu.googlemapwidget.widgetset.GooglemapwidgetWidgetset" />
<inherits name="com.fluxtream.widgets.FluxtreamwidgetsWidgetset" />
<inherits name="com.fluxtream.dashboard.widgetset.FlxDashboardWidgetset" />
I'm really confused, as I don't understand what I am doing wrong. I am using other add-ons which work just fine (icepush and googlemap) and I really don't understand what I am doing wrong here.
The Vaadin Eclipse plugin manages your gwt.xml, that is why it is modifies if you add/remove add-on from classpath.
Basically this means that you don't have to modify the gwt.xml by hand, if working in Eclipse. Furthermore, the Eclipse plugin does not know anything about maven (or pom files) and any information in those does not affect to it.
You can compile the widgetset two ways. First with the Eclipse plugin (the button on toolbar) or with maven. This sounds that you are mixing those.
Easiest setup is to put all add-on jars to WEB-INF/lib and use the eclipse plugin to compile the widgetset. The gwt.xml should be automatically updated, but sometimes a refresh (or jar remove/add procedure) is needed to let the plugin notice change.
Also, check the Vaadin settings in project preferences are the way you want.

GWT 3rd Party Library Problem : Code Included

I am using Eclipse Version: 3.5.1, GWT 2.0.0, GAE 1.3.0 and I am trying to use XStream 1.3.2 to 'serialize' my Java objects to and from xml between the client and server sides of GWT.
On the server side, XStream works without issue.
On the client side, the compiler complains that it cannot find source code for the XStream classes used. I understand that this is some sort of 'referencing' issue where GWT client classes cannot automatically find server classes and I understand why this is however, I am going slowly insane as I try to use the approaches described in various articles and tutorials that cover how to use 3rd party libraries in GWT.
None of them work!
My gwt.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='bandmates'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.redboffin.bandmates.client.BandMates' />
</module>
My Eclipse XStream Library is as follows:
XStream
|__ Access rules : No rules defined
|__ Native library location: (None)
|__ xstream-1.3.2.jar [path to jar]
|__ Source Attachment: xstream-1.3.2-sources.jar [path to source jar]
|__ Javadoc location: [path to javadoc]
|__ Native library location: (None)
|__ Access rules : No restrictions
I am more familiar with Netbeans and so I may be setting this up incorrectly, but I think I have included XStream into my Eclipse GWT project as a third party library and have correctly referenced the binary jar, the source jar and the javadoc jar
The client side method that throws the error:
public void onSuccess(String profilesXml) {
// Deserialize the xml
XStream xstream = new XStream(new DomDriver());
ProfilesImpl profiles = (ProfilesImpl) xstream.fromXML(profilesXml);
// Show the RPC result to the user
this.friendsWidget.setFriendProfiles(profiles);
this.friendsWidget.update();
}
And the GWT Compiler error:
Compiling module org.redboffin.bandmates.BandMates
Validating newly compiled units
[ERROR] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/BandMates/src/org/redboffin/bandmates/client/widgets/FriendsWidget.java'
[ERROR] Line 63: No source code is available for type com.thoughtworks.xstream.XStream; did you forget to inherit a required module?
[ERROR] Line 63: No source code is available for type com.thoughtworks.xstream.io.xml.DomDriver; did you forget to inherit a required module?
Finding entry point classes
[ERROR] Unable to find type 'org.redboffin.bandmates.client.BandMates'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
I'm not sure what other information you may need to help me but if you need something I haven't provided then please ask.
Thanks for reading this far :-)
Don't you need to import your XStreams package in your gwt.xml file. E.g. something like:
<inherits name='com.thoughtworks.xstream'/>
?
GWT compiles Java source to JavaScript. You canĀ“t just point to a regular jar. If you really must use XStream, you will need to include the sources under the client package or create a separate module and import it.
But for me this is just reinvent the wheel. You will have a lot of work and it will be slower than RPC. Even if there are other clients using the XML output, maybe you should consider having both ways.