Issue Details (XML | Word | Printable)

Key: CORE-2607
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Joerg von Frantzius
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JPOX Core (ARCHIVED)

Support JBoss 4.0.3 SP1

Created: 14/Dec/05 03:50 PM   Updated: 25/Apr/07 08:47 AM   Resolved: 05/Feb/07 11:58 AM
Component/s: JCA Adapter
Affects Version/s: 1.1.0-beta-5
Fix Version/s: 1.1.6, 1.2.0-beta-1

File Attachments: 1. Text File patch_DatabaseAdapter.txt (0.7 kB)
2. Text File patch_ManagedConnectionImpl.txt (0.6 kB)
3. Text File patch_ManagedTransaction.txt (0.8 kB)
4. Text File patch_PersistenceManagerImpl.txt (0.7 kB)
5. Text File patch_RDBMSManager.txt (2 kB)
6. Text File patch_SequenceImpl.txt (1 kB)


Datastore: Oracle


 Description  « Hide
[please see my email of today for a nicer HTML view of the different issues and patches]

in order to use JPOX via JCA in JBoss 4.0.3 SP1 I had to create some patches due to JBoss being very picky.

In the jpox-ds.xml I configured both ConnectionFactoryName and ConnectionFactory2Name for lookup of Oracle datasources, with ConnectionFactoryName being a local-tx-datasource and ConnectionFactory2Name being a no-tx-datasource (with the latter seeming to result in a autoCommit==true connection). I *didn't* configure Connection(DriverName|URL) etc.

