GWT第三方库问题:包含代码

GWT第三方库问题:包含代码,gwt,jar,Gwt,Jar,我正在使用Eclipse版本:3.5.1、GWT 2.0.0、GAE 1.3.0,并且我正在尝试使用XStream 1.3.2在GWT的客户端和服务器端之间“序列化”我的Java对象与xml之间的关系 在服务器端,XStream可以正常工作 在客户端,编译器抱怨无法找到所用XStream类的源代码。我知道这是一种“引用”问题,GWT客户机类无法自动找到服务器类,我也明白这是为什么。然而,当我尝试使用各种文章和教程中描述的方法时,我渐渐发疯了,这些文章和教程介绍了如何在GWT中使用第三方库 他们都

我正在使用Eclipse版本:3.5.1、GWT 2.0.0、GAE 1.3.0,并且我正在尝试使用XStream 1.3.2在GWT的客户端和服务器端之间“序列化”我的Java对象与xml之间的关系

在服务器端,XStream可以正常工作

在客户端,编译器抱怨无法找到所用XStream类的源代码。我知道这是一种“引用”问题,GWT客户机类无法自动找到服务器类,我也明白这是为什么。然而,当我尝试使用各种文章和教程中描述的方法时,我渐渐发疯了,这些文章和教程介绍了如何在GWT中使用第三方库

他们都不工作

我的gwt.xml文件如下所示:

<?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>
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
我更熟悉Netbeans,因此我可能设置不正确,但我认为我已经将XStream作为第三方库包含在我的eclipsegwt项目中,并且正确地引用了二进制jar、源jar和javadoc jar

引发错误的客户端方法:

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();

}
和GWT编译器错误:

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
我不知道你还需要什么信息来帮助我,但如果你需要我没有提供的信息,请询问


感谢您阅读本文:-)

您不需要在gwt.xml文件中导入XStreams包。例如,类似于:

<inherits name='com.thoughtworks.xstream'/>


您不需要在gwt.xml文件中导入XStreams包吗。例如,类似于:

<inherits name='com.thoughtworks.xstream'/>


?GWT将Java源代码编译为JavaScript。你不能只指向一个普通的罐子。如果确实必须使用XStream,则需要在客户机包下包含源代码,或者创建一个单独的模块并导入它


但对我来说,这只是重新发明轮子。您将有大量的工作,它将比RPC慢。即使有其他客户使用XML输出,也可能要考虑两种方式。

GWT将java源编译成JavaScript。你不能只指向一个普通的罐子。如果确实必须使用XStream,则需要在客户机包下包含源代码,或者创建一个单独的模块并导入它


但对我来说,这只是重新发明轮子。您将有大量的工作,它将比RPC慢。即使有其他客户机使用XML输出,也许您应该考虑两种方式。

使用继承的标记,编译器说:加载继承的模块“COM.DeavtWorks.xStuts[[错误] ],无法在类路径上找到“COM/DeavtWorks/xStudio.GWT.xml”;可能是输入错误,或者您忘记了包含源代码的类路径条目?好的,我不是GWT专家,但我认为jar需要源代码(GWT编译器需要)和xml文件。有关更多信息,请参阅此博客()。包含inherits标记后,编译器会说:加载继承模块'com.thoughtworks.xstream'[错误]在类路径上找不到'com/thoughtworks/xstream.gwt.xml';可能是输入错误,或者您忘记了包含源代码的类路径条目?好的,我不是GWT专家,但我认为jar需要源代码(GWT编译器需要)和xml文件。有关更多信息,请参阅此博客()。