Hi Ron,
If you are seeing problems with read-only transactions, we will have to
change the servlet code to not use @Transactional(readOnly=true)
anywhere. PostgreSQL doesn't support transitioning from a read/write
transaction into a read-only transaction so these annotations will
always cause problems. It would be nice if we could annotation certain
sections to enforce the fact that they are read-only but unfortunately
this doesn't seem possible with PostgreSQL.
In the master code, I am not configuring a JTA transaction manager (yet)
because I'm trying to ease the code into support for Hibernate 4+. From
what I have read, Hibernate 3 and Spring's transaction manager play
together nicely and it's not strictly necessary to use JTA. For that
reason, I'm avoiding using JTA for the time being. Here's my current
strategy for rolling Hibernate 4 support into master:
- Upgrade to an XA-capable Atomikos data source that wraps the
PostgreSQL PGXADataSource: DONE
- Eliminate usage of Spring's HibernateTemplate in favor of Hibernate's
native SessionFactory.getCurrentSession() since Spring 3.2.X does not
provide a HibernateTemplate that works with Hibernate4. This work is
currently in-progress in my soleger-master branch.
- It sounds like you are seeing that Hibernate 3 behaves better with
Atomikos with a JTA transaction manager so maybe the next step should be
adding a JTA transaction manager.
- Upgrade Hibernate to version 4.1. The API changes for this are fairly
minor once the SessionFactory.getCurrentSession() stuff is done. I have
this work in progress in my feature-hibernate4-upgrade branch and I am
slowly rolling changes (like Atomikos and now the
SessionFactory.getCurrentSession() work) into master from this branch.
I'm also trying to work carefully so that if we have to, we can switch
back to the legacy c3p0 DataSource if we need to ship a version of 1.14.
This work, even just switching to Atomikos, has been fairly error-prone
since many problems do not show up in unit tests because it is easy with
Spring to wrap unit tests in transactions. Then when the code runs
inside OpenNMS and the transaction state is different, problems occur.
:) However, I feel like moving to stricter transaction handling is good
and a lot of the problems exposed during this work were caused by sloppy
transaction management that could have led to data integrity problems.
I'm going to CC the devel list with this email since it might be useful
for other developers to understand where I'm going with the Hibernate
work. I'll let you know as I make progress on the
SessionFactory.getCurrentSession() work; hopefully I'll have that
committed to master soon.
Seth Leger
The OpenNMS Group
On 3/21/14, 12:30 AM, Ronald Roskens wrote:
> Hey Seth,
>
> I’ve been playing around trying to get 1.13.1-SNAPSHOT built and
> running under Jetty 9. One thing I ran into was I was getting errors
> on some of the JSP pages due to the readonly flag being set after a
> transaction had started so it would bail out with a nice long exception.
>
> I found this webpage
> ( http://www.atomikos.com/Documentation/HibernateIntegration ) and
> noticed a couple properties that could be set for hibernate3:
>
> diff --git
> a/opennms-dao/src/main/resources/META-INF/opennms/applicationContext-dao.xml
> b/opennms-dao/src/main/resources/META-INF/opennms/applicationContext-dao.xml
> index 7c7b215..e5e2adb 100644
> ---
> a/opennms-dao/src/main/resources/META-INF/opennms/applicationContext-dao.xml
> +++
> b/opennms-dao/src/main/resources/META-INF/opennms/applicationContext-dao.xml
> @@ -77,6 +77,8 @@
> hibernate.cache=false
> hibernate.cache.use_query_cache=false
> hibernate.jdbc.batch_size=0
> +
> hibernate.transaction.factory_class=com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
> +
> hibernate.transaction.manager_lookup_class=com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
> <!-- hibernate.format_sql=true -->
> </value>
> </property>
>
> After adding the missing transactions-hibernate3-3.9.3.jar to
> /opt/opennms/lib/, i don’t get that error any more, nor do i see
> instances of “WARNING: transaction manager not running”. This probably
> isn’t the “right” way to fix this, do you know how to set those
> properties only if the Atomikos factory is being used?
>
> Ron
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-devel mailing list
To *unsubscribe* or change your subscription options, see the bottom of this
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel