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.
Related
I am learning GWT and was trying to run this tutorial by Vogella and also the official GWT tutorial.
Using the Eclipse GWT plugin 3.0 on Windows 10 and JDK 11
I marked the Maven Project checkbox.
When I right-click and Run As
Turning off precompile in incremental mode.
Super Dev Mode starting up
workDir: C:\Users\My\AppData\Local\Temp\gwt-codeserver-8137229043727681777.tmp
2021-04-29 12:03:13.494:INFO::main: Logging initialized #718ms
Loading Java files in de.vogella.gwt.helloworld.De_vogella_gwt_helloworld.
[ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
I see that it is inheriting User
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.1//EN"
"http://www.gwtproject.org/doctype/2.8.1/gwt-module.dtd">
<module rename-to='de_vogella_gwt_helloworld'>
<!-- 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.clean.Clean'/>
<!-- <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='de.vogella.gwt.helloworld.client.De_vogella_gwt_helloworld'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
</module>
This SO question was not relevant to my issue.
Almost certainly you are either missing gwt-user.jar from your classpath, or somehow the gwt-user.jar version doesn't match the gwt-dev.jar, which will cause problems. Every module automatically inherits com.google.gwt.core.Core (despite the error message), and as your .gwt.xml shows, you already have User added.
--
Additionally, from your linked SO post, do check the comments - there are some better, more modern tutorials listed.
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.
I am using gwt2.0.3 version in my application.There are two projects in this application.One for client side and other is for server side.In the client side project I have given reference of server side project.So I am able to get all the method and properties of the server side in to the client side.
My all the beans are located at the server side.So while I import beans in the client side then It it not giving any issues.
But at the compile time it is giving issues of referencing.and it is giving issues like below:
[ERROR]
Errors in 'file:/E:/NTWrokSpace1June2011/AdminClient/src/com/nextenders/client/util/factory/DocumentMetadataFactory.java'
[ERROR] Line 26: No source code is available for type com.nextenders.facadeimplementation.beans.metadata.Table; did you forget to inherit a required module?
Hello All
I am using gwt2.0.3 version in my application.There are two projects in this application.One for client side and other is for server side.In the client side project I have given reference of server side project.So I am able to get all the method and properties of the server side in to the client side.
My all the beans are located at the server side.So while I import beans in the client side then It it not giving any issues.
But at the compile time it is giving issues of referencing.and it is giving issues like below:
[ERROR]
Errors in 'file:/E:/NTWrokSpace1June2011/AdminClient/src/com/nextenders/client/util/factory/DocumentMetadataFactory.java'
[ERROR] Line 26: No source code is available for type com.nextenders.facadeimplementation.beans.metadata.Table; did you forget to inherit a required module?
Here AdminClient is my client project.
And com.nextenders.facadeimplementation.beans.metadata package at the server side.And while importing in the class it is not giving nay issues.
But compile time it is giving issues.
Please help me out from this.
I suspect that part of your problem is in your module definition. GWT compiler will look in the source paths you define in your module file to determine which classes to attempt to compile to Javascript. You are likely referencing the Table class from client code, but that bean does not exist in any of the source paths specified in your module xml file.
Having the beans in a separate project may cause issues, but I've not tested it myself. The source paths specified in your module file are relative paths rather than package paths I believe, so it may not work at all.
The error message indicates that the class
com.nextenders.facadeimplementation.beans.metadata.Table;
references (imports) one or more java classes which cannot be compiled to javascript by the gwt.
The normal way would be to split you project into three packages: server, client and shared.
In client you put GWT code, in server obviously server code. In the shared you put code that belong to both client and server: most notably classes that pass RPC.
You have to tell GWT where your sources are then. You must reference those two in your .gwt.xml (if your gwt.xml file is in folder just above client and shared):
<source path='client'/>
<source path='shared'/>
If you use Maven then it will help you.
The maven-gwt-plugin with parameter compileSourcesArtifacts will download -sources.jar and compile GWT module without adding sources to the resulting jar.
Example pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<dependencies>
<dependency>
<groupId>com.my.group</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<!-- ... -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<!-- ... -->
<configuration>
<compileSourcesArtifacts>
<compileSourcesArtifact>com.my.group:my-artifact</compileSourcesArtifact>
</compileSourcesArtifacts>
</configuration>
</plugin>
</plugins>
</build>
</project>
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?
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.