-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Identity Generator throwing - Cannot commit during a mgd tx
PostPosted: Wed Jan 05, 2005 12:44 pm 
Newbie

Joined: Wed Jan 05, 2005 7:13 am
Posts: 4
Hi,

I know I cannot us hilo generators in a managed transaction but can I use Identity generators?

Using an identity generator I still get the old "You cannot commit during a managed transaction!" error.

The object is actually being persisted in the database but I'd feel much happier if I could get rid of the errrors.

If you think I should be able to do what I'm doing then below are the details of my environment and a full debug log showing the complete transaction.

Any help would be much appreciated.
Thanks,
Jon.

Hibernate version:
2.1.7

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="com.vnl.audit.entity.AuditLog"
table="AuditLog"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="ID"
column="ID"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="identity">
</generator>
</id>

<property
name="processID"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="Process_ID"
length="25"
not-null="false"
/>

<property
name="applicationName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="Application_Name"
length="25"
not-null="true"
/>

<property
name="machineName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="Machine_Name"
length="25"
not-null="true"
/>

<property
name="result"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="Result"
length="25"
not-null="true"
/>

<property
name="comment"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="Comment"
length="500"
not-null="false"
/>

<property
name="submitted"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="Submitted"
not-null="true"
/>

<property
name="created"
type="java.sql.Timestamp"
update="true"
insert="true"
access="property"
column="Created"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-AuditLog.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
protected void storeObj(Object obj) throws DAOException {
log.debug("Storing object");
try {
Session session = HibernateSession.currentSession();
session.saveOrUpdate(obj);
session.flush();
session.connection().commit();
}
catch(HibernateException he)
{
log.error("Hibernate error storing object, rolling back", he);
rollback();
throw new DAOException(he);
}
catch (SQLException sqle) {
log.error("SQL error storing object, rolling back", sqle);
rollback();
throw new DAOException(sqle);
}
finally {
closeSession();
}
}

Name and version of the database:
MySQL 4.0.18

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


