java GWT 模块继承和应用程序运行时没有可用的源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4276836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 05:38:56  来源:igfitidea点击:

GWT Module inheritance and NO source code available on application running time

javagwtgwt-rpc

提问by Irene

I am starting to use GWT for a class project and wanted to know real use cases for RPC. So, I found this example on this same website: Stack Overflow - Simple RPC Use Case Problem (Code Included)

我开始在一个类项目中使用 GWT,并想了解 RPC 的实际用例。所以,我在同一个网站上找到了这个例子:Stack Overflow - Simple RPC Use Case Problem (Code Included)

Why I did this example? because I was getting the same errors that the user posted on my own project and I decided to try and follow his code on my computer to see if I could really face my own mistakes.

为什么我做了这个例子?因为我遇到了用户在我自己的项目中发布的相同错误,我决定尝试在我的计算机上遵循他的代码,看看我是否真的可以面对自己的错误。

So the point is that after copying the files on an Eclipse GWT project and deploy the app, I got this two errors on running time:

所以关键是在 Eclipse GWT 项目上复制文件并部署应用程序后,我在运行时遇到了以下两个错误

1st Error

第一个错误

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?

2nd Error

第二个错误

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

So I tried to correct Test.gwt.xmlas Craig suggested on the post. Unfortunately, that solution is not working to me because still I am getting the same errors.

因此,我尝试按照 Craig 在帖子中的建议更正Test.gwt.xml。不幸的是,该解决方案对我不起作用,因为我仍然遇到相同的错误。

1st error: I don't know what is happening because, for example, in the file it is depicted, RemoteServiceServlet is imported some rows before (despite it is not seen). This file is on package "org.redboffin.worldhug.server.test;"

第一个错误:我不知道发生了什么,例如,在它所描述的文件中,RemoteServiceServlet 之前导入了一些行(尽管没有看到)。该文件位于“org.redboffin.worldhug.server.test;”包中

2nd error: If user who posted initial thread did not need to "inherit" a new package in his project, I can't understand why do I need them. Anyway, I put a new inherit line one the .gwt.xml file:

第二个错误:如果发布初始线程的用户不需要在他的项目中“继承”一个新包,我不明白为什么我需要它们。无论如何,我在 .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>

And that is what I got:

这就是我得到的:

 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?

(of course, it didn't compile)

(当然,它没有编译)

So, I really don't know what is going on. Please, can someone bring some light to this issue? Why is this not working? What I am doing bad? What is this type that it is needed on the 2nd error?

所以,我真的不知道发生了什么。请问有人可以解决这个问题吗?为什么这不起作用?我在做什么坏事?第二个错误所需的这种类型是什么?

回答by Semo

Hello Irene and other Web-Wanderers,

你好艾琳和其他网络漫游者,

Maybe this is a double post on a already answered post or let me say it is a try to clarify about includes of Java Source code in the xml file. I got stuck at the same point, but I couldn't point out what Adrian meant. The last two source tags will tell what packages and trailed source files shall be compiled. That is why you should name each package in the attribute called "path".

也许这是一个已经回答的帖子的双重帖子,或者让我说这是试图澄清 xml 文件中 Java 源代码的包含。我被困在同一点上,但我无法指出阿德里安的意思。最后两个源标记将说明应编译哪些包和尾随源文件。这就是为什么您应该在名为“path”的属性中命名每个包。

The file below was auto-generated in Eclipse Indigo in Framework version: appengine-java-sdk-1.6.4.1. It is bereft of unnecessary comments.

以下文件是在框架版本的 Eclipse Indigo 中自动生成的: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>

I hope this keeps everyone afar from probing and testing before having success... =)

我希望这能让每个人在成功之前远离探索和测试...... =)

Best regards, Semo

最好的问候,塞莫

PS. The file edited was not web.xml but PROJECTNAME.gwt.xml.

附注。编辑的文件不是 web.xml,而是 PROJECTNAME.gwt.xml。

回答by Adrian Mouat

Think I see it:

我想我看到了:

Test.javashould be in the client.testpackage not just client, or everything should point to client.Testrather than client.test.Test.

Test.java应该在client.test包里不只是client,或者一切都应该指向client.Test而不是client.test.Test

回答by Purushothaman

You will have to include the following

您必须包括以下内容

<source path='client.test'/>

回答by Adrian Mouat

Your server class seems to be under the package server.test, rather than just server, which is probably wrong. Check the mapping in web.xml correctly points to this class.

您的服务器类似乎在包 server.test 下,而不仅仅是服务器,这可能是错误的。检查 web.xml 中的映射是否正确指向此类。

I suspect the real error is probably somewhere else though - I would have expected it still to compile.

我怀疑真正的错误可能在其他地方 - 我原以为它仍然可以编译。

回答by Irene

(Not sure if I have to "answer your question" or not, first try on Stack Overflow site!)

(不确定我是否必须“回答您的问题”,请先在 Stack Overflow 网站上尝试!)

Thanks for your comment, Adrian!

谢谢你的评论,阿德里安!

This is the content of "web.xml" file:

这是“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>

It seems that the servlet tag is pointing to the right place to my eyes: TestServiceImpl.javais inside package "org.redboffin.worldhug.server.test"Did you mean that?

servlet 标记似乎指向了我眼中的正确位置:TestServiceImpl.java位于包“org.redboffin.worldhug.server.test”内,您是这个意思吗?

Any other idea?

还有其他想法吗?

Thank you again! :)

再次感谢你!:)