You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anand_tech <an...@gmail.com> on 2013/08/16 11:56:50 UTC

Camel Hibernate : org.hibernate.HibernateException: persist is not valid without active transaction

Hi,

I am trying to do a small poc with camel-hibernate component. First my
versions are :
Camel-core 2.9.0
Camel-hibernate 2.10.0
Spring - 3.0.6
Hibernate - 3.6.0

Below is my route : 

from("direct:foo")
		.process(new Processor() {
			
			@Override
			public void process(Exchange arg0) throws Exception {
				Queue q = new Queue();
				q.setName("hi");
				arg0.getIn().setBody(q);
			}
		})
		.to("hibernate:com.poc.camel.interesting.Queue");

from("direct:services")
	
.errorHandler(deadLetterChannel("direct:foo").useOriginalMessage()).end().to("http://somewebserver")

This is my configuration xml

<camelContext id="customCamelContext"
xmlns="http://camel.apache.org/schema/spring"
		trace="true" streamCache="true">
		<propertyPlaceholder id="camelProperties"
			location="classpath:camel.properties" />
		<camel:routeBuilder ref="customRouteBuilder" /> 
	</camelContext>

	

	<camel:proxy id="appService"
serviceInterface="com.poc.camel.interesting.ApiServices"
		serviceUrl="direct:services" camelContextId="tmeCamelContext" />

<bean id="hibernate"
class="org.apacheextras.camel.component.hibernate.HibernateComponent">
  <property name="sessionFactory" ref="sessionFactory"/>
  <property name="transactionStrategy" ref="springTransactionStrategy"/>
</bean>
 

<bean id="springTransactionStrategy"
class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
  <constructor-arg ref="sessionFactory"/>
  <constructor-arg ref="transactionTemplate"/>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
  <property name="transactionManager" ref="transactionManager"/>
</bean>

Now the flow is : I make a HTTP request to some webservice and when it fails
it goes to deadletter error handler which is pointed to direct:foo endpoint.
This then persists a Queue object in DB using camel-hibernate component.
Now i get following exception by doing all of this:

[2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpMethodDirector
INFO - Retrying request
[2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpConnection DEBUG
- Open connection to 10.152.160.18:8065
[2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
DEBUG - Closing the connection.
[2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
DEBUG - Method retry handler returned false. Automatic recovery will not be
attempted
[2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpConnection DEBUG
- Releasing connection back to connection manager.
[2013-08-16 14:55:11,994]
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
Freeing connection,
hostConfig=HostConfiguration[host=http://10.152.160.18:8065]
[2013-08-16 14:55:11,994]
org.apache.commons.httpclient.util.IdleConnectionHandler DEBUG - Adding
connection at: 1376645111994
[2013-08-16 14:55:11,995]
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
Notifying no-one, there are no waiting threads
[2013-08-16 14:55:11,996] org.apache.camel.processor.DeadLetterChannel DEBUG
- Failed delivery for exchangeId: ID-CHDSEZ102214D-61690-1376645101689-0-1.
On delivery attempt: 0 caught: java.net.ConnectException: Connection
refused: connect
[2013-08-16 14:55:12,007] org.apache.camel.processor.SendProcessor DEBUG -
>>>> Endpoint[direct://foo] Exchange[Message: BeanInvocation public abstract
com.poc.camel.interesting.ServiceProviderPayload
com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]]
[2013-08-16 14:55:12,007] org.apache.camel.processor.interceptor.Tracer INFO
- ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)
http://ThirdPartyServers?throwExceptionOnFailure=false -->  <<<
Pattern:InOnly, BodyType:org.apache.camel.component.bean.BeanInvocation,
Body:BeanInvocation public abstract
com.poc.camel.interesting.ServiceProviderPayload
com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]
[2013-08-16 14:55:12,009] org.apache.camel.processor.interceptor.Tracer INFO
- ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)  -->
hibernate://com.poc.camel.interesting.Queue <<< Pattern:InOnly,
BodyType:com.poc.camel.interesting.Queue,
Body:com.poc.camel.interesting.Queue@a4be02
[2013-08-16 14:55:12,010] org.apache.camel.processor.SendProcessor DEBUG -
>>>> Endpoint[hibernate://com.poc.camel.interesting.Queue] Exchange[Message:
com.poc.camel.interesting.Queue@a4be02]
[2013-08-16 14:55:12,039]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Creating new transaction with name [null]:
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[2013-08-16 14:55:12,286] org.hibernate.impl.SessionImpl DEBUG - opened
session at timestamp: 13766451120
[2013-08-16 14:55:12,286]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Opened new Session [org.hibernate.impl.SessionImpl@1f53293] for Hibernate
transaction
[2013-08-16 14:55:12,291]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Preparing JDBC Connection of Hibernate Session
[org.hibernate.impl.SessionImpl@1f53293]
[2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
begin
[2013-08-16 14:55:12,329] org.hibernate.jdbc.ConnectionManager DEBUG -
opening JDBC connection
[2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
current autocommit status: true
[2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
disabling autocommit
[2013-08-16 14:55:12,330] org.hibernate.impl.SessionImpl DEBUG - opened
session at timestamp: 13766451123
[2013-08-16 14:55:12,412]
org.springframework.transaction.support.TransactionTemplate DEBUG -
Initiating transaction rollback on application exception
org.hibernate.HibernateException: persist is not valid without active
transaction
	at
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:341)
	at $Proxy42.persist(Unknown Source)
	at
org.apacheextras.camel.component.hibernate.HibernateProducer$1.doInTransaction(HibernateProducer.java:54)
	at
org.apacheextras.camel.component.hibernate.SpringTransactionStrategy$1.doInTransaction(SpringTransactionStrategy.java:43)
	at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
	at
org.apacheextras.camel.component.hibernate.SpringTransactionStrategy.execute(SpringTransactionStrategy.java:40)
	at
org.apacheextras.camel.component.hibernate.HibernateProducer.process(HibernateProducer.java:49)
	at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
	at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
	at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
	at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:741)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:265)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
	at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:85)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
	at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:48)
	at
