user3081974
user3081974

Reputation: 21

Servlet Mapping for RPC Call

I am quite new to GWT-Programming but I have programmed a long time in Java!

I have created a small application with an RPC Call but it doesn't work.

When i click on the button with will start the call, I only get the following message on the console:

[WARN] 404 - POST /wps_akt/student (127.0.0.1) 1401 bytes
   Request headers
      Host: 127.0.0.1:8888
      Connection: keep-alive
      Accept: */*
      User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
      Accept-Encoding: gzip,deflate,sdch
      Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
      Content-Length: 137
      X-GWT-Module-Base: http://127.0.0.1:8888/wps_akt/
      X-GWT-Permutation: HostedMode
      Origin: http://127.0.0.1:8888
      Content-Type: text/x-gwt-rpc; charset=UTF-8
      Referer: http://127.0.0.1:8888/Wps_akt.html?gwt.codesvr=127.0.0.1:9997
   Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1401

The web.xml 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>StudentServiceImpl</servlet-name>
    <servlet-class>at.htlpinkafeld.wps.server.StudentServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>StudentServiceImpl</servlet-name>
    <url-pattern>/student</url-pattern>
  </servlet-mapping>


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

</web-app>

Thank you for your help Stefan

Upvotes: 0

Views: 330

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64551

GWT-RPC path in @RemoteServiceRelativePath is relative to GWT.getModuleBaseURL(), i.e. the folder where GWT produces the *.nocache.js and the .cache. files (that folder is named after your GWT module's name, or the rename-to attribute in your *.gwt.xml file).

So your <servlet-mapping> should use /wps_akt/student rather than just /student.

If you want to use /student, then you'll have to tweak your @RemoteServiceRelativePath to read "../student" (assuming the GWT compiler accepts it) or set the path explicitly (casting your service to ServiceDefTarget and call setServiceEntryPoint with the URL you mapped your servlet to.

Upvotes: 2

Related Questions