404 error on dispatch

271 views
Skip to first unread message

Christofer Jennings

unread,
Feb 25, 2011, 7:04:56 PM2/25/11
to gwt-pl...@googlegroups.com
I'm getting a 404 error when accessing a dispatch service. It's my first time using the @GenDispatch but I'm pretty sure I've done it right.  I already have one working LoginActionHandler which I hand made (LoginActionHandler). Anything look weird here? (THANKS!)

[WARN] 404 - POST /dispatch/FindUsers (127.0.0.1) 1404 bytes
   Request headers
      Host: 127.0.0.1:8888
      User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
      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
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 115
      Connection: keep-alive
      Cookie: JSESSIONID=adjt4k0qdvua; MYCOOKIE=adjt4k0qdvua
      X-GWT-Permutation: HostedMode
      X-GWT-Module-Base: http://127.0.0.1:8888/myapp/
      Content-Type: text/x-gwt-rpc; charset=utf-8
      Content-Length: 275
      Pragma: no-cache
      Cache-Control: no-cache
   Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1404


I've defined my action / response using the gen tool...
@GenDispatch
public class FindUsers {
@Out(1) List<User> users;
}

I have a Handler like this...
public class FindUsersActionHandler implements ActionHandler<FindUsersAction, FindUsersResult> {

@Override
public Class<FindUsersAction> getActionType() {
return FindUsersAction.class;
}

@Override
public FindUsersResult execute(FindUsersAction arg0,
ExecutionContext arg1) throws ActionException {
return new FindUsersResult(new ArrayList<User>());
}

@Override
public void undo(FindUsersAction action, FindUsersResult result,
ExecutionContext context) throws ActionException {
// Nothing to do.
}

Here's my DispatchServerModule...
public class DispatchServletModule extends ServletModule {

@Override
public void configureServlets() {
filter("*.jsp").through(HttpSessionSecurityCookieFilter.class);
bindConstant().annotatedWith(SecurityCookie.class).to("MYCOOKIE");

serve("/" + ActionImpl.DEFAULT_SERVICE_NAME).with(DispatchServiceImpl.class);
}

}

And my ServerModule...
public class ServerModule extends HandlerModule {

@Override
protected void configureHandlers() {
bindHandler(LoginAction.class, LoginActionHandler.class);
bindHandler(FindUsersAction.class, FindUsersActionHandler.class);
bindHandler(AddUserAction.class, AddUserActionHandler.class);
}
}

And my  GuiceServletContextListener...
public class MyGuiceServletContextListener extends GuiceServletContextListener {

@Override
protected Injector getInjector() {
return Guice.createInjector(new ServerModule(), new DispatchServletModule());
}
}

I'm puzzled.
,boz



Christofer Jennings

unread,
Feb 26, 2011, 11:25:42 AM2/26/11
to gwt-pl...@googlegroups.com
I got my action handler to work for find-users by not using the gen-tool. The code updates are shown below. 

But I'd really like to use the gen-tool :-) and I'm still confused as to why id didn't work for me. It may be a missing dependency for the server-side code. I'll keep experimenting.

I've re-defined my action / response using by hand...
public class XFindUsersAction extends ActionImpl<XFindUsersResult>{
}

public class XFindUsersResult implements Result {
   private List<User> users;

   public XFindUsersResult(List<User> users) {
      this.users = users;
   }

   /** For GWT serialization only. */
   @SuppressWarnings("unused")
   private XFindUsersResult() {}

   public List<User> getUsers() {
      return users;
   }

      

}

The Handler became this...
public class FindUsersActionHandler implements ActionHandler<XFindUsersAction, XFindUsersResult> {


@Override
public Class<XFindUsersAction> getActionType() {
return XFindUsersAction.class;
}

@Override
public XFindUsersResult execute(XFindUsersAction action,
ExecutionContext context) throws ActionException {
System.out.println("FindUsersActionHandler.execute(...)");
return new XFindUsersResult(makeDummyUsers());
}

@Override
public void undo(XFindUsersAction action, XFindUsersResult result,
ExecutionContext context) throws ActionException {
// Nothing to do.
}
}

And my ServerModule using the hand-made XFindUsersAction...
public class ServerModule extends HandlerModule {

@Override
protected void configureHandlers() {
bindHandler(LoginAction.class, LoginActionHandler.class);
bindHandler(XFindUsersAction.class, FindUsersActionHandler.class);
bindHandler(AddUserAction.class, AddUserActionHandler.class);
}
}

I'm puzzled.
,boz




Christofer Jennings

unread,
Feb 26, 2011, 11:51:07 AM2/26/11
to gwt-pl...@googlegroups.com
GOT IT!!!

My DispatchServletModule was missing the "*" in the serve path!

It was ...
  serve("/" + ActionImpl.DEFAULT_SERVICE_NAME).with(DispatchServiceImpl.class);

It needed to be ...
  serve("/" + ActionImpl.DEFAULT_SERVICE_NAME + "*").with(DispatchServiceImpl.class);

The generated actions now get handled correctly.
Found the fix in the Hive project.
Maybe it needs to be updated? I'm still too new to be sure.

Happy Camping
,boz


Philippe Beaudoin

unread,
Feb 26, 2011, 11:58:03 AM2/26/11
to gwt-pl...@googlegroups.com
Thanks, I've corrected it... and tried Google Code in-browser code
editor for the first time! Hopefully the CI server will let me know if
it fails. :)

Cheers,

Philippe

Reply all
Reply to author
Forward
0 new messages