GWT RPC Warning: the servlet has a mapping, but web.xml does not have a matching mapping

I have a strange problem with GWT-RPC. I am setting up an Async RPC handler that works fine. But when I start my server (using ant devmode ), I get the following warning:

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

To be clear, nowhere in my code do I specify "/ login / login". I want to use only / login . Why does he add 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="xyserver.LoginServiceImpl" /> 

So why do I get a warning about / login / login when it is not defined anywhere? Any help is appreciated, thanks.

-tjw

+4
source share
3 answers

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

 <module rename-to='login'> 

And your LoginService (interface!) Probably contains the annotation

 @RemoteServiceRelativePath("login") 

The resulting path (that is, the one that the client calls), then "/ login / login".

I'm not sure if you can easily reach "/ login", but what you could try is the following:

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

I have not tested this, so this may require a bit of 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. */ 
+4
source

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

 <servlet path="/login" class="xyserver.LoginServiceImpl" /> 

and now everything works, without warning. Question: Why was I instructed to put it there in the first place? What purpose does he fulfill?

-tjw

+1
source

If you use Netbeans, it says in the module file: "Do not list servlets here, use web.xml."

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

: For RPC, this element loads the servlet class installed at the specified URL path. The URL path must be absolute and in the form of a directory (e.g. / calendar). The client code then indicates this URL mapping, annotating the service interface with the @RemoteServiceRelativePath attribute. Any number of servlets can be loaded in this way, including from legacy modules.

The item applies only to the server side debugging feature of the embedded GWT server.

NOTE: with GWT 1.6, this tag no longer loads servlets in development mode, instead you must configure WEB-INF / web.xml in your military directory to load any necessary servlets.

+1
source

Source: https://habr.com/ru/post/1345923/


All Articles