Hello,

I posted a question a few days ago here:
http://forum.springframework.org/showthread.php?t=50400
but didn't get any responses, so I'll try to communicate the issue a little more clearly (I realize my last post was confusing) and hopefully someone knows how to overcome my problem.

I have a Spring bean in my web application that has a scope of request:

Code:
	<bean id="flowStateTracker"
		class="com.fidelity.shares.web.controller.support.FlowStateTracker"
		scope="request">
		<aop:scoped-proxy />
	</bean>
This bean's values are being set/get in a FlowExecutionListenerAdapter during each request:

Code:
public class FlowStateListener extends FlowExecutionListenerAdapter {

	private FlowStateTracker flowStateTracker;

...

	public void requestSubmitted(RequestContext context) {
		try {
			if (context.getActiveFlow() != null) {
				flowStateTracker.setCurrentFlow(context.getActiveFlow().getId());
				flowStateTracker.setCurrentState(context.getCurrentState()
						.getId());
			}
		}
		catch (java.lang.IllegalStateException iies) {
			// do nothing - we are not currently in a flowStateTracker so can't call the validate method anyway
			log
					.warn(
							"Could not retrieve current flowStateTracker.  This is probably okay, hence the warning message.",
							iies);
		}
	}
The FlowStateTracker is then injected into my Flow's Validator for use in commons-validator integration.

Everything works great when I load the app up in Tomcat, but I get the following error in my AbstractXmlFlowExecutionTests:

org.springframework.webflow.engine.ActionExecution Exception: Exception thrown executing [AnnotatedAction@1fe2493 targetAction = com.fidelity.shares.web.controller.ServiceProvider ElectionFormAction@d2883b, attributes = map['method' -> 'bindAndValidate']] in state 'election' of flow 'serviceProviderElection-flow' -- action execution attributes were 'map['method' -> 'bindAndValidate']'; nested exception is java.lang.IllegalStateException: No Scope registered for scope 'request'
at org.springframework.webflow.engine.ActionExecutor. execute(ActionExecutor.java:64)
at org.springframework.webflow.engine.support.ActionT ransitionCriteria.test(ActionTransitionCriteria.ja va:84)
at org.springframework.webflow.engine.support.Transit ionCriteriaChain.test(TransitionCriteriaChain.java :71)
at org.springframework.webflow.engine.Transition.canE xecute(Transition.java:182)
at org.springframework.webflow.engine.Transition.exec ute(Transition.java:195)
at org.springframework.webflow.engine.TransitionableS tate.onEvent(TransitionableState.java:107)
at org.springframework.webflow.engine.Flow.onEvent(Fl ow.java:534)
at org.springframework.webflow.engine.impl.RequestCon trolContextImpl.signalEvent(RequestControlContextI mpl.java:205)
at org.springframework.webflow.engine.impl.FlowExecut ionImpl.signalEvent(FlowExecutionImpl.java:202)
at org.springframework.webflow.test.execution.Abstrac tFlowExecutionTests.signalEvent(AbstractFlowExecut ionTests.java:243)
at org.springframework.webflow.test.execution.Abstrac tFlowExecutionTests.signalEvent(AbstractFlowExecut ionTests.java:195)
at com.fidelity.shares.web.controller.ServiceProvider ElectionFlowIntegrationTest.testElectionOnNextShow Summary(ServiceProviderElectionFlowIntegrationTest .java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.test.context.junit4.SpringTest Method.invoke(SpringTestMethod.java:198)
at org.springframework.test.context.junit4.SpringMeth odRoadie.runTestMethod(SpringMethodRoadie.java:274 )
at org.springframework.test.context.junit4.SpringMeth odRoadie$2.run(SpringMethodRoadie.java:207)
at org.springframework.test.context.junit4.SpringMeth odRoadie.runBeforesThenTestThenAfters(SpringMethod Roadie.java:254)
at org.springframework.test.context.junit4.SpringMeth odRoadie.runWithRepetitions(SpringMethodRoadie.jav a:234)
at org.springframework.test.context.junit4.SpringMeth odRoadie.runTest(SpringMethodRoadie.java:204)
at org.springframework.test.context.junit4.SpringMeth odRoadie.run(SpringMethodRoadie.java:146)
at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.invokeTestMethod(SpringJUnit4ClassRu nner.java:151)
at org.junit.internal.runners.JUnit4ClassRunner.runMe thods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run (JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotec ted(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtecte d(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(J Unit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IllegalStateException: No Scope registered for scope 'request'
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:282)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.aop.target.SimpleBeanTargetSou rce.getTarget(SimpleBeanTargetSource.java:33)
at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.getTarget(Cglib2AopProxy. java:662)
at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:612)
at com.fidelity.shares.web.controller.support.FlowSta teTracker$$EnhancerByCGLIB$$75beca47.getCurrentFlo wAndState(<generated>)
at com.fidelity.shares.web.form.ElectionFormValidator .validate(ElectionFormValidator.java:45)
at org.springframework.webflow.action.FormAction.doVa lidate(FormAction.java:881)
at org.springframework.webflow.action.FormAction.bind AndValidate(FormAction.java:513)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.webflow.util.DispatchMethodInv oker.invoke(DispatchMethodInvoker.java:99)
at org.springframework.webflow.action.MultiAction.doE xecute(MultiAction.java:133)
at org.springframework.webflow.action.AbstractAction. execute(AbstractAction.java:192)
at org.springframework.webflow.engine.AnnotatedAction .execute(AnnotatedAction.java:146)
at org.springframework.webflow.engine.ActionExecutor. execute(ActionExecutor.java:59)
... 34 more
I think I know the root of the problem. In my AbstractXmlFlowExecutionTests test case, I override the following:

Code:
	@Override
	protected FlowServiceLocator createFlowServiceLocator() {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] {"classpath:/spring/allTestContexts.xml"});

		FlowDefinitionRegistry registry = new FlowDefinitionRegistryImpl();

		DefaultFlowServiceLocator locator = new DefaultFlowServiceLocator(
				registry, context);

		XmlFlowRegistrar registrar = new XmlFlowRegistrar(locator);

		if (this.getSubFlowNames() != null) {
			for (int i = 0; i < this.getSubFlowNames().length; i++) {
				registrar.addResource(createFlowDefinitionResource(
						this.flowDir, this.getSubFlowNames()[i]));
			}
		}
		registrar.registerFlowDefinitions(registry);

		return locator;
	}
I do this in order to run integration tests vs unit tests. I think the issue is around the following piece of code:

Code:
ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] {"classpath:/spring/allTestContexts.xml"});
The ClassPathXmlApplicationContext is not "web-aware" and thus does not know what "Request" or "Session" scope is. It looks like I might need to instead instantiate a XmlWebApplicationContext instead, but that seems to complain about needing a ServletContext.

My question is: how can I test my request-scope dependent validator? Is there another way I can load my contexts so that they are web aware?

Thanks for your time and help!
Leo