开发者

GWT RPC "404 not found" error. How do you get RPC to work on your own Apache server?

The RPC I implemented works fine in dev mode. But as soon as I copy the code into a real apache server the RPC stops working! How do you configure your GWT application so that the RPC will work on the apache server? I have found the GWT tutorial on RPC but it is not very helpful. Other links about RPC configuration would be very much appreciated!


I developed some GWT code. I implemented and got working an RPC client-server communication. When I say it is working... I mean that it works great in development mode. I can click and it interacts with the server as expected.

Then when I do a GWT compile and copy the war directory into my apache server htdocs fold开发者_运维知识库er. I can view the website but when I click on the button that is supposed to initiate an RPC nothing happens. I check the Firefox-->tools-->web console and see "NAMEOFRPC 404 not found".

Here is my WEB-INF 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>NameOfRpc</servlet-name>
    <servlet-class>com.company.nameOfModule.server.rpc.NameOfRpcImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>NameOfRpc</servlet-name>
    <url-pattern>/nameOfModule</url-pattern>
  </servlet-mapping>

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

</web-app>

Here is the firefox web-console error I get:

[16:50:58.792] POST http://SERVER/gwt/nameOfModule/nameOfModule/NameOfRpc [HTTP/1.1 404 Not Found 3065ms]

I copy the war folder into /SERVER/gwt and then rename it to nameOfModule.

Is there anything wrong with my WEB-INF/web.xml?


What you need is some running JVM instance, running a J2EE servlet container, which is hosting your servlet code. Apache, as I understand is simply a http server, and does not run java code, or host servlets, out of the box. I'm assuming your wiki is simply a clump of HTML pages served by apache.

Tomcat is merely an option. It is the standard JVM contatiner folks use for hosting java servlets. It is also capable of serving HTML files, so you can stop using apache http server if you use tomcat.

Your app worked well in development mode, because GWT Hosted Mode has in-built Jetty server, which is a lightweight servlet container comparable to tomcat. Servers like tomcat and jetty and jboss are the ones which actually read your web.xml and do what you have described in it.


You are going to want the following in your web.xml:

<url-pattern>/nameOfModule/RpcGetXml</url-pattern>

Or whatever is in your RemoteServiceRelativePath

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