org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:83)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at
org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithbody(AbstractCamelInvocationHandler.java:101)
	at
org.apache.camel.component.bean.CamelInvocationHandler.invoke(CamelInvocationHandler.java:44)
	at $Proxy34.performOperation(Unknown Source)
	at
com.poc.camel.interesting.CamelDeadLetterTester.test(CamelDeadLetterTester.java:17)
	at
com.poc.camel.interesting.CamelDeadLetterTester.main(CamelDeadLetterTester.java:25)
[2013-08-16 14:55:12,415]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Initiating transaction rollback
[2013-08-16 14:55:12,416]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Rolling back Hibernate transaction on Session
[org.hibernate.impl.SessionImpl@1f53293]
[2013-08-16 14:55:12,416] org.hibernate.transaction.JDBCTransaction DEBUG -
rollback
[2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
re-enabling autocommit
[2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
rolled back JDBC Connection
[2013-08-16 14:55:12,417] org.hibernate.jdbc.ConnectionManager DEBUG -
transaction completed on session with on_close connection release mode; be
sure to close the session to release JDBC resources!
[2013-08-16 14:55:12,417]
org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
Closing Hibernate Session [org.hibernate.impl.SessionImpl@1f53293] after
transaction
[2013-08-16 14:55:12,417]
org.springframework.orm.hibernate3.SessionFactoryUtils DEBUG - Closing
Hibernate Session
[2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open
ResultSets: 0, globally: 0)]
[2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
transaction completed on session with on_close connection release mode; be
sure to close the session to release JDBC resources!
[2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
DEBUG - Failed delivery for exchangeId:
ID-CHDSEZ102214D-61690-1376645101689-0-1. On delivery attempt: 0 caught:
org.hibernate.HibernateException: persist is not valid without active
transaction
[2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
ERROR - Failed delivery for exchangeId:
ID-CHDSEZ102214D-61690-1376645101689-0-1. Exhausted after delivery attempt:
1 caught: org.hibernate.HibernateException: persist is not valid without
active transaction

So is it because of my outdated versions of hibernate and spring. Or am I
missing something in my transaction/spring/hibernate configuration.

I went through CAMEL-5849 ticket at JIRA, but if we dont have an option of
changing version, what's the alternative ? I referred to camel-hibernate
example given at Camel website for whole poc.




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Hibernate-org-hibernate-HibernateException-persist-is-not-valid-without-active-transaction-tp5737387.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Hibernate : org.hibernate.HibernateException: persist is not valid without active transaction

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Aug 16, 2013 at 3:07 PM, Christian Müller
<ch...@gmail.com> wrote:
> Also use Camel 2.11 if possible.
>

Yeah there is an example
http://camel.apache.org/hibernate-example.html

And the camel-hibernate component has been improved in this release
(though its from camel-extra).


> Best,
> Christian
> Am 16.08.2013 11:57 schrieb "anand_tech" <an...@gmail.com>:
>
>> Hi,
>>
>> I am trying to do a small poc with camel-hibernate component. First my
>> versions are :
>> Camel-core 2.9.0
>> Camel-hibernate 2.10.0
>> Spring - 3.0.6
>> Hibernate - 3.6.0
>>
>> Below is my route :
>>
>> from("direct:foo")
>>                 .process(new Processor() {
>>
>>                         @Override
>>                         public void process(Exchange arg0) throws
>> Exception {
>>                                 Queue q = new Queue();
>>                                 q.setName("hi");
>>                                 arg0.getIn().setBody(q);
>>                         }
>>                 })
>>                 .to("hibernate:com.poc.camel.interesting.Queue");
>>
>> from("direct:services")
>>
>>
>> .errorHandler(deadLetterChannel("direct:foo").useOriginalMessage()).end().to("
>> http://somewebserver")
>>
>> This is my configuration xml
>>
>> <camelContext id="customCamelContext"
>> xmlns="http://camel.apache.org/schema/spring"
>>                 trace="true" streamCache="true">
>>                 <propertyPlaceholder id="camelProperties"
>>                         location="classpath:camel.properties" />
>>                 <camel:routeBuilder ref="customRouteBuilder" />
>>         </camelContext>
>>
>>
>>
>>         <camel:proxy id="appService"
>> serviceInterface="com.poc.camel.interesting.ApiServices"
>>                 serviceUrl="direct:services"
>> camelContextId="tmeCamelContext" />
>>
>> <bean id="hibernate"
>> class="org.apacheextras.camel.component.hibernate.HibernateComponent">
>>   <property name="sessionFactory" ref="sessionFactory"/>
>>   <property name="transactionStrategy" ref="springTransactionStrategy"/>
>> </bean>
>>
>>
>> <bean id="springTransactionStrategy"
>>
>> class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
>>   <constructor-arg ref="sessionFactory"/>
>>   <constructor-arg ref="transactionTemplate"/>
>> </bean>
>>
>> <bean id="transactionManager"
>> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>>   <property name="sessionFactory" ref="sessionFactory"/>
>> </bean>
>>
>> <bean id="transactionTemplate"
>> class="org.springframework.transaction.support.TransactionTemplate">
>>   <property name="transactionManager" ref="transactionManager"/>
>> </bean>
>>
>> Now the flow is : I make a HTTP request to some webservice and when it
>> fails
>> it goes to deadletter error handler which is pointed to direct:foo
>> endpoint.
>> This then persists a Queue object in DB using camel-hibernate component.
>> Now i get following exception by doing all of this:
>>
>> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpMethodDirector
>> INFO - Retrying request
>> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpConnection
>> DEBUG
>> - Open connection to 10.152.160.18:8065
>> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
>> DEBUG - Closing the connection.
>> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
>> DEBUG - Method retry handler returned false. Automatic recovery will not be
>> attempted
>> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpConnection
>> DEBUG
>> - Releasing connection back to connection manager.
>> [2013-08-16 14:55:11,994]
>> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
>> Freeing connection,
>> hostConfig=HostConfiguration[host=http://10.152.160.18:8065]
>> [2013-08-16 14:55:11,994]
>> org.apache.commons.httpclient.util.IdleConnectionHandler DEBUG - Adding
>> connection at: 1376645111994
>> [2013-08-16 14:55:11,995]
>> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
>> Notifying no-one, there are no waiting threads
>> [2013-08-16 14:55:11,996] org.apache.camel.processor.DeadLetterChannel
>> DEBUG
>> - Failed delivery for exchangeId: ID-CHDSEZ102214D-61690-1376645101689-0-1.
>> On delivery attempt: 0 caught: java.net.ConnectException: Connection
>> refused: connect
>> [2013-08-16 14:55:12,007] org.apache.camel.processor.SendProcessor DEBUG -
>> >>>> Endpoint[direct://foo] Exchange[Message: BeanInvocation public
>> abstract
>> com.poc.camel.interesting.ServiceProviderPayload
>>
>> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
>> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]]
>> [2013-08-16 14:55:12,007] org.apache.camel.processor.interceptor.Tracer
>> INFO
>> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)
>> http://ThirdPartyServers?throwExceptionOnFailure=false -->  <<<
>> Pattern:InOnly, BodyType:org.apache.camel.component.bean.BeanInvocation,
>> Body:BeanInvocation public abstract
>> com.poc.camel.interesting.ServiceProviderPayload
>>
>> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
>> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]
>> [2013-08-16 14:55:12,009] org.apache.camel.processor.interceptor.Tracer
>> INFO
>> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)  -->
>> hibernate://com.poc.camel.interesting.Queue <<< Pattern:InOnly,
>> BodyType:com.poc.camel.interesting.Queue,
>> Body:com.poc.camel.interesting.Queue@a4be02
>> [2013-08-16 14:55:12,010] org.apache.camel.processor.SendProcessor DEBUG -
>> >>>> Endpoint[hibernate://com.poc.camel.interesting.Queue]
>> Exchange[Message:
>> com.poc.camel.interesting.Queue@a4be02]
>> [2013-08-16 14:55:12,039]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Creating new transaction with name [null]:
>> PROPAGATION_REQUIRED,ISOLATION_DEFAULT
>> [2013-08-16 14:55:12,286] org.hibernate.impl.SessionImpl DEBUG - opened
>> session at timestamp: 13766451120
>> [2013-08-16 14:55:12,286]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Opened new Session [org.hibernate.impl.SessionImpl@1f53293] for Hibernate
>> transaction
>> [2013-08-16 14:55:12,291]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Preparing JDBC Connection of Hibernate Session
>> [org.hibernate.impl.SessionImpl@1f53293]
>> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
>> begin
>> [2013-08-16 14:55:12,329] org.hibernate.jdbc.ConnectionManager DEBUG -
>> opening JDBC connection
>> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
>> current autocommit status: true
>> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
>> disabling autocommit
>> [2013-08-16 14:55:12,330] org.hibernate.impl.SessionImpl DEBUG - opened
>> session at timestamp: 13766451123
>> [2013-08-16 14:55:12,412]
>> org.springframework.transaction.support.TransactionTemplate DEBUG -
>> Initiating transaction rollback on application exception
>> org.hibernate.HibernateException: persist is not valid without active
>> transaction
>>         at
>>
>> org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:341)
>>         at $Proxy42.persist(Unknown Source)
>>         at
>>
>> org.apacheextras.camel.component.hibernate.HibernateProducer$1.doInTransaction(HibernateProducer.java:54)
>>         at
>>
>> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy$1.doInTransaction(SpringTransactionStrategy.java:43)
>>         at
>>
>> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
>>         at
>>
>> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy.execute(SpringTransactionStrategy.java:40)
>>         at
>>
>> org.apacheextras.camel.component.hibernate.HibernateProducer.process(HibernateProducer.java:49)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>>         at
>>
>> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>>         at
>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>>         at
>>
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>>         at
>>
>> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>>         at
>>
>> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>>         at
>>
>> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>>         at
>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:741)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:265)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>>         at
>>
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>>         at
>>
>> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:85)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>>         at
>>
>> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>>         at
>>
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>>         at
>>
>> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>>         at
>>
>> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
>>         at
>>
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>>         at
>>
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>>         at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
>>         at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
>>         at
>>
>> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:48)
>>         at
>>
>> org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:83)
>>         at
>> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>         at
>>
>> org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithbody(AbstractCamelInvocationHandler.java:101)
>>         at
>>
>> org.apache.camel.component.bean.CamelInvocationHandler.invoke(CamelInvocationHandler.java:44)
>>         at $Proxy34.performOperation(Unknown Source)
>>         at
>>
>> com.poc.camel.interesting.CamelDeadLetterTester.test(CamelDeadLetterTester.java:17)
>>         at
>>
>> com.poc.camel.interesting.CamelDeadLetterTester.main(CamelDeadLetterTester.java:25)
>> [2013-08-16 14:55:12,415]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Initiating transaction rollback
>> [2013-08-16 14:55:12,416]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Rolling back Hibernate transaction on Session
>> [org.hibernate.impl.SessionImpl@1f53293]
>> [2013-08-16 14:55:12,416] org.hibernate.transaction.JDBCTransaction DEBUG -
>> rollback
>> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
>> re-enabling autocommit
>> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
>> rolled back JDBC Connection
>> [2013-08-16 14:55:12,417] org.hibernate.jdbc.ConnectionManager DEBUG -
>> transaction completed on session with on_close connection release mode; be
>> sure to close the session to release JDBC resources!
>> [2013-08-16 14:55:12,417]
>> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
>> Closing Hibernate Session [org.hibernate.impl.SessionImpl@1f53293] after
>> transaction
>> [2013-08-16 14:55:12,417]
>> org.springframework.orm.hibernate3.SessionFactoryUtils DEBUG - Closing
>> Hibernate Session
>> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
>> releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open
>> ResultSets: 0, globally: 0)]
>> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
>> transaction completed on session with on_close connection release mode; be
>> sure to close the session to release JDBC resources!
>> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
>> DEBUG - Failed delivery for exchangeId:
>> ID-CHDSEZ102214D-61690-1376645101689-0-1. On delivery attempt: 0 caught:
>> org.hibernate.HibernateException: persist is not valid without active
>> transaction
>> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
>> ERROR - Failed delivery for exchangeId:
>> ID-CHDSEZ102214D-61690-1376645101689-0-1. Exhausted after delivery attempt:
>> 1 caught: org.hibernate.HibernateException: persist is not valid without
>> active transaction
>>
>> So is it because of my outdated versions of hibernate and spring. Or am I
>> missing something in my transaction/spring/hibernate configuration.
>>
>> I went through CAMEL-5849 ticket at JIRA, but if we dont have an option of
>> changing version, what's the alternative ? I referred to camel-hibernate
>> example given at Camel website for whole poc.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Camel-Hibernate-org-hibernate-HibernateException-persist-is-not-valid-without-active-transaction-tp5737387.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Hibernate : org.hibernate.HibernateException: persist is not valid without active transaction

Posted by Christian Müller <ch...@gmail.com>.
Also use Camel 2.11 if possible.

Best,
Christian
Am 16.08.2013 11:57 schrieb "anand_tech" <an...@gmail.com>:

> Hi,
>
> I am trying to do a small poc with camel-hibernate component. First my
> versions are :
> Camel-core 2.9.0
> Camel-hibernate 2.10.0
> Spring - 3.0.6
> Hibernate - 3.6.0
>
> Below is my route :
>
> from("direct:foo")
>                 .process(new Processor() {
>
>                         @Override
>                         public void process(Exchange arg0) throws
> Exception {
>                                 Queue q = new Queue();
>                                 q.setName("hi");
>                                 arg0.getIn().setBody(q);
>                         }
>                 })
>                 .to("hibernate:com.poc.camel.interesting.Queue");
>
> from("direct:services")
>
>
> .errorHandler(deadLetterChannel("direct:foo").useOriginalMessage()).end().to("
> http://somewebserver")
>
> This is my configuration xml
>
> <camelContext id="customCamelContext"
> xmlns="http://camel.apache.org/schema/spring"
>                 trace="true" streamCache="true">
>                 <propertyPlaceholder id="camelProperties"
>                         location="classpath:camel.properties" />
>                 <camel:routeBuilder ref="customRouteBuilder" />
>         </camelContext>
>
>
>
>         <camel:proxy id="appService"
> serviceInterface="com.poc.camel.interesting.ApiServices"
>                 serviceUrl="direct:services"
> camelContextId="tmeCamelContext" />
>
> <bean id="hibernate"
> class="org.apacheextras.camel.component.hibernate.HibernateComponent">
>   <property name="sessionFactory" ref="sessionFactory"/>
>   <property name="transactionStrategy" ref="springTransactionStrategy"/>
> </bean>
>
>
> <bean id="springTransactionStrategy"
>
> class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
>   <constructor-arg ref="sessionFactory"/>
>   <constructor-arg ref="transactionTemplate"/>
> </bean>
>
> <bean id="transactionManager"
> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>   <property name="sessionFactory" ref="sessionFactory"/>
> </bean>
>
> <bean id="transactionTemplate"
> class="org.springframework.transaction.support.TransactionTemplate">
>   <property name="transactionManager" ref="transactionManager"/>
> </bean>
>
> Now the flow is : I make a HTTP request to some webservice and when it
> fails
> it goes to deadletter error handler which is pointed to direct:foo
> endpoint.
> This then persists a Queue object in DB using camel-hibernate component.
> Now i get following exception by doing all of this:
>
> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpMethodDirector
> INFO - Retrying request
> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpConnection
> DEBUG
> - Open connection to 10.152.160.18:8065
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
> DEBUG - Closing the connection.
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
> DEBUG - Method retry handler returned false. Automatic recovery will not be
> attempted
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpConnection
> DEBUG
> - Releasing connection back to connection manager.
> [2013-08-16 14:55:11,994]
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
> Freeing connection,
> hostConfig=HostConfiguration[host=http://10.152.160.18:8065]
> [2013-08-16 14:55:11,994]
> org.apache.commons.httpclient.util.IdleConnectionHandler DEBUG - Adding
> connection at: 1376645111994
> [2013-08-16 14:55:11,995]
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
> Notifying no-one, there are no waiting threads
> [2013-08-16 14:55:11,996] org.apache.camel.processor.DeadLetterChannel
> DEBUG
> - Failed delivery for exchangeId: ID-CHDSEZ102214D-61690-1376645101689-0-1.
> On delivery attempt: 0 caught: java.net.ConnectException: Connection
> refused: connect
> [2013-08-16 14:55:12,007] org.apache.camel.processor.SendProcessor DEBUG -
> >>>> Endpoint[direct://foo] Exchange[Message: BeanInvocation public
> abstract
> com.poc.camel.interesting.ServiceProviderPayload
>
> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]]
> [2013-08-16 14:55:12,007] org.apache.camel.processor.interceptor.Tracer
> INFO
> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)
> http://ThirdPartyServers?throwExceptionOnFailure=false -->  <<<
> Pattern:InOnly, BodyType:org.apache.camel.component.bean.BeanInvocation,
> Body:BeanInvocation public abstract
> com.poc.camel.interesting.ServiceProviderPayload
>
> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]
> [2013-08-16 14:55:12,009] org.apache.camel.processor.interceptor.Tracer
> INFO
> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)  -->
> hibernate://com.poc.camel.interesting.Queue <<< Pattern:InOnly,
> BodyType:com.poc.camel.interesting.Queue,
> Body:com.poc.camel.interesting.Queue@a4be02
> [2013-08-16 14:55:12,010] org.apache.camel.processor.SendProcessor DEBUG -
> >>>> Endpoint[hibernate://com.poc.camel.interesting.Queue]
> Exchange[Message:
> com.poc.camel.interesting.Queue@a4be02]
> [2013-08-16 14:55:12,039]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Creating new transaction with name [null]:
> PROPAGATION_REQUIRED,ISOLATION_DEFAULT
> [2013-08-16 14:55:12,286] org.hibernate.impl.SessionImpl DEBUG - opened
> session at timestamp: 13766451120
> [2013-08-16 14:55:12,286]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Opened new Session [org.hibernate.impl.SessionImpl@1f53293] for Hibernate
> transaction
> [2013-08-16 14:55:12,291]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Preparing JDBC Connection of Hibernate Session
> [org.hibernate.impl.SessionImpl@1f53293]
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> begin
> [2013-08-16 14:55:12,329] org.hibernate.jdbc.ConnectionManager DEBUG -
> opening JDBC connection
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> current autocommit status: true
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> disabling autocommit
> [2013-08-16 14:55:12,330] org.hibernate.impl.SessionImpl DEBUG - opened
> session at timestamp: 13766451123
> [2013-08-16 14:55:12,412]
> org.springframework.transaction.support.TransactionTemplate DEBUG -
> Initiating transaction rollback on application exception
> org.hibernate.HibernateException: persist is not valid without active
> transaction
>         at
>
> org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:341)
>         at $Proxy42.persist(Unknown Source)
>         at
>
> org.apacheextras.camel.component.hibernate.HibernateProducer$1.doInTransaction(HibernateProducer.java:54)
>         at
>
> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy$1.doInTransaction(SpringTransactionStrategy.java:43)
>         at
>
> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
>         at
>
> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy.execute(SpringTransactionStrategy.java:40)
>         at
>
> org.apacheextras.camel.component.hibernate.HibernateProducer.process(HibernateProducer.java:49)
>         at
>
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>         at
>
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>         at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
>
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>         at
>
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>         at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:741)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:265)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
>
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:85)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
>
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
>
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
>         at
>
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
>
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
>
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
>         at
>
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:48)
>         at
>
> org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:83)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
>
> org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithbody(AbstractCamelInvocationHandler.java:101)
>         at
>
> org.apache.camel.component.bean.CamelInvocationHandler.invoke(CamelInvocationHandler.java:44)
>         at $Proxy34.performOperation(Unknown Source)
>         at
>
> com.poc.camel.interesting.CamelDeadLetterTester.test(CamelDeadLetterTester.java:17)
>         at
>
> com.poc.camel.interesting.CamelDeadLetterTester.main(CamelDeadLetterTester.java:25)
> [2013-08-16 14:55:12,415]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Initiating transaction rollback
> [2013-08-16 14:55:12,416]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Rolling back Hibernate transaction on Session
> [org.hibernate.impl.SessionImpl@1f53293]
> [2013-08-16 14:55:12,416] org.hibernate.transaction.JDBCTransaction DEBUG -
> rollback
> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
> re-enabling autocommit
> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
> rolled back JDBC Connection
> [2013-08-16 14:55:12,417] org.hibernate.jdbc.ConnectionManager DEBUG -
> transaction completed on session with on_close connection release mode; be
> sure to close the session to release JDBC resources!
> [2013-08-16 14:55:12,417]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Closing Hibernate Session [org.hibernate.impl.SessionImpl@1f53293] after
> transaction
> [2013-08-16 14:55:12,417]
> org.springframework.orm.hibernate3.SessionFactoryUtils DEBUG - Closing
> Hibernate Session
> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
> releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open
> ResultSets: 0, globally: 0)]
> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
> transaction completed on session with on_close connection release mode; be
> sure to close the session to release JDBC resources!
> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
> DEBUG - Failed delivery for exchangeId:
> ID-CHDSEZ102214D-61690-1376645101689-0-1. On delivery attempt: 0 caught:
> org.hibernate.HibernateException: persist is not valid without active
> transaction
> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
> ERROR - Failed delivery for exchangeId:
> ID-CHDSEZ102214D-61690-1376645101689-0-1. Exhausted after delivery attempt:
> 1 caught: org.hibernate.HibernateException: persist is not valid without
> active transaction
>
> So is it because of my outdated versions of hibernate and spring. Or am I
> missing something in my transaction/spring/hibernate configuration.
>
> I went through CAMEL-5849 ticket at JIRA, but if we dont have an option of
> changing version, what's the alternative ? I referred to camel-hibernate
> example given at Camel website for whole poc.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Hibernate-org-hibernate-HibernateException-persist-is-not-valid-without-active-transaction-tp5737387.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel Hibernate : org.hibernate.HibernateException: persist is not valid without active transaction

