8

In my GWT project running in glassfishv3, everything is worked properly, but when I change my servlet url patterns mapping from web.xml to @WebServlet annotation inside servlet classes, GWT rpc cand find the servlet!

note that, other usual servlets work with this annotation(WebServlet) and just GWT RPC doesnt work.

what is the reason?

RGDS

Nav
  • 4,450
  • 10
  • 53
  • 84

2 Answers2

6

Did you set the version number of web-app in the web.xml to the correct servlet version, because this feature is available only since 3.0:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      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_3_0.xsd"
      version="3.0"> 
Hilbrand Bouwkamp
  • 13,509
  • 1
  • 45
  • 52
  • yes it is version 3, and other servlets work with this kind of mapping(@WebServlet) but GWT remoteServiceServlet not work – Nav Nov 24 '11 at 19:57
4

Ok, I finally got this working but with some caveats. I was able to get it working in Tomcat within Intellij and as a deployed WAR to a Tomcat 7 container.

I was NOT able to get it working in dev-mode without using -noserver. I believe this is because the built-in Jetty server is not JSR315 compatible but have no evidence of this as I've not tried to determine what version of jetty is in the gwt-dev jar.

The trick is you need to fully qualify the path in WebServlet. So if your remote service interface has the relative path of "bar" and your module name (rename-to in gwt.xml) is "foo" then the path you need to set the path of "/foo/bar" in WebServlet and it will work.

icfantv
  • 4,523
  • 7
  • 36
  • 53
  • I know this is old, but here is a bug directly related to getting Servlet 3.0 annotations to work with the embedded Jetty server; https://code.google.com/p/google-web-toolkit/issues/detail?id=8472 – Jonathan Apr 03 '15 at 19:28