我在 GWT 编译过程中遇到了这个编译错误。我正在使用它来解析 XML 文档。
[ERROR] Line 24: No source code is available for type org.w3c.dom.Node; did you forget to inherit a required module?
[ERROR] Line 28: No source code is available for type org.w3c.dom.NodeList; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
根据我对此所做的任何研究,它说类路径可能丢失,但由于这将默认包含在 gwt-user.jar 和 JRE7 中,而且我也没有包含任何外部 jar,所以没有重复的情况!你不能在客户端代码中使用这些类型的代码,因为它将被转换为 javascript
我有一个在我的共享文件夹(GWT Model View Presenter Project structure)中使用这个节点的类,它基本上是一个模型!
- 将代码移到服务器端是唯一可能的解决方案吗?
如果 1 为真,我将如何重构我的客户端演示者访问此模型而无需每次都进行 RPC 调用?
是否有其他替代方法?
我的 GWT 配置文件。
<module rename-to='xxxxx'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name="com.google.gwt.xml.XML" />
<entry-point class='com.xxxx.xxxxx.gwt.client.ProjectEntry'/>
<source path='client'/>
<source path='shared'/>
</module>
编辑:我现在已经包含了继承的 xml!它的工作
最佳答案
在您使用 org.w3c.dom.Node 和 org.w3c.dom.NodeList 的代码库的某处,它们未列入白名单。换句话说你不能使用这些类!看;
https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation
您应该将这些包用于 xml;
import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;
关于java - GWT 错误!类型 org.w3c.dom.Node 没有可用的源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11450357/