geronimo transaction manager != geronimo connection manager, although they work well together.
I'm glad you got it working. david jencks On Feb 25, 2014, at 8:12 AM, Dutertry Nicolas <[email protected]> wrote: > Actually Geronimo transaction manager is embedded in aries transaction > manager bundle. > > I have finally managed to have a non-XA datasource properly handled by JTA. > To do so, I have used BasicManagedDataSource from commons dbcp. > The datasource can be configured like that with blueprint: > > <reference id="transactionManager" > interface="javax.transaction.TransactionManager"/> > > <bean id="dataSource" > class="org.apache.commons.dbcp.managed.BasicManagedDataSource"> > <property name="transactionManager" ref="transactionManager"/> > <property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver"/> > <property name="url" value="jdbc:hsqldb:mem:test"/> > <property name="username" value="sa"/> > <property name="password" value=""/> > </bean> > > Regards, > -- > Nicolas Dutertry > > -----Original Message----- > From: David Jencks [mailto:[email protected]] > Sent: lundi 24 février 2014 19:54 > To: [email protected] > Subject: Re: Transactions with Blueprint > > I don't know what you are using to support jta and connection management. In > order to use jta + a non-xa-datasource you need a connection manager that > knows how to do this and it needs to be configured properly. The geronimo > connection manager does this but I don't know if its installed secretly in > the aries jta support. > > If you use an xa datasource you'll still only get one phase commit since > there is only one participant, so if the driver is written reasonably it > should be as fast as a non-xa datasource. (the "start transaction" xa > message would be replaced by "auto commit off" for a non-xa datasource. Of > course this might not result in a message to the server, depending on how the > driver is written). > > david jencks > > On Feb 24, 2014, at 5:00 AM, Dutertry Nicolas <[email protected]> > wrote: > >> Hi, >> >> I am trying to use transactions (JTA) and JPA with Aries blueprint but I did >> not manage to make it work. >> >> I don't want to use XA datasource because I only access a single database. >> So In my JPA persistence.xml file I have something like : >> <persistence-unit name="test"> >> >> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service. >> name=jdbc/testdb)</jta-data-source> >> ... >> >> My blueprint.xml contains : >> <bean id="personService" >> class="test.service.impl.PersonServiceImpl"> >> <tx:transaction method="*" value="Required"/> >> <jpa:context property="entityManager" unitname="test"/> </bean> >> >> I have written a test to check transaction's rollback, using a transactional >> method like the following : >> >> public class PersonServiceImpl implements PersonService { >> ... >> public void createPerson(Person person) { >> entityManager.persist(person); >> entityManager.flush(); >> >> throw new RuntimeException("exception"); >> } >> } >> >> I was expecting that the created person would not be written to the database >> after calling "createPerson" because of the Exception, but it is not the >> case ! The person object is persisted in the database. >> It appears that the underlying JDBC Connection has an autocommit property >> set to "true", so rollback is impossible. I thought transaction manager >> would take care of JDBC connection autocommit, but it is not the case. >> >> The result is the same with OpenJPA and Hibernate. >> >> Am I missing something related to JTA ? >> >> Thanks for your help. >> >> -- >> Nicolas Dutertry >> HR Access - http://www.hraccess.com >> >> >
