2010-11-25 53 views
0

我開始將GWT用於類項目,並且想知道RPC的實際使用情況。所以,我在這個網站上找到了這個例子:Stack Overflow - Simple RPC Use Case Problem (Code Included)GWT模塊繼承和無應用程序運行時可用的源代碼

爲什麼我做了這個例子?因爲我得到的錯誤與用戶在我自己的項目中發佈的錯誤相同,我決定嘗試在計算機上跟蹤他的代碼,看看我是否可以真正面對自己的錯誤。

因此,問題是複製上一個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? 

[ 2n個錯誤]

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 

於是,我就科爾ect Test.gwt.xml Craig在帖子中建議。不幸的是,這個解決方案對我來說並不合適,因爲我仍然得到相同的錯誤。在這裏你可以看到一個圖像鏈接(上ImageShack的)我的Eclipse屏幕:

http://yfrog.com/n7errorgwtj

[第一錯誤]我不知道發生了什麼,因爲,例如,在文件中它被描繪,RemoteServiceServlet之前導入了一些行(儘管沒有看到)。這個文件在包「org.redboffin.worldhug.server.test;」

[2n錯誤]如果發佈初始線程的用戶不需要在他的項目中「繼承」一個新包,我無法理解爲什麼我需要它們。不管怎樣,我把新的繼承線之一.gwt.xml文件:

​​

這是我得到:

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? 

(當然,它並沒有編譯)

所以,我真的不知道發生了什麼。請問,有人能爲這個問題帶來一些啓示嗎?爲什麼這不起作用?我做得不好?這是什麼類型的[第二個錯誤]需要它?

非常感謝所有讀者到目前爲止,

問候。

回答

1

想我看到它:

Test.java應該在client.test包中,而不僅僅是client,或者一切應該指向client.Test而不是client.test.Test

0

您的服務器類似乎在server.test包下,而不僅僅是服務器,可能是錯誤的。檢查web.xml中的映射是否正確指向此類。

我懷疑真正的錯誤可能是其他地方,但我會期待它仍然編譯。

+0

我只是看看例子,似乎路徑是正確的。但是,爲什麼你使用SO代碼而不是Google教程? – 2010-11-25 12:24:41

+0

我嘗試了一些谷歌的教程,我發現他們長期,複雜和不明確的人不是高手在這種網絡開發的。總而言之,我試圖遵循St​​ockWatcher示例來明確自己的想法,並在遵循所有應用程序無法使用的方式之後。我感到沮喪,正在尋找像我用過的例子那樣的小東西。不過我對我自己的項目面臨着同樣的錯誤,我想,如果我知道如何解決上一個小項目,這些錯誤也許我可以做同樣的一個更大的。 – Irene 2010-11-25 13:27:52

+0

我做了stockwatcher教程,並認爲它非常好。你應該在教程的每個階段有所作爲,而不僅僅是最後。 GWT確實有幾個文件需要正確的設置才能發生。 – 2010-11-25 14:38:41

0

(不知道我是否有「回答你的問題」與否,首先嚐試在Stack Overflow網站!)

感謝您的評論,阿德里安!

這是「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’你有沒有?!意味着

任何其他的想法

再次謝謝:)

3

您好艾琳和其他Web-流浪漢,

也許這是一個已經回答後雙崗還是讓我說,這是一個試圖澄清關於包括在xml文件Java源代碼。我陷入了同樣的困境,但我無法指出阿德里安的意思。最後兩個源標籤會告訴編譯哪些包和尾隨的源文件。這就是爲什麼你應該在名爲「path」的屬性中命名每個包。

在Eclipse靛藍下面是自動生成的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。

0

您必須包括以下

<source path='client.test'/>