on 11-10-2004 10:42 AM
Hi,
Im 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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ivaylo,
Thanks! Im now able to obtain a javax.transaction.UserTransaction with ctx.lookup("java:comp/UserTransaction"). Heres 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>
Im still looking for a way to get a javax.transaction.TransactionManager. This is not needed for enabling container managed transactions with Hibernate. Its required when JVM-level caching is enabled which is what I plan to do.
Can you or anybody else help?
Anke
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>
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
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.