Openbravo Issue Tracking System - Modules
View Issue Details
0028934ModulesApache External Connection Poolpublic2015-02-13 10:342015-05-07 22:17
daniOpenbravo 
inigosanchez 
normalmajoralways
closedfixed 
3014.04
 
 
umartirena
0028934: Error when launching "Create AP Expense Invoices" related to Openbravo External Connection Pools module.
If we try to launch "Create AP Expense Invoices" process while we have "Openbravo External Connection Pools" module installed and configured, we get the error shown on the attached image and Openbravo log.
- Install "Openbravo External Connection Pools" module and configure it: http://wiki.openbravo.com/wiki/Modules:Apache_JDBC_Connection_Pool. [^]
- Once this module is installed, we should add the following line to Openbravo.properties in order to Openbravo will start using JDBC Connection Pool (it is explained on the above link): db.externalPoolClassName=org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool
- Launch "Create AP Expense Invoices": Select "From Date", "To Date" and "Date Invoiced" fields and click on "Process" button.
- As we can see, the error on the attached screenshoot is raised.
While debugging the code we have taken into account that if we comment the following line of ExpenseAPInvoice.java file, we do not get the error: releaseCommitConnection(conn);
No tags attached.
related to defect 0036945 closed AtulOpenbravo Modules Cannot post a document from the Report Not Posted window if an External Connection Pool is not used 
causes defect 0030314 closed Triage Omni OMS Openbravo ERP NullPointerException when launching the Create AP Expense Invoices process 
causes defect 0030811 closed dmiguelez Openbravo ERP process: "Create expense AP Invoice" does not work 
txt bugJdbcExternalConnectionPool.txt (7,911) 2015-02-13 10:34
https://issues.openbravo.com/file_download.php?file_id=7788&type=bug
Issue History
2015-02-13 10:34daniOpenbravoNew Issue
2015-02-13 10:34daniOpenbravoAssigned To => AugustoMauch
2015-02-13 10:34daniOpenbravoFile Added: bugJdbcExternalConnectionPool.txt
2015-02-13 11:01daniOpenbravoNote Added: 0074445
2015-02-13 11:01daniOpenbravoIssue Monitored: daniOpenbravo
2015-02-13 11:11AugustoMauchNote Edited: 0074445bug_revision_view_page.php?bugnote_id=0074445#r7675
2015-02-13 11:15daniOpenbravoNote Edited: 0074445bug_revision_view_page.php?bugnote_id=0074445#r7676
2015-04-21 09:34inigosanchezAssigned ToAugustoMauch => inigosanchez
2015-04-28 12:03inigosanchezReview Assigned To => umartirena
2015-04-28 12:06hgbotCheckin
2015-04-28 12:06hgbotNote Added: 0076821
2015-04-28 12:06hgbotStatusnew => resolved
2015-04-28 12:06hgbotResolutionopen => fixed
2015-04-28 12:06hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b134bab019fe3e3a354b5b53b0b887d4d4aefb39 [^]
2015-05-04 10:57umartirenaNote Added: 0076928
2015-05-04 10:57umartirenaStatusresolved => closed
2015-05-07 22:17hudsonbotCheckin
2015-05-07 22:17hudsonbotNote Added: 0077172
2015-07-03 14:13ngarciaRelationship addedcauses 0030314
2015-09-14 15:59vmromanosRelationship addedcauses 0030811
2017-09-26 10:33aferrazRelationship addedrelated to 0036945

Notes
(0074445)
daniOpenbravo   
2015-02-13 11:01   
(edited on: 2015-02-13 11:15)
We have edited "removeAbandoned" property (setting it as removeAbandoned=false) in connectionPool.properties configuration file but in this case it does not seem to be the problem.

(0076821)
hgbot   
2015-04-28 12:06   
Repository: erp/devel/pi
Changeset: b134bab019fe3e3a354b5b53b0b887d4d4aefb39
Author: Inigo Sanchez <inigo.sanchez <at> openbravo.com>
Date: Tue Apr 28 11:49:51 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/b134bab019fe3e3a354b5b53b0b887d4d4aefb39 [^]

Fixes bug 28934:Error when launching "Create AP Expense Invoices".

The problem wasn't related with "Openbravo External Connection Pools module". This issue
has been reproduced without using "Apache JDBC Connection Pool", this is the error log:

Apr 27, 2015 12:51:47 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet P801268 threw exception
org.hibernate.TransactionException: JDBC commit failed
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:157)
    at org.openbravo.dal.core.SessionHandler.commitAndClose(SessionHandler.java:258)
.........................
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:701)
Caused by: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.commit(AbstractJdbc2Connection.java:705)
    at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:166)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:142)

In both cases (default connection pool or apache jdbc connection pool) there was an error
related with the way of manage connections in "Create AP Expense Invoices" process.

This connection is obtained with getConnection() method and finally it is closed in
realeaseCommitConnection() method. This method gets the connection from the session.
In following uses of "getConnection()" there is an error because this process closed
the connection of the session.

To fix this, using "getTransactionConnection()" instead of "getConnection()" method. This method
creates a new connection instead of using the connection of the session. For this reason, it can
be closed without any problem.

---
M src/org/openbravo/erpCommon/ad_process/ExpenseAPInvoice.java
---
(0076928)
umartirena   
2015-05-04 10:57   
Code Review + Testing OK
(0077172)
hudsonbot   
2015-05-07 22:17   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/a1817f84bd8b [^]
Maturity status: Test