servlets - My service is not reached when using guice + gwt -


i trying setup guice+gwt far cannot invoke service . async request fails.

here guice context listener:

import ne.projl.client.service.projservice; import ne.projl.server.projserviceimpl;  import com.google.inject.abstractmodule; import com.google.inject.guice; import com.google.inject.injector; import com.google.inject.persist.persistfilter; import com.google.inject.persist.jpa.jpapersistmodule; import com.google.inject.servlet.guiceservletcontextlistener; import com.google.inject.servlet.servletmodule;  public class myguiceservletconfig extends guiceservletcontextlistener {      @override     protected injector getinjector() {          return guice.createinjector(new servletmodule(){             @override             protected void configureservlets() {                 // todo auto-generated method stub                 install(new jpapersistmodule("projpunit"));                 filter("/*").through(persistfilter.class);                 serve("springgwtservices/*").with(projserviceimpl.class);                 //bind(projservice.class)              }          }, new abstractmodule(){              @override             protected void configure() {                 bind(projserviceimpl.class);              }          });     }  } 

here web.xml

<!doctype web-app public  "-//sun microsystems, inc.//dtd web application 2.3//en"  "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>     <display-name>geomajas gwt face example application</display-name>     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value> <!--            web-inf/applicationcontext.xml -->        </param-value>     </context-param>         <filter>     <filter-name>guicefilter</filter-name>     <filter-class>com.google.inject.servlet.guicefilter</filter-class>   </filter>    <filter-mapping>     <filter-name>guicefilter</filter-name>     <url-pattern>/*</url-pattern>   </filter-mapping>    <listener>   <listener-class>ne.projl.as.myguiceservletconfig</listener-class> </listener>       <welcome-file-list>         <welcome-file>index.html</welcome-file>     </welcome-file-list>  </web-app> 

my service implementation projserviceimpl

import ne.projl.client.service.projservice; import ne.projl.server.entities.poicateg; import ne.projl.shared.fieldverifier;  import com.google.gwt.user.server.rpc.remoteserviceservlet; import com.google.inject.inject; import com.google.inject.singleton;     /**  * server side implementation of rpc service.  */ @suppresswarnings("serial") //@service("test") @singleton public class projserviceimpl extends remoteserviceservlet implements projservice {     private static final log log = logfactory.getlog(projserviceimpl.class);       //@autowired     //@inject     //poicategdao poicategdao;     @inject     public projserviceimpl(){}; //  protected void doget(javax.servlet.http.httpservletrequest req, javax.servlet.http.httpservletresponse resp) throws javax.servlet.servletexception ,java.io.ioexception { //       //       //  };      public string greetserver(string input) throws illegalargumentexception {         // verify input valid.          if (!fieldverifier.isvalidname(input)) {             // if input not valid, throw illegalargumentexception             // client.             throw new illegalargumentexception(                     "name must @ least 4 characters long");         }         //requestcontextutils.getwebapplicationcontext(request); //      string serverinfo = getservletcontext().getserverinfo(); //      string useragent = getthreadlocalrequest().getheader("user-agent");            return "hello, " + input + "!<br><br>i running .<br><br>it looks using:<br>";         }      @override      public void testdao(integer id) throws illegalargumentexception {         // todo auto-generated method stub //      poicateg x=poicategdao.findbyid(id);     //  poicateg z=poicategdao.findbyid(id);     }  } 

and projservice interface:

@remoteservicerelativepath("springgwtservices/test") public interface projservice extends remoteservice {     string greetserver(string name) throws illegalargumentexception;      void testdao(integer id) throws illegalargumentexception; } 

and async remote procedure call :

projservice.testdao(5, new asynccallback<void>(){              @override             public void onfailure(throwable caught) {                 // todo auto-generated method stub                 label des= new label("mer7 can");                 rootpanel.get().add(des);             }              @override             public void onsuccess(void result) {                 // todo auto-generated method stub                 label des= new label("merge1 can");                 rootpanel.get().add(des);             }           }); 

the caught error :

com.google.gwt.user.client.rpc.statuscodeexception: 404 <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>error 404 not_found</title> </head> <body><h2>http error: 404</h2><pre>not_found</pre> <p>requesturi=/showcase/springgwtservices/test</p><p><i><small><a href="http://jetty.mortbay.org/">powered jetty://</a></small></i></p><br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                 <br/>                                                  </body> </html> 

and projserviceasync interface :

public interface projserviceasync {     void greetserver(string input, asynccallback<string> callback)             throws illegalargumentexception;      void testdao(integer id, asynccallback<void> callback); } 

and relevant console output :

[warn] 404 - post /showcase/springgwtservices/test (127.0.0.1) 1417 bytes    request headers       host: 127.0.0.1:8888       user-agent: mozilla/5.0 (windows nt 6.1; rv:22.0) gecko/20100101 firefox/22.0       accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8       accept-language: en-us,en;q=0.5       accept-encoding: gzip, deflate       dnt: 1       x-gwt-permutation: hostedmode       x-gwt-module-base: http://127.0.0.1:8888/showcase/       content-type: text/x-gwt-rpc; charset=utf-8       referer: http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997       content-length: 160       connection: keep-alive       pragma: no-cache       cache-control: no-cache    response headers       content-type: text/html; charset=iso-8859-1       content-length: 1417 

it looks missing application root in guiceservletconfig

in "myguiceservletconfig" try changing:

serve("springgwtservices/*").with(projserviceimpl.class);

to:

serve("/showcase/springgwtservices/*").with(projserviceimpl.class);

if doesn't work try adding "/test" on end instead of "/*" so:

serve("/showcase/springgwtservices/test").with(projserviceimpl.class);

so matches path in "projservice"

@remoteservicerelativepath("springgwtservices/test")


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -