GWT 程序中的错误

Posted

技术标签:

【中文标题】GWT 程序中的错误【英文标题】:errors in GWT program 【发布时间】:2011-12-09 23:36:57 【问题描述】:

我正在开发一个简单的应用程序(使用 GWT RPC 和 Hibernate)将数据插入数据库并检索。添加用户方法效果很好。

现在我编写了一个从数据库中检索数据并显示的方法。将模块加载到浏览器中时会引发源路径错误。

eclipse中project的结构是:

-src
-user.hbm.xml
-hibernate.cfg.xml
   ->rpctest
     ->Rpctest.gwt.xml  
   ->rpctest.hibDomain
     ->User.java
   ->rpctest.client
     ->Rpctest.java
     ->service interfaces
   ->rpctest.server
     ->service implementation
     ->HibernateUtil.java

这是堆栈跟踪:

    [DEBUG] [rpctest] - Validating newly compiled units
[TRACE] [rpctest] - Finding entry point classes
    [ERROR] [rpctest] - Unable to find type 'rpctest.client.Rpctest'
        [ERROR] [rpctest] - Hint: Previous compiler errors may have made this type unavailable
        [ERROR] [rpctest] - 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
[ERROR] [rpctest] - Failed to load module 'rpctest' from user agent 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)' at 127.0.0.1:49465

Rpctest.gwt.xml

   <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='rpctest'>
  <!-- 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='rpctest.client.Rpctest'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='rpctest.client.Rpctest'/>
  <source path='server'/>
  <source path='hibDomain.User'/>


 </module>

【问题讨论】:

你能粘贴 User 类吗? 【参考方案1】:

hibDomain 包中的 User 类不包含在你的 gwt 源路径中

您可以通过在您的 gwt xml 文件中添加 gwt 编译器应转换为 javascript 的类来配置它们。查看文档:http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml

【讨论】:

我在 'Rpctest.gwt.xml' 中将 'User' 类添加到 GWT 项目中,如 ,其中 'rpctest' 是 src 下的包& hibDomain 是包含用户类文件的文件夹。但同样的错误正在引发。 源路径是相对于你的 gwt xml 文件的 我现在把它变成了“hibDomain.User”。因为包含“User.java”的“hibDomain”文件夹和包含“gwt.xml”的“rpctest”文件夹都在“src”文件夹中。但同样的错误:( 虽然这个问题仍有待解决,但我知道错误的原因,即通过您的回答源路径参数。当我打开一个新线程时,我最好关闭这个线程。谢谢丹尼尔的帮助。

以上是关于GWT 程序中的错误的主要内容,如果未能解决你的问题,请参考以下文章

GWT 应用程序编译问题 - 错误,状态 503

GWT 中的 PropertyChangeSupport

gwt编译错误

如何修复多项目 GWT 设置中的 RPC 错误 IncompatibleRemoteServiceException?

GWT RPC 上的错误 404

gwt rpc 调用的零星 502 错误