Posted by Claus Ibsen <cl...@gmail.com>.
You can try camel-jpa instead and use JPA which Hibernate also support.

On Fri, Aug 16, 2013 at 11:56 AM, anand_tech <an...@gmail.com> wrote:
> Hi,
>
> I am trying to do a small poc with camel-hibernate component. First my
> versions are :
> Camel-core 2.9.0
> Camel-hibernate 2.10.0
> Spring - 3.0.6
> Hibernate - 3.6.0
>
> Below is my route :
>
> from("direct:foo")
>                 .process(new Processor() {
>
>                         @Override
>                         public void process(Exchange arg0) throws Exception {
>                                 Queue q = new Queue();
>                                 q.setName("hi");
>                                 arg0.getIn().setBody(q);
>                         }
>                 })
>                 .to("hibernate:com.poc.camel.interesting.Queue");
>
> from("direct:services")
>
> .errorHandler(deadLetterChannel("direct:foo").useOriginalMessage()).end().to("http://somewebserver")
>
> This is my configuration xml
>
> <camelContext id="customCamelContext"
> xmlns="http://camel.apache.org/schema/spring"
>                 trace="true" streamCache="true">
>                 <propertyPlaceholder id="camelProperties"
>                         location="classpath:camel.properties" />
>                 <camel:routeBuilder ref="customRouteBuilder" />
>         </camelContext>
>
>
>
>         <camel:proxy id="appService"
> serviceInterface="com.poc.camel.interesting.ApiServices"
>                 serviceUrl="direct:services" camelContextId="tmeCamelContext" />
>
> <bean id="hibernate"
> class="org.apacheextras.camel.component.hibernate.HibernateComponent">
>   <property name="sessionFactory" ref="sessionFactory"/>
>   <property name="transactionStrategy" ref="springTransactionStrategy"/>
> </bean>
>
>
> <bean id="springTransactionStrategy"
> class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
>   <constructor-arg ref="sessionFactory"/>
>   <constructor-arg ref="transactionTemplate"/>
> </bean>
>
> <bean id="transactionManager"
> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>   <property name="sessionFactory" ref="sessionFactory"/>
> </bean>
>
> <bean id="transactionTemplate"
> class="org.springframework.transaction.support.TransactionTemplate">
>   <property name="transactionManager" ref="transactionManager"/>
> </bean>
>
> Now the flow is : I make a HTTP request to some webservice and when it fails
> it goes to deadletter error handler which is pointed to direct:foo endpoint.
> This then persists a Queue object in DB using camel-hibernate component.
> Now i get following exception by doing all of this:
>
> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpMethodDirector
> INFO - Retrying request
> [2013-08-16 14:55:10,993] org.apache.commons.httpclient.HttpConnection DEBUG
> - Open connection to 10.152.160.18:8065
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
> DEBUG - Closing the connection.
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpMethodDirector
> DEBUG - Method retry handler returned false. Automatic recovery will not be
> attempted
> [2013-08-16 14:55:11,994] org.apache.commons.httpclient.HttpConnection DEBUG
> - Releasing connection back to connection manager.
> [2013-08-16 14:55:11,994]
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
> Freeing connection,
> hostConfig=HostConfiguration[host=http://10.152.160.18:8065]
> [2013-08-16 14:55:11,994]
> org.apache.commons.httpclient.util.IdleConnectionHandler DEBUG - Adding
> connection at: 1376645111994
> [2013-08-16 14:55:11,995]
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager DEBUG -
> Notifying no-one, there are no waiting threads
> [2013-08-16 14:55:11,996] org.apache.camel.processor.DeadLetterChannel DEBUG
> - Failed delivery for exchangeId: ID-CHDSEZ102214D-61690-1376645101689-0-1.
> On delivery attempt: 0 caught: java.net.ConnectException: Connection
> refused: connect
> [2013-08-16 14:55:12,007] org.apache.camel.processor.SendProcessor DEBUG -
>>>>> Endpoint[direct://foo] Exchange[Message: BeanInvocation public abstract
> com.poc.camel.interesting.ServiceProviderPayload
> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]]
> [2013-08-16 14:55:12,007] org.apache.camel.processor.interceptor.Tracer INFO
> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)
> http://ThirdPartyServers?throwExceptionOnFailure=false -->  <<<
> Pattern:InOnly, BodyType:org.apache.camel.component.bean.BeanInvocation,
> Body:BeanInvocation public abstract
> com.poc.camel.interesting.ServiceProviderPayload
> com.poc.camel.interesting.ApiServices.performOperation(com.poc.camel.interesting.ServiceProviderPayload)
> with [com.poc.camel.interesting.ServiceProviderPayload@8cd4db]]
> [2013-08-16 14:55:12,009] org.apache.camel.processor.interceptor.Tracer INFO
> - ID-CHDSEZ102214D-61690-1376645101689-0-1 >>> (route4)  -->
> hibernate://com.poc.camel.interesting.Queue <<< Pattern:InOnly,
> BodyType:com.poc.camel.interesting.Queue,
> Body:com.poc.camel.interesting.Queue@a4be02
> [2013-08-16 14:55:12,010] org.apache.camel.processor.SendProcessor DEBUG -
>>>>> Endpoint[hibernate://com.poc.camel.interesting.Queue] Exchange[Message:
> com.poc.camel.interesting.Queue@a4be02]
> [2013-08-16 14:55:12,039]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Creating new transaction with name [null]:
> PROPAGATION_REQUIRED,ISOLATION_DEFAULT
> [2013-08-16 14:55:12,286] org.hibernate.impl.SessionImpl DEBUG - opened
> session at timestamp: 13766451120
> [2013-08-16 14:55:12,286]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Opened new Session [org.hibernate.impl.SessionImpl@1f53293] for Hibernate
> transaction
> [2013-08-16 14:55:12,291]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Preparing JDBC Connection of Hibernate Session
> [org.hibernate.impl.SessionImpl@1f53293]
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> begin
> [2013-08-16 14:55:12,329] org.hibernate.jdbc.ConnectionManager DEBUG -
> opening JDBC connection
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> current autocommit status: true
> [2013-08-16 14:55:12,329] org.hibernate.transaction.JDBCTransaction DEBUG -
> disabling autocommit
> [2013-08-16 14:55:12,330] org.hibernate.impl.SessionImpl DEBUG - opened
> session at timestamp: 13766451123
> [2013-08-16 14:55:12,412]
> org.springframework.transaction.support.TransactionTemplate DEBUG -
> Initiating transaction rollback on application exception
> org.hibernate.HibernateException: persist is not valid without active
> transaction
>         at
> org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:341)
>         at $Proxy42.persist(Unknown Source)
>         at
> org.apacheextras.camel.component.hibernate.HibernateProducer$1.doInTransaction(HibernateProducer.java:54)
>         at
> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy$1.doInTransaction(SpringTransactionStrategy.java:43)
>         at
> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
>         at
> org.apacheextras.camel.component.hibernate.SpringTransactionStrategy.execute(SpringTransactionStrategy.java:40)
>         at
> org.apacheextras.camel.component.hibernate.HibernateProducer.process(HibernateProducer.java:49)
>         at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>         at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
>         at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:741)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:265)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:85)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)
>         at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:53)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
>         at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
>         at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:48)
>         at
> org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:83)
>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
> org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithbody(AbstractCamelInvocationHandler.java:101)
>         at
> org.apache.camel.component.bean.CamelInvocationHandler.invoke(CamelInvocationHandler.java:44)
>         at $Proxy34.performOperation(Unknown Source)
>         at
> com.poc.camel.interesting.CamelDeadLetterTester.test(CamelDeadLetterTester.java:17)
>         at
> com.poc.camel.interesting.CamelDeadLetterTester.main(CamelDeadLetterTester.java:25)
> [2013-08-16 14:55:12,415]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Initiating transaction rollback
> [2013-08-16 14:55:12,416]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Rolling back Hibernate transaction on Session
> [org.hibernate.impl.SessionImpl@1f53293]
> [2013-08-16 14:55:12,416] org.hibernate.transaction.JDBCTransaction DEBUG -
> rollback
> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
> re-enabling autocommit
> [2013-08-16 14:55:12,417] org.hibernate.transaction.JDBCTransaction DEBUG -
> rolled back JDBC Connection
> [2013-08-16 14:55:12,417] org.hibernate.jdbc.ConnectionManager DEBUG -
> transaction completed on session with on_close connection release mode; be
> sure to close the session to release JDBC resources!
> [2013-08-16 14:55:12,417]
> org.springframework.orm.hibernate3.HibernateTransactionManager DEBUG -
> Closing Hibernate Session [org.hibernate.impl.SessionImpl@1f53293] after
> transaction
> [2013-08-16 14:55:12,417]
> org.springframework.orm.hibernate3.SessionFactoryUtils DEBUG - Closing
> Hibernate Session
> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
> releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open
> ResultSets: 0, globally: 0)]
> [2013-08-16 14:55:12,418] org.hibernate.jdbc.ConnectionManager DEBUG -
> transaction completed on session with on_close connection release mode; be
> sure to close the session to release JDBC resources!
> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
> DEBUG - Failed delivery for exchangeId:
> ID-CHDSEZ102214D-61690-1376645101689-0-1. On delivery attempt: 0 caught:
> org.hibernate.HibernateException: persist is not valid without active
> transaction
> [2013-08-16 14:55:12,422] org.apache.camel.processor.DefaultErrorHandler
> ERROR - Failed delivery for exchangeId:
> ID-CHDSEZ102214D-61690-1376645101689-0-1. Exhausted after delivery attempt:
> 1 caught: org.hibernate.HibernateException: persist is not valid without
> active transaction
>
> So is it because of my outdated versions of hibernate and spring. Or am I
> missing something in my transaction/spring/hibernate configuration.
>
> I went through CAMEL-5849 ticket at JIRA, but if we dont have an option of
> changing version, what's the alternative ? I referred to camel-hibernate
> example given at Camel website for whole poc.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Hibernate-org-hibernate-HibernateException-persist-is-not-valid-without-active-transaction-tp5737387.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen