[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Hibernate - Unable to locate current JTA transaction
bmcgovern
do-not-reply at jboss.com
Wed Oct 25 13:45:44 EDT 2006
My problem: I am trying to get transactions working with hibernate 3 and jboss 4.0.4.
I deployed my har file and it worked. I can get a currentSession() from JNDI, but I cannot get a transaction to work. It throughs Unable to locate current JTA transaction exception.
I'm not using EJBs, rather DAO. What am i doing wrong?
datasource-ds.xml
---------------------------------------------------------------
| <datasources>
| <local-tx-datasource>
| <jndi-name>TeenFitData</jndi-name>
| <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
| <connection-url>jdbc:jtds:sqlserver://192.168.100.102:1433;databaseName=Teenfit_Hibernate;tds=8.0;lastupdatecount=true</connection-url>
| <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
| <user-name>user</user-name>
| <password>pass</password>
| </local-tx-datasource>
| </datasources>
|
jboss-service.xml
---------------------------------------------------------------
<server>
| <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.adminguide:name=ExampleSessionFactory">
| <attribute name="DatasourceName">java:/TeenFitData</attribute>
| <attribute name="Dialect"> org.hibernate.dialect.SQLServerDialect</attribute>
| <attribute name="SessionFactoryName">java:/teenfit/TeenFitDataSessionFactory </attribute>
| <attribute name="CacheProviderClass"> org.hibernate.cache.HashtableCacheProvider</attribute>
| <attribute name="Hbm2ddlAuto">create-drop</attribute>
| <attribute name="ShowSqlEnabled">true</attribute>
| </mbean>
| </server>
Data code
-----------------------------------------------
InitialContext ctx = new InitialContext();
| SessionFactory factory = (SessionFactory) ctx.lookup("java:/teenfit/TeenFitDataSessionFactory");
| //Session hsession = TeenFitHibernateUtil.getSessionFactory().getCurrentSession();
| Session hsession = factory.getCurrentSession();
| Transaction zTransaction = null;
| //zTransaction = (Transaction)new InitialContext().lookup("java:comp/UserTransaction");
|
| zTransaction = hsession.beginTransaction();
| System.out.println("**TRANSACTION FOUNT**" + hsession.getTransaction().toString());
|
| hsession.saveOrUpdate(HibernateTFUser);
|
|
| zTransaction.commit();
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3980791#3980791
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3980791
More information about the jboss-user
mailing list