Here's a list of the problems encountered and their fixes:
Must not begin(), commit() or rollback() on Connection that has autoCommit==true

    Index: RDBMSManager.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/store/rdbms/RDBMSManager.java,v
    retrieving revision 1.129
    diff -u -r1.129 RDBMSManager.java
    --- RDBMSManager.java 5 Dec 2005 08:51:34 -0000 1.129
    +++ RDBMSManager.java 14 Dec 2005 11:18:46 -0000
    @@ -1274,14 +1274,29 @@
                             boolean success = false;
                             try
                             {
    - con.commit();
    + if (!con.getAutoCommit()) {
    + con.commit();
    + }
                                 success = true;
                             }
                             finally
                             {
                                 if (!success)
                                 {
    - con.rollback();
    + try
    + {
    + if (!con.getAutoCommit()) {
    + con.rollback();
    + }
    + }
    + catch (SQLException e)
    + {
    + String msg=LOCALISER_RDBMS.msg("RDBMS.Manager.POIDConnectionCloseError", e);
    + JPOXLogger.RDBMS_SCHEMA.error(msg);
    + throw new JDODataStoreException(msg);
    + } finally {
    + closeConnection(con);
    + }
                                 }
                             }
                             closeConnection(con);
    @@ -1893,11 +1908,11 @@
                                 {
                                     if (isolationLevel != Connection.TRANSACTION_NONE)
                                     {
    - if (succeeded)
    + if (succeeded && !conn.getAutoCommit())
                                         {
                                             conn.commit();
                                         }
    - else
    + else if (!conn.getAutoCommit())
                                         {
                                             conn.rollback();
                                         }
    Index: SequenceImpl.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/SequenceImpl.java,v
    retrieving revision 1.12
    diff -u -r1.12 SequenceImpl.java
    --- SequenceImpl.java 12 Jul 2005 21:51:57 -0000 1.12
    +++ SequenceImpl.java 14 Dec 2005 11:20:49 -0000
    @@ -106,14 +106,18 @@
                             boolean success = false;
                             try
                             {
    - conn.commit();
    + if (!conn.getAutoCommit()) {
    + conn.commit();
    + }
                                 success = true;
                             }
                             finally
                             {
                                 if (!success)
                                 {
    - conn.rollback();
    + if (!conn.getAutoCommit()) {
    + conn.rollback();
    + }
                                 }
                             }
                             ((RDBMSManager)storeManager).closeConnection(conn);

Must not setAutoCommit() within running UserTransaction

    Index: DatabaseAdapter.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/store/rdbms/adapter/DatabaseAdapter.java,v
    retrieving revision 1.64
    diff -u -r1.64 DatabaseAdapter.java
    --- DatabaseAdapter.java 7 Nov 2005 18:28:17 -0000 1.64
    +++ DatabaseAdapter.java 14 Dec 2005 11:35:12 -0000
    @@ -859,7 +859,9 @@
                 }
                 else
                 {
    - conn.setAutoCommit(false);
    + if (conn.getAutoCommit()) {
    + conn.setAutoCommit(false);
    + }
                     if (supportsTransactionIsolationLevel(isolationLevel))
                     {
                         conn.setTransactionIsolation(isolationLevel);

NPE (Core-2604)

    Index: PersistenceManagerImpl.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/resource/PersistenceManagerImpl.java,v
    retrieving revision 1.37
    diff -u -r1.37 PersistenceManagerImpl.java
    --- PersistenceManagerImpl.java 2 Nov 2005 19:15:15 -0000 1.37
    +++ PersistenceManagerImpl.java 14 Dec 2005 11:41:25 -0000
    @@ -1428,7 +1428,9 @@
          */
         public void removeQueryResult(QueryResult queryResult)
         {
    - mc.removeQueryResult(queryResult);
    + if (mc!=null) {
    + mc.removeQueryResult(queryResult);
    + }
         }
     
         /* (non-Javadoc)

    Index: ManagedConnectionImpl.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/resource/ManagedConnectionImpl.java,v
    retrieving revision 1.11
    diff -u -r1.11 ManagedConnectionImpl.java
    --- ManagedConnectionImpl.java 2 Nov 2005 19:15:15 -0000 1.11
    +++ ManagedConnectionImpl.java 14 Dec 2005 11:43:27 -0000
    @@ -134,6 +134,7 @@
                 ((PersistenceManagerImpl)i.next()).setManagedConnection(null);
             }
             handles.clear();
    + disconnectQueryCache();
         }
     
         /**

Must not commit SQL Connection within running UserTransaction
I imagine this fix could be a problem if ConnectionURL etc. is configured instead of ConnectionFactoryName, as I don't know whether UserTransaction.commit() will commit the SQL Connection when it wasn't obtained via a JCA datasource (which I'd think is the case when using ConnectionURL etc. instead of ConnectionFactory).

However, if the connection was obtained via a JCA datasource, it seems to be the appserver's responsibility to commit it when the UserTransaction is committed.

    Index: ManagedTransaction.java
    ===================================================================
    RCS file: /cvsroot/jpox/JPOX/Core/src/java/org/jpox/resource/ManagedTransaction.java,v
    retrieving revision 1.17
    diff -u -r1.17 ManagedTransaction.java
    --- ManagedTransaction.java 13 Dec 2005 11:27:14 -0000 1.17
    +++ ManagedTransaction.java 14 Dec 2005 11:56:03 -0000
    @@ -341,7 +341,9 @@
                             sync.beforeCompletion();
                         }
     
    - conn.commit();
    + // JBoss 4.0.3 SP1 doesn't want us to commit the connection during a managed transaction here.
    + // should it really be our responsibility to commit the SQL connection anyway?!
    + //conn.commit();
     
                         success = true;
                     }


Please tell me what your objections to these patches are, if any. I think it would be great if JPOX would run fine in JBoss 4.0.3 SP1 for everyone.

Regards,
Jörg

--
__________________________________________________________
Dipl.-Inf. Jörg von Frantzius | artnology GmbH
                               | Milastr. 4
Tel +49 (0)30 4435 099 26 | 10437 Berlin
Fax +49 (0)30 4435 099 99 | http://www.artnology.com
_______________________________|__________________________



Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 15/Dec/05 06:33 AM
Patches for use of commit/rollback only when not using autoCommit are now applied to CVS.

Andy Jefferson added a comment - 15/Dec/05 07:12 AM
With respect to the removeQueryResult patch I want to know why only apply a check like that to that method. Sounds like papering over some crack that will only show elsewhere later. Please address the real issue of why that is being hit. Why is "mc" null at that point ? What is a better way of adding/removing query results that fits in with how JCA is used ?

With respect to the patch that removes the commit of the txn, I can't apply that since have no way of knowing its correctness. Erik will have to assess that one

Joerg von Frantzius added a comment - 15/Dec/05 12:10 PM
This is all happending during UserTransaction.commit().

The mc is null at that point because ManagedConnection.cleanup() is called by JBoss before it calls ManagedConnection.destroy() (see stacktrace in second comment of http://www.jpox.org/servlet/jira/browse/CORE-2604). The cleanup() disconnects the ManagedConnectionImpl from the PersistenceManagers it was associated with. I have no idea why that is done.

ManagedConnectionImpl.destroy() would even close all its PMs if cleanup() wasn't called previously, and I wonder what sense *that* makes. JBoss always seems to call cleanup() before destroy(). So either the PMs should not be closed on ManagedConnection.close(), or ManagedConnection.cleanup() shouldn't clear their list. Closing any PMs on UserTransaction.commit() seems pretty bad to me anyway!

Probably the disconnecting of the ManagedConnection from its PMs should happen in ManagedConnection.destroy(), without closing the PMs.

I'll try it that way and post my results here, as you can't test it anyway?

Erik Bengtson added a comment - 27/May/06 11:12 AM
any progress on this?

Andy Jefferson added a comment - 05/Feb/07 11:58 AM
I'm assuming this is fixed (9 months and no comment means that it is either fixed or not important). If it isnt fixed then speak up