I have some problem when using JTA of jboss
Code:
UserTransaction tx=null;
try {
tx =(UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
dao.addUser(user);
tx.commit();
} catch (Exception e) {
if(tx!=null)
tx.rollback();
throw new Exception(e);
}
the error info list:
Code:
13:19:02,687 INFO [STDOUT] session closed
13:19:05,859 INFO [STDOUT] filter starts
13:19:06,125 INFO [Environment] Hibernate 2.1 beta 5
13:19:06,156 INFO [Environment] hibernate.properties not found
13:19:06,156 INFO [Environment] using CGLIB reflection optimizer
13:19:06,171 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
13:19:06,421 INFO [Configuration] Mapping resource: User.hbm.xml
13:19:06,703 INFO [Binder] Mapping class: com.up.cip.po.User -> user
13:19:06,984 INFO [Configuration] Configured SessionFactory: null
13:19:06,984 INFO [Configuration] processing one-to-many association mappings
13:19:06,984 INFO [Configuration] processing one-to-one association property re
ferences
13:19:06,984 INFO [Configuration] processing foreign key constraints
13:19:07,046 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialec
t
13:19:07,046 INFO [SettingsFactory] Use outer join fetching: true
13:19:07,093 INFO [NamingHelper] JNDI InitialContext properties:{}
13:19:07,093 INFO [DatasourceConnectionProvider] Using datasource: java:/mysqld
atasource
13:19:07,109 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibe
rnate.transaction.JTATransactionFactory
13:19:07,109 INFO [NamingHelper] JNDI InitialContext properties:{}
13:19:07,125 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup
configured (in JTA environment, use of process level read-write cache is not re
commended)
13:19:07,125 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup
configured (in JTA environment, use of process level read-write cache is not re
commended)
13:19:07,390 INFO [SettingsFactory] Use scrollable result sets: true
13:19:07,390 INFO [SettingsFactory] JDBC 2 max batch size: 20
13:19:07,390 INFO [SettingsFactory] echoing all SQL to stdout
13:19:07,390 INFO [SettingsFactory] Query language substitutions: {}
13:19:07,390 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.JCSC
acheProvider
13:19:07,406 INFO [Configuration] instantiating and configuring caches
13:19:07,812 INFO [SessionFactoryImpl] building session factory
13:19:08,421 INFO [SessionFactoryObjectFactory] no JNDI name configured
13:19:08,609 ERROR [STDERR] java.lang.IllegalStateException: No transaction.
13:19:08,609 ERROR [STDERR] at org.jboss.tm.TxManager.rollback(TxManager.jav
a:272)
13:19:08,609 ERROR [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUser
Transaction.rollback(ServerVMClientUserTransaction.java:134)
and my hibernte.cfg.xml
Code:
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:/mysqldatasource</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.jdbc.batch_size">20</property>
<!-- Mapping files -->
<mapping resource="User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I don't know where is the problem?