通过 RPC 调用让 google GWT StockWatcher 程序在 Tomcat 上运行
我遵循了默认的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的类很可能在不包括您的课程。我对 Ant 的了解还不够,无法为您提供更好的方法(如果有的话)来构建 WAR,但请尝试添加
WEB-INF/classes
中编译,而不是打包到 JAR 中,因此您的
接下来到现有的一个来接你的课程。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.