2005-01-05 16:10:45,108 DEBUG [com.vnl.audit.service.ejb.AuditLogWriter] Storing object
2005-01-05 16:10:45,108 INFO [net.sf.hibernate.cfg.Configuration] Mapping resource: com/vnl/audit/entity/AuditLog.hbm.xml
2005-01-05 16:10:45,139 DEBUG [net.sf.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
2005-01-05 16:10:45,139 DEBUG [net.sf.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.Binder] Mapping class: com.vnl.audit.entity.AuditLog -> AuditLog
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: ID -> ID, type: long
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: processID -> Process_ID, type: string
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: applicationName -> Application_Name, type: string
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: machineName -> Machine_Name, type: string
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: result -> Result, type: string
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: comment -> Comment, type: string
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: submitted -> Submitted, type: timestamp
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: created -> Created, type: timestamp
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.Configuration] processing one-to-many association mappings
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.Configuration] processing one-to-one association property references
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.Configuration] processing foreign key constraints
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.dialect.Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
2005-01-05 16:10:45,155 DEBUG [net.sf.hibernate.exception.SQLExceptionConverterFactory] Using dialect defined converter
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.SettingsFactory] Maximim outer join fetch depth: 2
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.cfg.SettingsFactory] Use outer join fetching: true
2005-01-05 16:10:45,155 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.connection.DatasourceConnectionProvider] Using datasource: java:/DiagnosticsDS
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiated TransactionManagerLookup
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiated TransactionManagerLookup
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.SettingsFactory] Use scrollable result sets: true
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.SettingsFactory] Use JDBC3 getGeneratedKeys(): true
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.SettingsFactory] Optimize cache for minimal puts: false
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.SettingsFactory] Query language substitutions: {}
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.SettingsFactory] cache provider: net.sf.hibernate.cache.EhCacheProvider
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.cfg.Configuration] instantiating and configuring caches
2005-01-05 16:10:45,170 INFO [net.sf.hibernate.impl.SessionFactoryImpl] building session factory
2005-01-05 16:10:45,186 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] instantiating session factory with properties: {java.vendor=Sun Microsystems Inc., catalina.base=C:\jboss\jboss-4.0.0RC1\server\default, catalina.useNaming=false, os.name=Windows 2000, sun.boot.class.path=C:\Sun\AppServer\jdk\jre\lib\rt.jar;C:\Sun\AppServer\jdk\jre\lib\i18n.jar;C:\Sun\AppServer\jdk\jre\lib\sunrsasign.jar;C:\Sun\AppServer\jdk\jre\lib\jsse.jar;C:\Sun\AppServer\jdk\jre\lib\jce.jar;C:\Sun\AppServer\jdk\jre\lib\charsets.jar;C:\Sun\AppServer\jdk\jre\classes, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_02-b03, user.name=jaddy, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, jboss.bind.address=0.0.0.0, jboss.remoting.instanceid=5916dc2fea728fa7x193a66fxfee803c2e2x-7ffd357, jboss.home.dir=C:\jboss\jboss-4.0.0RC1, user.language=en, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, sun.boot.library.path=C:\Sun\AppServer\jdk\jre\bin, jboss.home.url=file:/C:/jboss/jboss-4.0.0RC1/, java.version=1.4.2_02, version=2.4.1, user.timezone=Europe/London, jboss.server.home.dir=C:\jboss\jboss-4.0.0RC1\server\default, sun.arch.data.model=32, java.endorsed.dirs=C:\Sun\AppServer\jdk\jre\lib\endorsed, jboss.server.home.url=file:/C:/jboss/jboss-4.0.0RC1/server/default/, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, jboss.server.config.url=file:/C:/jboss/jboss-4.0.0RC1/server/default/conf/, user.country=GB, java.home=C:\Sun\AppServer\jdk\jre, java.vm.info=mixed mode, jboss.lib.url=file:/C:/jboss/jboss-4.0.0RC1/lib/, os.version=5.0, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory, hibernate.connection.datasource=java:/DiagnosticsDS, path.separator=;, java.vm.version=1.4.2_02-b03, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, user.variant=, vendor-url=http://xml.apache.org/xalan-j, java.protocol.handler.pkgs=org.jboss.net.protocol, java.awt.printerjob=sun.awt.windows.WPrinterJob, vendor=Apache Software Foundation, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., jboss.server.temp.dir=C:\jboss\jboss-4.0.0RC1\server\default\tmp, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces, user.home=C:\Documents and Settings\jaddy.VNL2000, java.rmi.server.RMIClassLoaderSpi=org.jboss.system.JBossRMIClassLoader, java.specification.vendor=Sun Microsystems Inc., jboss.identity=5916dc2fea728fa7x193a66fxfee803c2e2x-7ffd357, org.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl, jboss.home=C:\jboss\jboss-4.0.0RC1, java.library.path=C:\Sun\AppServer\jdk\bin;.;C:\WINNT\system32;C:\WINNT;c:\sun\appserver\jdk\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\BES\bin;C:\JBuilder9\extras\ant\bin;C:\Program Files\cvsnt, java.vendor.url=http://java.sun.com/, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\jboss\jboss-4.0.0RC1\bin\run.jar;C:\Sun\AppServer\jdk\lib\tools.jar, jbossmx.loader.repository.class=org.jboss.mx.loading.UnifiedLoaderRepository3, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=C:\jboss\jboss-4.0.0RC1\server\default, jboss.remoting.domain=JBOSS, sun.cpu.endian=little, sun.os.patch.level=Service Pack 4, jboss.server.lib.url=file:/C:/jboss/jboss-4.0.0RC1/server/default/lib/, java.rmi.server.codebase=http://sys079:8083/, java.io.tmpdir=C:\DOCUME~1\JADDY~1.VNL\LOCALS~1\Temp\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, jboss.server.data.dir=C:\jboss\jboss-4.0.0RC1\server\default\data, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, jboss.remoting.jmxid=10.254.136.53/1104940821295/5916dc2fea728fa7x193a66fx101439aeb2fxX800029/1, java.ext.dirs=C:\Sun\AppServer\jdk\jre\lib\ext, user.dir=C:\jboss\jboss-4.0.0RC1\bin, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, jboss.server.base.dir=C:\jboss\jboss-4.0.0RC1\server, jboss.server.base.url=file:/C:/jboss/jboss-4.0.0RC1/server/, javax.management.builder.initial=org.jboss.mx.server.MBeanServerBuilderImpl, file.encoding=Cp1252, catalina.ext.dirs=C:\jboss\jboss-4.0.0RC1\server\default\lib, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, java.specification.version=1.4, jboss.server.name=default}
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] registered: 8a7e08b501439c7a010143a470800001 (unnamed)
2005-01-05 16:10:45,248 INFO [net.sf.hibernate.impl.SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] instantiated session factory
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] obtaining JTA TransactionManager
2005-01-05 16:10:45,248 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() unsaved instance
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] saving [com.vnl.audit.entity.AuditLog#<null>]
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] executing insertions
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.persister.EntityPersister] Inserting entity: com.vnl.audit.entity.AuditLog (native id)
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.SQL] insert into AuditLog (Process_ID, Application_Name, Machine_Name, Result, Comment, Submitted, Created) values (?, ?, ?, ?, ?, ?, ?)
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.persister.EntityPersister] Dehydrating entity: [com.vnl.audit.entity.AuditLog#<null>]
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.StringType] binding 'Proc1' to parameter: 1
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.StringType] binding 'App1' to parameter: 2
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.StringType] binding 'Machine1' to parameter: 3
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.StringType] binding 'OK' to parameter: 4
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.StringType] binding 'None' to parameter: 5
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.TimestampType] binding '2005-01-05 16:10:45' to parameter: 6
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.type.TimestampType] binding '2005-01-05 16:10:45' to parameter: 7
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.persister.AbstractEntityPersister] Natively generated identity: 16
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] flushing session
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushing entities and processing referenced collections
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] Processing unreferenced collections
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] Scheduling collection removes/(re)creates/updates
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.Printer] listing entities:

2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.Printer] com.vnl.audit.entity.AuditLog{created=2005-01-05 16:10:45, processID=Proc1, applicationName=App1, result=OK, comment=None, machineName=Machine1, submitted=2005-01-05 16:10:45, ID=16}
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] executing flush
2005-01-05 16:10:45,248 DEBUG [net.sf.hibernate.impl.SessionImpl] post flush
2005-01-05 16:10:45,248 ERROR [com.vnl.audit.service.ejb.AuditLogWriter] SQL error storing object, rolling back
java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:499)
at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:451)
at com.vnl.audit.persistence.BaseDAO.storeObj(Unknown Source)
at com.vnl.audit.persistence.LogDAO.writeLog(Unknown Source)
at com.vnl.audit.service.ejb.AuditLogWriter.onMessage(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:87)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:93)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
at org.jboss.ejb.Container.invoke(Container.java:871)
at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:920)
at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1213)
at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:871)
at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:159)
at org.jboss.mq.SpySession.run(SpySession.java:347)
at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
at java.lang.Thread.run(Thread.java:534)
2005-01-05 16:10:45,248 DEBUG [com.vnl.audit.service.ejb.AuditLogWriter] Rolling back
2005-01-05 16:10:45,248 ERROR [com.vnl.audit.service.ejb.AuditLogWriter] SQL error rolling back
java.sql.SQLException: You cannot rollback during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcRollback(BaseWrapperManagedConnection.java:511)
at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedConnection.java:460)
at com.vnl.audit.persistence.BaseDAO.rollback(Unknown Source)
at com.vnl.audit.persistence.BaseDAO.storeObj(Unknown Source)
at com.vnl.audit.persistence.LogDAO.writeLog(Unknown Source)
at com.vnl.audit.service.ejb.AuditLogWriter.onMessage(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:87)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:93)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
at org.jboss.ejb.Container.invoke(Container.java:871)
at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:920)
at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1213)
at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:871)
at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:159)
at org.jboss.mq.SpySession.run(SpySession.java:347)
at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
at java.lang.Thread.run(Thread.java:534)
2005-01-05 16:10:45,264 DEBUG [net.sf.hibernate.impl.SessionImpl] closing session
2005-01-05 16:10:45,264 DEBUG [net.sf.hibernate.impl.SessionImpl] disconnecting session
2005-01-05 16:10:45,264 ERROR [com.vnl.audit.service.ejb.AuditLogWriter] com.vnl.audit.persistence.DAOException: You cannot rollback during a managed transaction! wraps: [java.sql.SQLException: You cannot rollback during a managed transaction!]
2005-01-05 16:10:45,264 DEBUG [net.sf.hibernate.engine.CacheSynchronization] transaction before completion callback
2005-01-05 16:10:45,264 DEBUG [net.sf.hibernate.engine.CacheSynchronization] transaction after completion callback, status: 3
2005-01-05 16:10:45,264 DEBUG [net.sf.hibernate.impl.SessionImpl] transaction completion
2005-01-05 16:10:46,483 DEBUG [net.sf.hibernate.impl.SessionImpl] running Session.finalize()

