cancel
Showing results for 
Search instead for 
Did you mean: 

How can I lookup or instantiate the TransactionManager implementation?

Former Member
0 Kudos

Hi,

I’m trying to port a J2EE application to Web AS 6.30 that uses the Hibernate framework (http://www.hibernate.org) and container managed transactions. To make it work I have to write a class that looks up the transaction manager and define it as transaction.manager_lookup_class in my hibernate.cfg.xml.

This would be easy if I know how to lookup or instantiate the javax.transaction.TransactionManager implementation. I appreciate any help.

Regards,

Anke

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

have you seen this article: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/working with transactions in sap web application server java 6.40.article

It explains how to use transactions in your applications on Web AS 6.40.

Hope that helps!

Former Member
0 Kudos

Hi Ivaylo,

Thanks! I’m now able to obtain a javax.transaction.UserTransaction with ctx.lookup("java:comp/UserTransaction"). Here’s my hibernate.cfg.xml:

<hibernate-configuration>

<session-factory >

<!-- properties -->

<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>

<property name="connection.datasource">java:comp/env/my_Datasource</property>

<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>

<!-- mapping files -->

...

</session-factory>

</hibernate-configuration>

I’m still looking for a way to get a javax.transaction.TransactionManager. This is not needed for enabling container managed transactions with Hibernate. It’s required when JVM-level caching is enabled which is what I plan to do.

Can you or anybody else help?

Anke

Former Member
0 Kudos

Hi Ivaylo,

thanks to you I was finally able to locate the TransactionManager. I found a hint from you in another topic where you pointed to the JNDI Registry which can be accessed by the Visual Administrator. There I found the TransactionManager entry.

The rest of the work was quite easy to do. I wrote my own TransactionManagerLookupClass and integrated it with Hibernate. I attach my solution to this message.

Regards,

Anke

<i># SAPWebASTransactionManagerLookup.java #</i>

package de.iop.hibernate;

import net.sf.hibernate.transaction.JNDITransactionManagerLookup;

public class SAPWebASTransactionManagerLookup extends JNDITransactionManagerLookup {

protected String getName() {

return "TransactionManager";

}

public String getUserTransactionName() {

return "java:comp/UserTransaction";

}

}

<i># hibernate.cfg.xml #</i>

<hibernate-configuration>

<session-factory >

<!-- properties -->

<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>

<property name="connection.datasource">java:comp/env/my_Datasource</property>

<property name="transaction.manager_lookup_class">de.iop.hibernate.SAPWebASTransactionManagerLookup</property>

<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>

<!-- mapping files -->

...

</session-factory>

</hibernate-configuration>

detlev_beutner
Active Contributor
0 Kudos

Hi Anke,

for I'm just going with Hibernate on EP, I wonder how your deployment strategy is. Do you deploy the Hibernate stuff along with your app?

My aim is to set Hibernate on the base of the J2EE engine so that each (portal) application can use it (with it's own mapping classes and config files). The problem is the use of the thread context classloader for loading the mapping classes. For pure web applications, I expect no problem, but for portal applications under the EP the thread context classloader does not work.

I'm quite unsatisfied with this. It works when we deploy the whole Hibernate stuff with the portal app, but this is really ugly (at least deploying 1 MB; several Hibernate2.jar's if used in different app's etc).

Any idea?

Best regards

Detlev

Answers (0)