You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Wang Yan <wy...@gmail.com> on 2019/03/07 20:46:40 UTC

I could not use .transacted() in camel route with SpringBoot, got exception

I could not use  .transacted() in camel route with SpringBoot, got exception
No bean could be found in the registry of type: PlatformTransactionManager"
Is it expected behavior for SpringBoot+Camel setup?

below is example of the code

https://github.com/apache/camel/blob/master/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java



public class JavaDslTransactedNoTXManagerTest extends ContextTestSupport {
@Test
public void testTransactedNoTXManager() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.transacted()
.to("mock:result");
}
});
try {
context.start();
fail("Should have thrown an exception");
} catch (FailedToCreateRouteException e) {
NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.
getCause());
assertEquals("No bean could be found in the registry of type:
PlatformTransactionManager", cause.getMessage());
}
}
@Override
public boolean isUseRouteBuilder() {
return false;
}
}

Fwd: I could not use .transacted() in camel route with SpringBoot, got exception

Posted by Wang Yan <wy...@gmail.com>.
thanks for the hints

i tried below code to get PlatformTransactionManager  instance from spring
boot context
but it failed with below exceptions. do i need more configurations for
getting the instance of PlatformTransactionManager  ?




    @Resource
    private PlatformTransactionManager transactionManager;

APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method webMvcMetricsFilter in
org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration
required a bean of type
'org.springframework.transaction.PlatformTransactionManager' that could not
be found.
        - Bean method 'transactionManager' not loaded because
@ConditionalOnClass did not find required class
'com.atomikos.icatch.jta.UserTransactionManager'
        - Bean method 'transactionManager' not loaded because
@ConditionalOnClass did not find required class
'bitronix.tm.jndi.BitronixContext'
        - Bean method 'transactionManager' not loaded because
@ConditionalOnJndi JNDI environment is not available
        - Bean method 'transactionManager' not loaded because
@ConditionalOnClass did not find required classes
'com.arjuna.ats.jta.UserTransaction',
'org.jboss.tm.XAResourceRecoveryRegistry'

---------- Forwarded message ---------
From: Wang Yan <wy...@gmail.com>
Date: Thu, Mar 7, 2019 at 9:46 PM
Subject: I could not use .transacted() in camel route with SpringBoot, got
exception
To: <us...@camel.apache.org>



I could not use  .transacted() in camel route with SpringBoot, got exception
No bean could be found in the registry of type: PlatformTransactionManager"
Is it expected behavior for SpringBoot+Camel setup?

below is example of the code

https://github.com/apache/camel/blob/master/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java



public class JavaDslTransactedNoTXManagerTest extends ContextTestSupport {
@Test
public void testTransactedNoTXManager() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.transacted()
.to("mock:result");
}
});
try {
context.start();
fail("Should have thrown an exception");
} catch (FailedToCreateRouteException e) {
NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.
getCause());
assertEquals("No bean could be found in the registry of type:
PlatformTransactionManager", cause.getMessage());
}
}
@Override
public boolean isUseRouteBuilder() {
return false;
}
}

Re: I could not use .transacted() in camel route with SpringBoot, got exception

Posted by Willem Jiang <wi...@gmail.com>.
The transacted DSL is built on top of Spring
PlatformTransactionManager.  If you want to use the transacted with
Spring Boot, you need to make sure you can get
PlatformTransactionManager from the application context.

Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Fri, Mar 8, 2019 at 4:46 AM Wang Yan <wy...@gmail.com> wrote:
>
> I could not use  .transacted() in camel route with SpringBoot, got exception
> No bean could be found in the registry of type: PlatformTransactionManager"
> Is it expected behavior for SpringBoot+Camel setup?
>
> below is example of the code
>
> https://github.com/apache/camel/blob/master/components/camel-spring/src/test/java/org/apache/camel/spring/processor/JavaDslTransactedNoTXManagerTest.java
>
>
>
> public class JavaDslTransactedNoTXManagerTest extends ContextTestSupport {
> @Test
> public void testTransactedNoTXManager() throws Exception {
> context.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("direct:start")
> .transacted()
> .to("mock:result");
> }
> });
> try {
> context.start();
> fail("Should have thrown an exception");
> } catch (FailedToCreateRouteException e) {
> NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.
> getCause());
> assertEquals("No bean could be found in the registry of type:
> PlatformTransactionManager", cause.getMessage());
> }
> }
> @Override
> public boolean isUseRouteBuilder() {
> return false;
> }
> }