我开始将GWT用于类项目,并想知道RPC的实际用例。所以,我在同一个网站上找到了这个例子:Stack Overflow - Simple RPC Use Case Problem (Code Included)
为什么我这样做?因为我收到了用户在我自己的项目上发布的相同错误,我决定尝试在我的计算机上查看他的代码,看看我是否真的可以面对自己的错误。
所以关键是在复制Eclipse GWT项目上的文件并部署应用程序后,我在运行时遇到了两个错误:
第一次错误
12:14:07.874 [ERROR] [test] Line 17: No source code is available for type com.google.gwt.user.server.rpc.RemoteServiceServlet; did you forget to inherit a required module?
第二次错误
12:42:54.547 [ERROR] [test] Unable to find type 'org.redboffin.worldhug.client.test.Test'
12:14:09.341 [ERROR] [test] 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
所以我试图纠正 Test.gwt.xml ,就像Craig在帖子上建议的那样。不幸的是,这个解决方案对我不起作用,因为我仍然遇到同样的错误。
第一个错误:我不知道发生了什么,因为,例如,在描述的文件中,RemoteServiceServlet之前导入了一些行(尽管没有看到)。该文件位于“org.redboffin.worldhug.server.test;”
包中第二个错误:如果发布初始线程的用户不需要在项目中“继承”新包,我就无法理解为什么需要它们。无论如何,我把一个新的继承行放在.gwt.xml文件中:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='test'>
<inherits name="com.google.gwt.user.User" />
<entry-point class="org.redboffin.worldhug.client.test.Test"></entry-point>
<source path="client" />
<source path="shared" />
<inherits name="org.redboffin.worldhug.client.test.Test" />
</module>
这就是我得到的:
Loading inherited module 'org.redboffin.worldhug.client.test.Test'
[ERROR] Unable to find 'org/redboffin/worldhug/client/test/Test.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
(当然,它没有编译)
所以,我真的不知道发生了什么。请问有人能为这个问题带来一些启示吗?为什么这不起作用?我做得不好?第二个错误需要什么类型?
答案 0 :(得分:3)
你好艾琳和其他网络流浪者,
也许这是已经回复的帖子上的双重帖子,或者让我说这是尝试澄清xml文件中包含的Java源代码。我陷入了同样的困境,但我无法指出阿德里安的意思。最后两个源标记将告诉应编译哪些包和尾随源文件。这就是为什么你应该在名为“path”的属性中命名每个包。
以下文件是在Eclipse Indigo的Framework版本中自动生成的:appengine-java-sdk-1.6.4.1。它没有多少不必要的评论。
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='wk_cms'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.json.JSON'/>
<inherits name='com.google.gwt.http.HTTP'/>
<inherits name='com.google.gwt.user.theme.chrome.Chrome'/>
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='de.someproject.wkcms.client.Wk_cms'/>
<!-- Specify the paths for translatable code -->
<source path='client'/> <<-- my code (package client)
<source path='communication'/> <<-- my code (package communication)
</module>
我希望这能使每个人远离探测和测试,然后才能获得成功...... =)
祝你好运, 塞莫
PS。编辑的文件不是web.xml,而是PROJECTNAME.gwt.xml。
答案 1 :(得分:1)
想想我看到了:
Test.java
应该放在client.test
包中,不仅仅是client
,或者所有内容都应该指向client.Test
而不是client.test.Test
。
答案 2 :(得分:0)
您的服务器类似乎位于包server.test下,而不仅仅是服务器,这可能是错误的。检查web.xml中的映射是否正确指向此类。
我怀疑真正的错误可能在其他地方 - 我本以为它仍然需要编译。
答案 3 :(得分:0)
(不确定我是否必须“回答你的问题”,先试试Stack Overflow网站!)
感谢您的评论,Adrian!
这是“web.xml”文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>org.redboffin.worldhug.server.test.TestServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/worldhug/test/testService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
</web-app>
似乎servlet标记指向我眼睛的正确位置: TestServiceImpl.java 位于包“org.redboffin.worldhug.server.test”中你的意思是?
还有其他想法吗?
再次感谢你! :)
答案 4 :(得分:0)
您必须包含以下内容
<source path='client.test'/>