-->
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.  [ 2 posts ] 
Author Message
 Post subject: hbm2ddl.SchemaExport failing in session bean
PostPosted: Sat Jun 18, 2005 10:37 am 
Newbie

Joined: Wed Jun 15, 2005 12:23 pm
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

org.hibernate.tool.hbm2ddl.SchemaExport is failing in a statless session bean.

Any hints ?

Thank You

Hibernate version:
3.0.2
Mapping documents:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">mysqlDS</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="org.hibernate.transaction.JTATransactionFactory">org.hibernate.transaction.JBossTransactionManagerLookup</property>

<!-- Mapping files -->
<mapping resource="mapFiles/ListValue.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.currentSession();
Session dom4jSession = session.getSession(EntityMode.DOM4J);
List results_xml = dom4jSession.createCriteria(ListValue.class).list();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:
2005-06-18 07:27:17,847 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful
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 org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:371)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:131)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:259)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:28)
at template.service.TemplateCSBean.TestHib(TemplateCSBean.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
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:313)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Name and version of the database you are using:
mysql 4.1
The generated SQL (show_sql=true):
2005-06-18 07:27:17,927 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-06-18 07:27:17,927 DEBUG [org.hibernate.SQL] select this_.id as id0_, this_.name as name0_0_, this_.allowPosting as allowPos3_0_0_, this_.createdDate as createdD4_0_0_, this_.createdBy as createdBy0_0_ from ListValue this_
2005-06-18 07:27:17,927 INFO [STDOUT] Hibernate: select this_.id as id0_, this_.name as name0_0_, this_.allowPosting as allowPos3_0_0_, this_.createdDate as createdD4_0_0_, this_.createdBy as createdBy0_0_ from ListValue this_
2005-06-18 07:27:17,927 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-06-18 07:27:17,927 DEBUG [MySQL] --> Connection.java:1335 com.mysql.jdbc.Connection.prepareStatement("select this_.id as id0_, this_.name as name0_0_, this_.allowPosting as allowPos3_0_0_, this_.createdDate as createdD4_0_0_, this_.createdBy as createdBy0_0_ from ListValue this_")
2005-06-18 07:27:17,927 DEBUG [MySQL] --> Connection.java:1354 com.mysql.jdbc.Connection.prepareStatement("select this_.id as id0_, this_.name as name0_0_, this_.allowPosting as allowPos3_0_0_, this_.createdDate as createdD4_0_0_, this_.createdBy as createdBy0_0_ from ListValue this_", 1003, 1007)

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 18, 2005 10:52 am 
Newbie

Joined: Wed Jun 15, 2005 12:23 pm
Posts: 7
I also ran it with DB2 and I got the same :
2005-06-18 07:47:32,633 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] Running hbm2ddl schema export
2005-06-18 07:47:32,633 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] exporting generated schema to database
2005-06-18 07:47:32,633 INFO [org.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2005-06-18 07:47:32,633 INFO [org.hibernate.connection.DatasourceConnectionProvider] Using datasource: DB2DS
2005-06-18 07:47:32,633 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful
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 org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:371)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:131)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:259)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:28)
at template.service.TemplateCSBean.TestHib(TemplateCSBean.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
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:313)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.