Hello everybody.
I'm trying to persist entities in a native hibernate environment depolyed on karaf 2.3.4 with hibernate 4.3.4.Final. However, I'm making use of JtaTransactions by using
Code:
<tx:transaction method="*" value="Required" />
in the blueprint file.
The SessionFactory is obtained using SCR/DS by means of
Code:
@Reference
SessionFactory sessionFactory;
which works as desired.
After creating an entity and persisting it with
Code:
currentSession.save(storedEvent);
the logfile shows:
Quote:
stingDomainEventPublisherService | 247 - brodos-eventing - 2.0.1.SNAPSHOT | Store of event object requested for: com.brodos.eventing.event.TestEvent@c9ccadb
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Connection provider reports to not support aggressive release; overriding
TransactionCoordinatorImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | successfully registered Synchronization
ActionQueue | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Executing identity-insert immediately
SQL | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | insert into t_stored_event (event_body, occurred_on, type_name) values (?, ?, ?)
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Obtaining JDBC connection
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Obtained JDBC connection
IdentifierGeneratorHelper | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Natively generated identity: 170
which so far is as expected.
However, when leaving the method intercepted by the blueprint transaction interceptor, the log shows:
Quote:
AbstractFlushingEventListener | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Processing flush-time cascades
AbstractFlushingEventListener | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Dirty checking collections
AbstractFlushingEventListener | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
AbstractFlushingEventListener | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
EntityPrinter | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Listing entities:
EntityPrinter | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | com.brodos.common.event.StoredEvent{typeName=com.brodos.eventing.event.TestEvent, eventId=170, eventBody={"id":"12","dateTime":"1396016086039"}, occurredOn=Fri Mar 28 15:14:46 CET 2014}
EntityPrinter | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | com.brodos.common.event.StoredEvent{typeName=com.brodos.eventing.event.TestEvent, eventId=171, eventBody={"id":"12","dateTime":"1396016091933"}, occurredOn=Fri Mar 28 15:14:51 CET 2014}
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Aggressively releasing JDBC connection
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Releasing JDBC connection
LogicalConnectionImpl | 238 - org.jboss.logging.jboss-logging - 3.1.3.GA | Released JDBC connection
LoggingOutInterceptor | 130 - org.apache.cxf.cxf-api - 2.7.10 | Outbound Message
The persisted entities never show up in the database.
My hibernate configuration is like:
Code:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">eventdb</property>
<property name="hibernate.connection.url">jdbc:mysql://192.168.56.101:3306/eventstore</property>
<property name="hibernate.connection.username">eventdb</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</property>
<mapping resource="StoredEvent.hbm.xml"/>
</session-factory>
</hibernate-configuration>
When I try to force session commit by calling
Code:
sessionFactory.currentSession().getTransaction().commit();
I get a
Quote:
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Transaction not successfully started
EDIT:
In a debugger session I found that the JtaTransaction is existing and logs show successful session synchronization.
Moreover, debugging shows, that AbstractTransactionImpl.commit() is never called. Forcing commit to be called, throws the mentioned exception because the localStatus field of AbstractTransactionImpl is never set to ACTIVE. Here, AbstractTransactionImpl should test on isActive(), because isActive() is overwritten by CMTTransaction and the implementation there delegates to JtaStatusHelper.isActive(), which
is ACTIVE.
I'm trying to get this running now for days, please help!
Best regards,
Alexander