简体   繁体   中英

@WebServlet annotation and GWT RPC

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

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"> 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM