Exception : org.adempiere.exceptions.DBException: java.sql.SQLException: You can't operate on a closed Statement!!!

565 views
Skip to first unread message

Ru...@amxware.com

unread,
Jan 4, 2019, 1:14:47 AM1/4/19
to iDempiere
Hi, all

I have an error in idempiere when using Query class in custom model. The complete error is

Exception : org.adempiere.exceptions.DBException: java.sql.SQLException: You can't operate on a closed Statement!!! at org.compiere.model.Query.first(Query.java:316)


since this error in idempiere class. is there any hint or cause that can make this happen? it's not always happen but frequent. i'm using postgresql for database.




Regards,
Rudy

Ru...@amxware.com

unread,
Jan 21, 2019, 4:23:45 AM1/21/19
to iDempiere
anybody able to help or experiencing this same problem? I'm not able to reproduce this in local when tested with jmeter for threading.

Carlos Antonio Ruiz Gómez

unread,
Jan 21, 2019, 6:32:25 AM1/21/19
to iDempiere
Hi, most possibly a bug in your custom code - but is really hard to try to give advice about invisible sources   ;)

Regards,

Carlos Ruiz
Message has been deleted

Ru...@amxware.com

unread,
Jan 22, 2019, 2:26:32 AM1/22/19
to iDempiere
the exception happen in various part of the source code. for example

PreparedStatement pstmt = DB.prepareStatement(GET_SPG_BY_CODE, trxName);
   
ResultSet rs = null;
   
try {
        pstmt
.setString(1, spgcode);
        rs
= pstmt.executeQuery();
       
if (rs.next()){
            retValue
= new MSPG(ctx, rs, trxName);
       
}                                
   
} catch (Exception e) {
       
StringWriter errors = new StringWriter();
        e
.printStackTrace(new PrintWriter(errors));                        
        sLog
.severe("MSMISGMSPG : "+errors.toString());
   
} finally {
        DB
.close(rs, pstmt);
        rs
= null;
        pstmt
= null;
   
}

and
final String whereClause = "ID=? AND IsActive = 'Y'";
retValue
=new Query(ctx, Table_Name, whereClause, trxName)
   
.setParameters(ID)            
   
.first();

its all started from custom servlet that we develop as a plugin in idempiere.

any particular part of the code that you need?

Regards,

Hiep Lq

unread,
Jan 22, 2019, 2:56:35 AM1/22/19
to Mohemmed Bilal Ilyas
you can see it happen on core source, but root cause can start from somewhere.

because just you report about it so assume it start from you customize code.

i experimental that issue one time when it happen on production server of Norbert.

after one week add customize code to get more information we detect issue from a line of core. it's a leak connection.

so if your customize code make same issue, it raise same error

when i find out that issue i will post here for you reference.


--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/d20f3f11-880d-461d-abe2-13c3f7ebf6ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Lê Quý Hiệp
Email: hie...@hasuvimex.vn
Skype: admin.hasuvimex

Company: Thanh Hoa Fishery Import - Export J.s.c  (HasuvimexDL 47
Add: Lot E, Le Mon Industrial Zone, Thanh Hoa, Vietnam

Hiep Lq

unread,
Jan 22, 2019, 3:06:19 AM1/22/19
to Mohemmed Bilal Ilyas

Ru...@amxware.com

unread,
Jan 22, 2019, 3:58:17 AM1/22/19
to iDempiere
so basically somewhere in my code, i miss the "DB.close" statement that it affects other part of the code as well, right?
thanks, i'll look into it once more.

Regards,

Carlos Antonio Ruiz Gomez

unread,
Jan 22, 2019, 7:51:51 AM1/22/19
to idem...@googlegroups.com

It can be that you're missing a DB.close - or that you're closing a transaction and then trying to use it (the error message looks more like this).

What Hiep describes is kind of common with customized code, and sporadically we find these things in core - the good news is that tool has been implemented that make very fast to see where is the leak:

Regards,

Carlos Ruiz



El 22/01/19 a las 9:58, Ru...@amxware.com escribió:

Ru...@amxware.com

unread,
Jan 25, 2019, 1:10:51 AM1/25/19
to iDempiere




from that link, there is 3 active transaction while only 2 active transaction in detail. is that difference is the problem? or the fact that 1 active transaction is missing?


what if i don't specify trxname (trxname = null) is that what causing the active transaction without detail?


Regards,

Rudy

Reply all
Reply to author
Forward
0 new messages