Announcement Announcement Module
Collapse
No announcement yet.
how to register custom FlowExecutionExceptionHandler? we are increasing finding this. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to register custom FlowExecutionExceptionHandler? we are increasing finding this.

    i created custom FlowExecutionExceptionHandler but don't know on how to reference it properly..even digging into documentation...

    flow
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns="http://www.springframework.org/schema/webflow"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/webflow
            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
    
    	<view-state id="xyz" view="" model="" >
    		...
    		<transition on-exception="xyz.common.exceptions.BusinessLogicException" to="xyz"></transition>
    	</view-state>
    
    	<end-state id="end" view="externalRedirect:/..." />
    
    	<exception-handler bean="customTransitionExecutingFlowExecutionExceptionHandler"/>
    	
    	<!-- same directory -->
    	<bean-import resource="beans.xml"/>
    	
    </flow>
    beans.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    
    	<bean id="customTransitionExecutingFlowExecutionExceptionHandler" class="xyz.web.exception.CustomTransitionExecutingFlowExecutionExceptionHandler">
    	</bean>
    
    </beans>
    then i installed Spring IDE that's why I am receiving the below xml error message..

    Referenced bean "customTransitionExecutingFlowExecutionExceptionHa ndler" cannot be found

  • #2
    my goal is to add error message codes to messageContext... that's why I need to override the handle method..

    Comment


    • #3
      i found this statement by Erwin Verveat (The Definitive Guide to Spring Webflow)

      You can attach any number of exception handlers, to the flow or any of its states. Java
      flow builders have to override the optional buildExceptionhandlers() hook method to
      register exception handlers with the flow:

      public void buildExceptionHandlers() throws FlowBuilderException {
      getFlow().getExceptionHandlerSet().add(getFlowServ iceLocator().getExceptionHandler("handleBar"));
      }
      don't have idea on what class to override and why it is inside the java class not inside the xml (application context)?

      Comment


      • #4
        i think this requirements are common to every spring application..

        i searched already the forum but those threads were not resolved..
        please share on how to register custom FlowExecutionExceptionHandler?

        Comment


        • #5
          Well, In fact I think your configuration is right. I have the exact same thing and it's working for me. Never had a problem with this. Are you completely sure that the beans.xml file is in the same folder where you have the flow definition xml file?

          Comment


          • #6
            Originally posted by triqui View Post
            Well, In fact I think your configuration is right. I have the exact same thing and it's working for me. Never had a problem with this. Are you completely sure that the beans.xml file is in the same folder where you have the flow definition xml file?
            you installed Spring IDE in your eclipse?

            then to confirm the beans.xml ... upon ctrl + click .... the beans.xml file was displayed... therefore, I conclude that it is in correct directory..
            Last edited by eros; May 10th, 2010, 06:14 AM.

            Comment


            • #7
              really don't know on what do i need to check....

              Sir triqui , if you think that we are the same settings... and its working fine... there's something wrong in my part...

              Comment


              • #8
                i'm begging to the spring community specially to spring webflow gurus...

                how do you register your custom FlowExecutionExceptionHandler?

                thanks

                Comment


                • #9
                  I typically don't import beans.xml files in individual flows. Maybe you could try defining your exception handler in a top-level beans.xml file, see if that works?

                  For the record, that's what I'm doing. I have a global flow exception handler defined as a singleton bean in my top-level beans.xml file. Then I just reference the bean by it's id as an exception handler, and that's that.

                  By the way, I believe imported beans are automatically flow-scoped, unless I'm mistaken.

                  Comment


                  • #10
                    Originally posted by InverseFalcon View Post
                    I typically don't import beans.xml files in individual flows. Maybe you could try defining your exception handler in a top-level beans.xml file, see if that works?
                    .....
                    do you mean, defining in the applicationContext?

                    Comment


                    • #11
                      xml setteings update

                      web.xml
                      Code:
                      ...
                      	<context-param>
                      		<param-name>contextConfigLocation</param-name>
                      		<param-value><![CDATA[
                      			classpath:data-access-config.xml,
                      			classpath:service-config.xml,
                      			classpath:bl-config.xml,
                      			classpath:dao-config.xml,
                      			classpath:webmvc-config.xml,
                      			classpath:webflow-config.xml,
                      			classpath:controller-config.xml,
                      			classpath:security-config.xml,
                      		]]></param-value>
                      	</context-param>
                      	
                      	<listener>
                      		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
                      	</listener>
                      
                      	<servlet>
                      	    <servlet-name>resources</servlet-name>
                      	    <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
                      	    <load-on-startup>0</load-on-startup>
                      	</servlet>
                      	
                      	<servlet>
                      		<servlet-name>springproj</servlet-name>
                      		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                      	    <init-param>
                      	        <param-name>contextConfigLocation</param-name>
                      	        <param-value></param-value>
                      	    </init-param>
                      		<load-on-startup>1</load-on-startup>
                      	</servlet>
                      ...
                      webflow-config.xml
                      Code:
                      <?xml version="1.0" encoding="UTF-8"?>
                      <beans xmlns="http://www.springframework.org/schema/beans"
                      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      	xmlns:flow="http://www.springframework.org/schema/webflow-config"
                      	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                      		http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
                      
                      	<!-- Executes flows: the entry point into the Spring Web Flow system -->
                      	<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry" >
                      		<flow:flow-execution-listeners>
                      			<flow:listener ref="securityFlowExecutionListener"/>
                      		</flow:flow-execution-listeners>
                      	</flow:flow-executor>
                      	
                      	<bean id="securityFlowExecutionListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener">
                      	</bean>
                      	
                      	<!-- The registry of executable flow definitions -->
                      	<flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
                          	<flow:flow-location-pattern value="/WEB-INF/flows/**/*-flow.xml"/>
                      	</flow:flow-registry>
                      
                      	<flow:flow-builder-services id="flowBuilderServices" development="true" 
                      		view-factory-creator="mvcViewFactoryCreator" />
                      
                      	<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
                          	<property name="viewResolvers" ref="tilesViewResolver"/>
                      	</bean>
                      	
                      	<bean id="customTransitionExecutingFlowExecutionExceptionHandler" class="xyz.web.exception.CustomTransitionExecutingFlowExecutionExceptionHandler">
                      	</bean>
                      
                      </beans>
                      flow definition
                      Code:
                      	....
                      	<!-- END -->
                      	<end-state id="end" view="externalRedirect:/xxx/xxx-flow" />
                      
                      	<exception-handler bean="customTransitionExecutingFlowExecutionExceptionHandler"/>
                      <!--	<bean-import resource="beans.xml"/>-->
                      	
                      </flow>
                      but still the error remains..
                      Last edited by eros; May 12th, 2010, 12:41 AM.

                      Comment


                      • #12
                        Originally posted by eros View Post
                        do you mean, defining in the applicationContext?
                        There are several ways to do this, and you aren't limited to a single file.

                        For example, my file is called "web-application-config.xml", and all it does is import the other xml files in the same directory.

                        Each one has their own purpose. I've got a dao-config.xml, webflow-config.xml, webmvc-config.xml, flow-security-config.xml, flow-utils.xml (for helper beans I've written), and an application-beans.xml (for all of my application-specific beans).

                        However, from what you've posted, it SHOULD be working...At this point I'm baffled. The bean is defined, and you're referencing it properly... I don't know what to tell you here. Something subtle is going on, so play around with it and see if you can figure it out.

                        Comment


                        • #13
                          >Sir InverseFalcon,
                          Thanks a lot for spending time to share us your knowledge...

                          i can't create a jira for this because others able to set it up properly and working...

                          i think, need to beg a time to Spring Webflow Team... to guide me on how to figure it out...

                          Comment


                          • #14
                            my main goal is
                            1) throw exception
                            2) cancel the transition to subflow
                            3) back to originating state
                            3) display an error message

                            in my other scenario (A scenario):
                            1) catching the exception
                            2) set the error message code to messageContext
                            3) then its automatically back to originating state and it displays the corresponding error message.

                            my problem is... when I use A scenario, its still do the transition to subflow.. in other word, the behavior is different if you set the <transition on to> to a subflow state... it doesn't do the 3) of A scenario...

                            that's why I would like to implement an exception handler to handle that behavior (a bug?)....

                            >to Spring Webflow Team,
                            please guide me on how to figure it out because its something different... cannot see in any documentation.. thanks a lot..

                            any hints/ideas are highly appreciated.

                            Comment

                            Working...
                            X