通过 RPC 调用让 google GWT StockWatcher 程序在 Tomcat 上运行

发布于 2024-12-12 02:46:30 字数 2136 浏览 0 评论 0原文

我遵循了默认的 GWT 教程,并开始学习 Java RPC 部分,http: //code.google.com/webtoolkit/doc/latest/tutorial/RPC.html 用于创建示例 StockWatcher 应用程序。

我在 eclipse 中本地运行了所有内容,包括 java servlet 内容。 war/WEB-INF/web.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee">

  <!-- Servlets -->
  <servlet>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <servlet-class>com.google.gwt.sample.stockwatcher.server.StockPriceServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <url-pattern>/stockwatcher/stockPrices</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>StockWatcher.html</welcome-file>
  </welcome-file-list>

</web-app>

我不知道如何将所有这些放入一个 war 文件中,但在互联网上找到了这个 ANT 脚本,它确实创建了 .war 文件。

<project name="StockWatcher" basedir="." default="default">

    <target name="default" depends="buildwar,deploy"></target>

    <target name="buildwar">
        <war basedir="war" destfile="StockWatcher.war" webxml="war/WEB-INF/web.xml">
            <exclude name="WEB-INF/**" />
            <webinf dir="war/WEB-INF/">
                <include name="**/*.jar" />
            </webinf>
        </war>
    </target>

    <target name="deploy">
        <copy file="StockWatcher.war" todir="." />
    </target>

</project>

当我将应用程序上传到 Tomcat 时,客户端 javascript 工作正常,但是 RPC servlet 无法工作,我收到以下错误。

HTTP 状态 404 - Servlet stockPriceServiceImpl 不可用

如何修复此问题?

I followed the default GWT tutorial and am up to the Java RPC part, http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html for creating a sample StockWatcher application.

I got it all working locally in eclipse including the java servlet stuff. The war/WEB-INF/web.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee">

  <!-- Servlets -->
  <servlet>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <servlet-class>com.google.gwt.sample.stockwatcher.server.StockPriceServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <url-pattern>/stockwatcher/stockPrices</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>StockWatcher.html</welcome-file>
  </welcome-file-list>

</web-app>

I didn't know how to put all this into a war file but found this ANT script on the internet it it did create the .war file.

<project name="StockWatcher" basedir="." default="default">

    <target name="default" depends="buildwar,deploy"></target>

    <target name="buildwar">
        <war basedir="war" destfile="StockWatcher.war" webxml="war/WEB-INF/web.xml">
            <exclude name="WEB-INF/**" />
            <webinf dir="war/WEB-INF/">
                <include name="**/*.jar" />
            </webinf>
        </war>
    </target>

    <target name="deploy">
        <copy file="StockWatcher.war" todir="." />
    </target>

</project>

When I uploaded the application to Tomcat, the client side javascript stuff is working fine, however the RPC servlet is not working, I am getting the following error.

HTTP Status 404 - Servlet stockPriceServiceImpl is not available

How do I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-12-19 02:46:30

您的类很可能在 WEB-INF/classes 中编译,而不是打包到 JAR 中,因此您的 不包括您的课程。我对 Ant 的了解还不够,无法为您提供更好的方法(如果有的话)来构建 WAR,但请尝试添加 接下来到现有的一个来接你的课程。

Your classes might very well be compiled in WEB-INF/classes and not packaged into a JAR, so your <include name="**/*.jar" /> is excluding your classes. I don't know Ant enough to give you a better way (if any) of building your WAR, but try adding an <include name="**/*.class" /> next to the existing one to pick up your classes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文