_________________
Regards,
Jon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 3:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Your code is doing something wrong
Code:
at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedConnection.java:460)
at com.vnl.audit.persistence.BaseDAO.rollback(Unknown Source)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 6:50 am 
Newbie

Joined: Wed Jan 05, 2005 7:13 am
Posts: 4
Thanks for the feedback but the rollback is only being attempted after this initial error:

2005-01-05 16:10:45,248 ERROR [com.vnl.audit.service.ejb.AuditLogWriter] SQL error storing object, rolling back
java.sql.SQLException: You cannot commit during a managed transaction!


Outside of a managed environment the code works fine.. I would also guess that a rollback issued when using a managed connection should be ignored by hibernate in much the same way as a commit would?

_________________
Regards,
Jon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 7:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
OK then
Code:
at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:451)
at com.vnl.audit.persistence.BaseDAO.storeObj(Unknown Source)

Your code is commiting.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 7:43 am 
Newbie

Joined: Wed Jan 05, 2005 7:13 am
Posts: 4
Maybe then I have mis-understood something....my understanding is that I can leave hibernate to ignore the commit I issue as hibernate will know its using a managed connection.

Is this not correct?

_________________
Regards,
Jon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 7:57 am 
Newbie

Joined: Wed Jan 05, 2005 7:13 am
Posts: 4
Sorry, my mistake i've been using the session and not using the transaction api.

Thanks for your help emmanuel, now wheres that dunce hat.....

_________________
Regards,
Jon.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 09, 2005 7:59 am 
Newbie

Joined: Sun Jan 09, 2005 7:51 am
Posts: 1
Hi, I'm pretty new to this hibernate stuff. I thought with managed transactions (i.e within a J2ee app server) you did not have to worry about the transaction management side of things at all. I thought the container managed it for you. Therefore somehting along the lines of (if using within an EJB with CMT):

ctx = new InitialContext();
Object obj = ctx.lookup("java:/hibernate/SessionFactory");
Session session = factory.openSession();
session.save(dto);
session.flush();
session.close();

should perform the commit for you as long as your EJB method is set to act within a CMT.

Therefore you should not need to call connection.commit() or tx.commit().

But I am new to all of this and trying to get my head around it.

Cheers

Grant


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 09, 2005 9:40 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/245.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.