0
votes

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?

1

1 Answers

0
votes

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.