This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Errors trying to use Gateway with a service-interface to encapsulate a TransactionPage Title Module

Errors trying to use Gateway with a service-interface to encapsulate a Transaction

Aug 25th, 2011, 10:24 PM

Hello,
I'm trying to use a Gateway with a Service interface to weave a transaction around encapsulated processing.

I've simplified my use case to try this out. I have an incoming xml that has lots of orders. I split them and put then on an orders channel. Processing an individual order needs to be in a single transaction of its own so I do not end up with incomplete orders in the DB.

I'm not sure if this is conceptually the right way to achieve a transaction boundary around processing each order or not. Anyway when I execute the code it is unable to create the application context and errors out.
Error:

Code:

java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
....###TRACE Shortened so I can post###
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#3': Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#0' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [interface java.util.List] for method match: [public final boolean $Proxy13.isInterfaceProxied(java.lang.Class), public final void $Proxy13.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException, public final void $Proxy13.setExposeProxy(boolean), public final int $Proxy13.indexOf(org.aopalliance.aop.Advice), public final java.lang.Object $Proxy13.doInTransaction(java.lang.Object), public final int $Proxy13.indexOf(org.springframework.aop.Advisor), public final java.lang.String $Proxy13.toProxyConfigString(), public final void $Proxy13.setTargetSource(org.springframework.aop.TargetSource)]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
....###TRACE Shortened so I can post###
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
... 27 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [interface java.util.List] for method match: [public final boolean $Proxy13.isInterfaceProxied(java.lang.Class), public final void $Proxy13.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException, public final void $Proxy13.setExposeProxy(boolean), public final int $Proxy13.indexOf(org.aopalliance.aop.Advice), public final java.lang.Object $Proxy13.doInTransaction(java.lang.Object), public final int $Proxy13.indexOf(org.springframework.aop.Advisor), public final java.lang.String $Proxy13.toProxyConfigString(), public final void $Proxy13.setTargetSource(org.springframework.aop.TargetSource)]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
....###TRACE Shortened so I can post###
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 43 more
Caused by: java.lang.IllegalArgumentException: Found ambiguous parameter type [interface java.util.List] for method match: [public final boolean $Proxy13.isInterfaceProxied(java.lang.Class), public final void $Proxy13.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException, public final void $Proxy13.setExposeProxy(boolean), public final int $Proxy13.indexOf(org.aopalliance.aop.Advice), public final java.lang.Object $Proxy13.doInTransaction(java.lang.Object), public final int $Proxy13.indexOf(org.springframework.aop.Advisor), public final java.lang.String $Proxy13.toProxyConfigString(), public final void $Proxy13.setTargetSource(org.springframework.aop.TargetSource)]
at org.springframework.util.Assert.isNull(Assert.java:89)
at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:352)
at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:167)
....###TRACE Shortened so I can post###
at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:56)
at org.springframework.integration.handler.ServiceActivatingHandler.<init>(ServiceActivatingHandler.java:34)
at org.springframework.integration.config.ServiceActivatorFactoryBean.createMethodInvokingHandler(ServiceActivatorFactoryBean.java:48)
at org.springframework.integration.config.AbstractStandardMessageHandlerFactoryBean.createHandler(AbstractStandardMessageHandlerFactoryBean.java:72)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.createHandlerInternal(AbstractSimpleMessageHandlerFactoryBean.java:89)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:68)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:31)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 48 more

If I simply remove the service-interface="si.services.TransactionGateway" from the Gateway's configuration it works. Else it throws the above error
Any ideas what this error is about?

I'm open to other ideas to be able to wrap a transaction around the order processing.
Also just for info - I need the <transactional> for the Poller so as not to loose an in process order message from the JDBC store in the event of a JVM crash. And I need the jdbc store operation to be a separate transaction from the order processing (If there is a business Exception during the processing of the order I don't want that message to keep coming back over and over again).