tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Gumbrecht <agumbre...@tomitribe.com>
Subject Re: Transaction issues using TomEE, JPA, and Spring
Date Fri, 24 Jul 2015 13:46:12 GMT
Hi Mike,

Either add @Stateless to your bean that accesses the db and let TomEE
manage the transaction, or @Inject UserTransaction trans into your bean and
call trans.begin() and trans.commit()

Andy.

On 24 July 2015 at 15:05, Mike Spencer <mspencer@denniskirk.com> wrote:

> Hi Romain,
>
> I am using Spring's JtaTransactionManager and it is finding a
> org.apache.geronimo.transaction.manager.GeronimoTransactionManager at the
> JNDI location java:comp/UserTransaction. Is this the correct transaction
> manager to be using?
>
> Thanks,
> Mike Spencer
>
> On 07/23/2015 04:11 PM, Romain Manni-Bucau wrote:
>
>> Hi
>>
>> isnt it only that spring is not able to lookup tomee tx magaer by default?
>> try to wire it in your app ctx.
>>
>>
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.openejb/openejb-core/4.7.1/org/apache/openejb/OpenEJB.java#OpenEJB.getTransactionManager%28%29
>> is the one (doable using methid invoker of spring IIRC)
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <http://rmannibucau.wordpress.com> | Github <
>> https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> <http://www.tomitribe.com>
>>
>>
>> 2015-07-23 14:04 GMT-07:00 Mike Spencer <mspencer@denniskirk.com>:
>>
>>  Hi all,
>>>
>>> I am having issues with using database transactions in a Spring based
>>> application. I have my data sources configured on TomEE and they work
>>> fine
>>> for non-transactional database calls, but whenever I try to call a method
>>> using Spring's @Transactional annotation a TransactionRequiredException
>>> is
>>> thrown due to no active transactions. I have this application working on
>>> Glassfish currently and am trying to port it to TomEE.
>>>
>>> The application is using JPA (through EclipseLink), Spring, and Spring
>>> Data JPA to handle the database calls. I have a
>>> org.springframework.transaction.jta.JtaTransactionManager configured and
>>> it
>>> appears to be grabbing a
>>> org.apache.geronimo.transaction.manager.GeronimoTransactionManager from
>>> TomEE under a default JNDI name. I am not explicitly creating or
>>> configuring a TransactionManager in TomEE.
>>>
>>> As far as I can tell, everything is working up to a point of trying to
>>> the
>>> point of committing a transaction. I enabled debug logging and I get this
>>> in my logs:
>>>
>>> 2015-07-23 14:50:07,510 DEBUG
>>> [AbstractPlatformTransactionManager.java:367] - Creating new transaction
>>> with name
>>>
>>> [org.springframework.data.jpa.repository.support.SimpleJpaRepository.saveAndFlush]:
>>> PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
>>> 2015-07-23 14:50:07,511 DEBUG
>>> [AbstractPlatformTransactionManager.java:847] - Initiating transaction
>>> rollback
>>> Jul 23, 2015 2:50:07 PM org.apache.catalina.core.ApplicationDispatcher
>>> invoke
>>> SEVERE: Servlet.service() for servlet dispatcher threw exception
>>> org.springframework.dao.InvalidDataAccessApiUsageException:
>>> Exception Description: No transaction is currently active; nested
>>> exception is javax.persistence.TransactionRequiredException:
>>> Exception Description: No transaction is currently active
>>>
>>>
>>> I do not know if I missed a configuration option in TomEE or not, but I
>>> could use some help trying to find what I am missing.
>>>
>>> Thanks,
>>> Mike Spencer
>>>
>>>
>


-- 
  Andy Gumbrecht
  https://twitter.com/AndyGeeDe
  http://www.tomitribe.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message