cancel
Showing results for 
Search instead for 
Did you mean: 

A jdbc transaction error occur

Former Member
0 Kudos

Hi Everybody

A jdbc transaction error occur when I deploy the application on the server .

Below is the stack trace

#SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot commit transaction from this connection of "YTSQLS2K" DataSource. This resource participates in a local or distributed transaction. #SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot initiate transaction from a connection of "YTSQLS2K" DataSource. Local or distributed transaction has already started.

#SAP J2EE Engine JTA Transaction : [03bfffffffd3a000ffffffc0]####Application [13]##0#0#Error#1#/System/Audit#Java###Exception #1#com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot commit transaction from this connection of "YTSQLS2K" DataSource. This resource participates in a local or distributed transaction.

Any idea about it

I use the jdbc version in datasource <jdbc-1.x>

is there a need to replace it with <jdbc-2.0>

Thank You

Syed Saifuddin

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Check this article:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bf0d57db-0c01-0010-6fa3-835...

The article explains how to integrate Hibernate 3.x, how to use SAP transaction manager and hibernate cache.

It is created for Web AS 6.40but I checked it on the JEE5 server and it works just fine there too.

0 Kudos

Hibernate allows you to choose transaction manager. As Nikolay pointed out, in a JEE envirnment it's prefferable to use JTA transactions. All you need to do is to configure hibernate to use a JTA transaction manager. It is all written in the Hibernate documentations. See

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-j2ee

and

http://www.hibernate.org/42.html#A5 .

The relevant properties that need to be set in the configuration are:

hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory

and

hibernate.transaction.manager_lookup_class=<Class that knows how to lookup>

You need to implement a class that knows how to lookup user transaction in SAP J2EE Egnine.

The class must extend org.hibernate.transaction.JNDITransactionManagerLookup and only override its abstract method getName (simply returning the lookup string). Then provide the fully qualified name as value of the property and make sure that Hibernate can load the class.

That should work.

HTH

-Georgi

Message was edited by:

Georgi Pavlov

nikolai_tankov
Explorer
0 Kudos

Hi Syed,

It is not possible to use jdbc transactions when JTA transaction is running. This means that application is not allowed to call connection.commit()/rollback()/setAutoCommit(false) when JTA transaction is started from EJB container or with UserTransaction.begin().

If JTA transaction is started from EJB container you have to use "NotSupported" transaction attributes for the methods in which jdbc transactions are used or better simply use only JTA transaction.

Best regards,

Nikolai.

Former Member
0 Kudos

Hi Nikolai Tankov

Thank You v much. But I am using hibernate and hibernate do all the connection.commit()/rollback()/setAutoCommit(false) inside it.

Then how to resolve this issue

Thank You

Syed Saifuddin

Vlado
Advisor
Advisor
0 Kudos

Hi Syed,

The error messages above indicate that you are mixing both JTA and JDBC transactions. So, if you cannot get rid of the JDBC transactions (because of hibernate), you should get rid of the JTA transactions. As Nikolai already explained, the latter are started either by the container according to the transaction attributes of your EJBs (if your application contains EJBs at all), or by the client (e.g. JSP, servlets, bean-managed EJBs) with UserTransaction.begin(). Try to figure out the points where JTA transactions are being started and produce conflicts with hibernate-managed JDBC transactions, and switch them off.

HTH!

-Vladimir