Announcement Announcement Module
Collapse
No announcement yet.
<Transition on-exception not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <Transition on-exception not working

    Hi all,
    Somehow my flow does not seem to find the exception although everything seems to be in place. I am using webflow 2.1.1 and spring 3.0.3

    [ code]
    Flow:
    <action-state id="lookUpCustomer">
    <evaluate expression="accountService.findCustomer(requestPar ameters.username,requestParameters.password)"
    result="requestScope.customer" />
    <transition on="success" to="showOrder">
    <evaluate expression="order.setCustomer(customer)"/>
    </transition>
    <transition on-exception="se.shirtshop.services.CustomerNotFoundE xception"
    to="enterCustomerId">
    <set name="flashScope.errorMessage" value="resourceBundle.customerNotFoundMessage"/>
    </transition>
    </action-state>
    [/code ]

    [ code]
    Class method:
    @Override
    public Customer findCustomer(String username, String password) throws CustomerNotFoundException {
    if (username.equals(customerDb.getUsername()) && password.equals(customerDb.getPassword())) {
    return customerDb;
    }
    else throw new CustomerNotFoundException();
    }
    [/code ]


    [ code]
    Stacktrace:
    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecut ionException: Exception thrown executing [AnnotatedAction@76f4da6d targetAction = [EvaluateAction@6ff80c0e expression = accountService.findCustomer(requestParameters.user name,requestParameters.password), resultExpression = requestScope.customer], attributes = map[[empty]]] in state 'lookUpCustomer' of flow 'customer-flow' -- action execution attributes were 'map[[empty]]'
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:656)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)

    root cause

    org.springframework.webflow.execution.ActionExecut ionException: Exception thrown executing [AnnotatedAction@76f4da6d targetAction = [EvaluateAction@6ff80c0e expression = accountService.findCustomer(requestParameters.user name,requestParameters.password), resultExpression = requestScope.customer], attributes = map[[empty]]] in state 'lookUpCustomer' of flow 'customer-flow' -- action execution attributes were 'map[[empty]]'
    org.springframework.webflow.execution.ActionExecut or.execute(ActionExecutor.java:60)
    org.springframework.webflow.engine.ActionState.doE nter(ActionState.java:101)
    org.springframework.webflow.engine.State.enter(Sta te.java:194)
    org.springframework.webflow.engine.Transition.exec ute(Transition.java:227)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.execute(FlowExecutionImpl.java:391)
    org.springframework.webflow.engine.impl.RequestCon trolContextImpl.execute(RequestControlContextImpl. java:214)
    org.springframework.webflow.engine.TransitionableS tate.handleEvent(TransitionableState.java:119)
    org.springframework.webflow.engine.Flow.handleEven t(Flow.java:555)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.handleEvent(FlowExecutionImpl.java:386)
    org.springframework.webflow.engine.impl.RequestCon trolContextImpl.handleEvent(RequestControlContextI mpl.java:210)
    org.springframework.webflow.engine.ViewState.handl eEvent(ViewState.java:230)
    org.springframework.webflow.engine.ViewState.resum e(ViewState.java:196)
    org.springframework.webflow.engine.Flow.resume(Flo w.java:545)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.resume(FlowExecutionImpl.java:259)
    org.springframework.webflow.executor.FlowExecutorI mpl.resumeExecution(FlowExecutorImpl.java:169)
    org.springframework.webflow.mvc.servlet.FlowHandle rAdapter.handle(FlowHandlerAdapter.java:183)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:774)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)

    root cause

    org.springframework.dao.EmptyResultDataAccessExcep tion: Incorrect result size: expected 1, actual 0
    org.springframework.dao.support.DataAccessUtils.re quiredSingleResult(DataAccessUtils.java:71)
    org.springframework.jdbc.core.JdbcTemplate.queryFo rObject(JdbcTemplate.java:734)
    se.shirtshop.sqlconnections.SqlCustomerRepository. getCustomerFromDb(SqlCustomerRepository.java:41)
    se.shirtshop.services.DatabaseService.getCustomerF romDb(DatabaseService.java:32)
    se.shirtshop.services.AccountServiceImpl.findCusto mer(AccountServiceImpl.java:40)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.expression.spel.support.Reflec tiveMethodExecutor.execute(ReflectiveMethodExecuto r.java:58)
    org.springframework.expression.spel.ast.MethodRefe rence.getValueInternal(MethodReference.java:104)
    org.springframework.expression.spel.ast.CompoundEx pression.getValueInternal(CompoundExpression.java: 57)
    org.springframework.expression.spel.ast.SpelNodeIm pl.getTypedValue(SpelNodeImpl.java:102)
    org.springframework.expression.spel.standard.SpelE xpression.getValue(SpelExpression.java:97)
    org.springframework.binding.expression.spel.Spring ELExpression.getValue(SpringELExpression.java:78)
    org.springframework.webflow.action.EvaluateAction. doExecute(EvaluateAction.java:75)
    org.springframework.webflow.action.AbstractAction. execute(AbstractAction.java:188)
    org.springframework.webflow.execution.AnnotatedAct ion.execute(AnnotatedAction.java:145)
    org.springframework.webflow.execution.ActionExecut or.execute(ActionExecutor.java:51)
    org.springframework.webflow.engine.ActionState.doE nter(ActionState.java:101)
    org.springframework.webflow.engine.State.enter(Sta te.java:194)
    org.springframework.webflow.engine.Transition.exec ute(Transition.java:227)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.execute(FlowExecutionImpl.java:391)
    org.springframework.webflow.engine.impl.RequestCon trolContextImpl.execute(RequestControlContextImpl. java:214)
    org.springframework.webflow.engine.TransitionableS tate.handleEvent(TransitionableState.java:119)
    org.springframework.webflow.engine.Flow.handleEven t(Flow.java:555)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.handleEvent(FlowExecutionImpl.java:386)
    org.springframework.webflow.engine.impl.RequestCon trolContextImpl.handleEvent(RequestControlContextI mpl.java:210)
    org.springframework.webflow.engine.ViewState.handl eEvent(ViewState.java:230)
    org.springframework.webflow.engine.ViewState.resum e(ViewState.java:196)
    org.springframework.webflow.engine.Flow.resume(Flo w.java:545)
    org.springframework.webflow.engine.impl.FlowExecut ionImpl.resume(FlowExecutionImpl.java:259)
    org.springframework.webflow.executor.FlowExecutorI mpl.resumeExecution(FlowExecutorImpl.java:169)
    org.springframework.webflow.mvc.servlet.FlowHandle rAdapter.handle(FlowHandlerAdapter.java:183)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:774)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    [/code ]

    The trace is telling me that it map is empty and it expected 1 but got 0 . Duh, it's suppose to have zero and throw exception and error message via bundle.
    Any thoughts highly appreciated.
    Thanks,
    Cantheman
    Last edited by Cantheman; May 25th, 2011, 04:17 AM.

  • #2
    Please use [ code][/code ] tags when posting code and post the full stacktrace... Judging from your description your if/else is useless and you get an InvalidResultSetSizeException which is a subclass of DataAccessException. Which you get with either jdbctemplate when doing a queryForObject or using hibernate getting a single element.

    Comment


    • #3
      Hi Marten,
      don't know if I did it correctly with the tags. Aren't they suppose to highlight?

      /Cantheman

      Comment


      • #4
        They don't highlight, they only preserve the formatting (also remove the space) and please put each section in its own code block instead of a large enclosing all in one code block.

        Originally posted by mdeinum
        Judging from your description your if/else is useless and you get an InvalidResultSetSizeException which is a subclass of DataAccessException. Which you get with either jdbctemplate when doing a queryForObject or using hibernate getting a single element.
        Which is obviously what you get, judging from your stacktrace... So basically your if/else is useless... Either transition-on a different exception (the one you actually get) or put a try/catch in there next to the if/else...

        Comment


        • #5
          Hi Martin,
          it works now. Thank you very much! I have spent many hours on this so typical that it's the small details. Again thanks!
          It was the org.springframework.webflow.execution.ActionExecut ionException that was needed!
          /Cantheman

          Comment

          Working...
          X