4

I'm having a strange issue with GWT-RPC. I setup an Async RPC handler that is working fine. But when I run my server (using ant devmode) I get the following warning:

[WARN] Module declares a servlet class 'x.y.server.LoginServiceImpl' 
with a mapping to '/login/login', but the web.xml has no corresponding mapping

To be clear, nowhere in my code am I specifying "/login/login". I want to use just /login. Why is it adding it twice? It almost looks like a GWT bug. Here is the rest of the configuration:

My web.xml servlet-mapping looks like this:

<servlet-mapping>
    <servlet-name>LoginServiceImpl</servlet-name>
    <url-pattern>/login</url-pattern>
</servlet-mapping>

My module file has the following:

<servlet path="/login" class="x.y.server.LoginServiceImpl" />

So why am I getting a warning about /login/login when that is not defined anywhere? Any help is appreciated, thanks.

-tjw

Travis Webb
  • 14,688
  • 7
  • 55
  • 109

3 Answers3

4

You have probably defined your rename-to attribute in your .gwt.xml file as:

<module rename-to='login'>

And your LoginService (the interface!) probably contains the annotation

@RemoteServiceRelativePath("login")

The resulting path (i.e. the one which the client calls) is then "/login/login".

I'm not sure, if you can achieve "/login" easily, but what you could try, is this:

LoginServiceAsync service = GWT.create(LoginService.class);
ServiceDefTarget serviceDefTarget = (ServiceDefTarget) service;
serviceDefTarget.setServiceEntryPoint(GWT.getHostPageBaseURL() + "login");

I haven't tested this, so this may need a little bit tweaking (?). From the Javadoc of ServiceDefTarget:

/**
 * An interface implemented by client-side RPC proxy objects. Cast the object
 * returned from {@link com.google.gwt.core.client.GWT#create(Class)} on a
 * {@link RemoteService} to this interface to initialize the target URL for the
 * remote service.
 */
Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
  • But doesn't that then mean that the Service is hosted at /login/login? I'm making my request to just /login and I'm getting a response just fine. I tried your fix and it doesn't seem to make a difference. – Travis Webb Mar 30 '11 at 19:34
  • @Travis: The web.xml specifies, where the service will be hosted. So if you specify `/login`, then the service will be hosted at "/login". – Chris Lercher Mar 30 '11 at 20:08
  • I just quickly tried my solution, and it actually works as I intended. The `setEntryPoint` method doesn't change anything on the server - it just tells the client, which server URL it should call (in this case: "www.example.org/login"). You say, it didn't work... maybe remove the `` line from your .gwt.xml (looks like old style). – Chris Lercher Mar 30 '11 at 20:14
1

I solved it, but points still to anyone who can tell me why. I removed this from my module definition:

<servlet path="/login" class="x.y.server.LoginServiceImpl" />

and now everything works, with no warning. Question: why was I instructed to put that there in the first place? What purpose does it serve?

-tjw

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
  • Ah, I see you already removed it. Where did you read that instruction? – Chris Lercher Mar 30 '11 at 20:15
  • That lines allows for loading of servlets during 'DevMode,' but in production mode those servlets are pulled from 'web.xml.' However if you have IoC/DM like Spring, then you'll need to point your DevMode to a running Tomcat/Jetty so that your RPC's can still be served up. – Joseph Lust Aug 08 '12 at 23:57
1

If you are using Netbeans, it say in the module file: "Do not define servlets here, use web.xml".

http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml say:

: For RPC, this element loads a servlet class mounted at the specified URL path. The URL path should be absolute and have the form of a directory (for example, /calendar). Your client code then specifies this URL mapping by annotating the service interface with the @RemoteServiceRelativePath attribute. Any number of servlets may be loaded in this manner, including those from inherited modules.

The element applies only to GWT's embedded server server-side debugging feature.

NOTE: as of GWT 1.6, this tag does no longer loads servlets in development mode, instead you must configure a WEB-INF/web.xml in your war directory to load any servlets needed.

ngspkinga
  • 421
  • 5
  • 16