Re: [gwt-dispatch] Multiple ActionHandler not recognise when using gwtp-dispatch-server-spring-0.7

115 views
Skip to first unread message

Robert Munteanu

unread,
Oct 14, 2012, 4:28:49 AM10/14/12
to gwt-di...@googlegroups.com
Hi,

Since your code mentions gwt-platform, you might be looking for

http://groups.google.com/group/gwt-platform

This is the discussion group for http://code.google.com/p/gwt-dispatch/

Cheers,

Robert

On Fri, Oct 12, 2012 at 10:08 PM, mavanier <ma.v...@gmail.com> wrote:
> Hi,
>
> I started a Maven, Spring, GWTP project based on gwtp-sample-basic-spring. I
> added new actions, results, handlers, mapped it in ServerModule. I am stuck
> with an application that the only possible action is to sign in. Every other
> server call gives me an 500 error.
>
> The only error message I see is:
> 00:01:34.384 [INFO] (AuditTrailsPresenter.java:110) 2012-10-12 14:18:32,370
> [DEBUG] onFailure() - 500 The call failed on the server; see server log for
> details
>
> I played a lot with the files and configuration and when I comment out the
> working handler, I receive this error message with a long stack trace in the
> eclipse console:
> [ERROR] com.gwtplatform.dispatch.shared.UnsupportedActionException: No
> handler is registered for audit.shared.action.LoginAction
>
> No error message is displayed when removing the other action handlers.
>
> What am I doing wrong? Or can I turn the log on with a special command?
>
> Thanks,
> Marc-Andre
>
> web.xml (in attachment)
> ------
> <!-- GWT-Dispatch Spring -->
> <servlet>
> <servlet-name>dispatch</servlet-name>
> <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> applicationContext.xml
> ---------------------------------
> <context:component-scan
> base-package="com.gwtplatform.dispatch.server.spring"/>
> <context:annotation-config/>
>
> <!-- GWT Service Beans -->
> <bean class="ca.sunmedia.documentum.audit.server.ServerModule"/>
>
>
> ServerModule.java
> --------------------------
> /**
> * Module which binds the handlers and configurations.
> */
> @Configuration
> @Import(DefaultModule.class)
> public class ServerModule extends HandlerModule {
>
> public ServerModule() {
> }
>
> @Bean
> public LoginHandler getLoginHandler() {
> return new LoginHandler();
> }
>
> @Bean
> public RetrieveAuditTrailHandler getRetrieveAuditTrailHandler() {
> return new RetrieveAuditTrailHandler();
> }
>
> @Bean
> public ActionValidator getDefaultActionValidator() {
> return new DefaultActionValidator();
> }
>
> protected void configureHandlers() {
> bindHandler(LoginAction.class, LoginHandler.class);
> bindHandler(RetrieveAuditTrailListAction.class,
> RetrieveAuditTrailHandler.class);
> bindHandler(TestAction.class, TestActionActionHandler.class,
> LoggedInActionValidator.class);
> }
>
> @Bean
> public TestActionActionHandler getTestActionActionHandler() {
> return new TestActionActionHandler();
> }
> }
>
>
> Service call in a presenter
> ------------
> getDispatcher().execute(new TestAction("test"), new
> AsyncCallback<TestActionResult>() {
>
> @Override
> public void onFailure(Throwable caught) {
> // TODO Auto-generated method stub
> Log.debug("TestAction failure!");
> }
>
> @Override
> public void onSuccess(TestActionResult result) {
> // TODO Auto-generated method stub
> Log.debug("TestAction successful!");
> }
> });
>
> Non Working Handler
> ------------------
> public class RetrieveAuditTrailHandler extends
> AbstractActionHandler<RetrieveAuditTrailListAction,
> RetrieveAuditTrailListResult> {
>
>
> @Autowired
> AuditTrailService auditTrailService;
>
> // @Inject
> public RetrieveAuditTrailHandler() {
> super(RetrieveAuditTrailListAction.class);
> }
>
> @Override
> public RetrieveAuditTrailListResult execute(RetrieveAuditTrailListAction
> action, ExecutionContext context) throws ActionException {
> List<AuditTrail> audits =
> auditTrailService.retrieve(action.getFirstResult(), action.getMaxResults());
>
> List<AuditTrailDto> results = new ArrayList<AuditTrailDto>();
>
> for (AuditTrail auditTrail : audits) {
> AuditTrailDto dto = new AuditTrailDto();
> dto.setId((String) auditTrail.get("_id"));
> dto.setApplicationName((String) auditTrail.get("applicationName"));
> dto.setServerNode((String) auditTrail.get("serverNode"));
> dto.setEventName((String) auditTrail.get("eventName"));
> dto.setObjectId((String) auditTrail.get("ojectId"));
> dto.setFilename((String) auditTrail.get("filename"));
> dto.setDescription((String) auditTrail.get("description"));
> }
>
> return new RetrieveAuditTrailListResult(results);
> }
>
> @Override
> public Class<RetrieveAuditTrailListAction> getActionType() {
> return RetrieveAuditTrailListAction.class;
> }
>
> @Override
> public void undo(RetrieveAuditTrailListAction action,
> RetrieveAuditTrailListResult result, ExecutionContext context)
> throws ActionException {
> // Do nothing
> }
> }
>
> Working Handler
> ------------------------
> public class LoginHandler extends AbstractActionHandler<LoginAction,
> LoginResult> {
>
> @Autowired
> private ServletContext servletContext;
>
> @Autowired
> UserService userService;
>
> public LoginHandler() {
> super(LoginAction.class);
> }
>
> @Override
> public LoginResult execute(final LoginAction action, final
> ExecutionContext context) throws ActionException {
>
> LoginResult result = null;
>
> try {
> User user = userService.retrieveUser(action.getLogin());
>
> if (user != null && isValidLogin(action, user)) {
>
> servletContext.setAttribute("login.authenticated", action.getLogin());
>
> String sessionKey = UUID.randomUUID().toString();
> servletContext.setAttribute("sessionId", UUID.randomUUID());
>
> result = new LoginResult(sessionKey);
>
> Log.debug(action.getLogin() + " has logged in");
> Log.debug("Session key: " + result.getSessionKey());
> }
> else {
> throw new LoginException("Invalid User name or Password.");
> }
> }
> catch (Exception e) {
>
> // log the stack trace
> StringWriter stringWriter = new StringWriter();
> PrintWriter printWriter = new PrintWriter(stringWriter);
> e.printStackTrace(printWriter);
>
> Log.debug("Exception e: " + stringWriter.toString());
> // Log.debug("e: " + e);
>
> throw new ActionException(e);
> }
>
> return result;
> }
>
> private Boolean isValidLogin(LoginAction action, User user) {
> Log.debug("LoginHandler - hash: " + " password: " + user.getPassword());
>
> return true;
> }
>
> @Override
> public Class<LoginAction> getActionType() {
> return LoginAction.class;
> }
>
> @Override
> public void undo(LoginAction action, LoginResult result,
> ExecutionContext context) throws ActionException {
> }
> }
>
>



--
Sent from my (old) computer
Reply all
Reply to author
Forward
0 new messages