-->
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.  [ 3 posts ] 
Author Message
 Post subject: SchemaUpdate with JBoss getting You cannot commit
PostPosted: Tue Jun 08, 2004 2:53 pm 
Newbie

Joined: Tue Jun 08, 2004 2:48 pm
Posts: 1
Hey all-

I am using Hibernate inside of JBoss. My hibernate.cfg.xml uses a datasource I have specified in JBoss.

In my code I am trying to execute a SchemaUpdate execute on the config object to build the tables I have in my config, but not yet in my db.

When it in JBoss I get this error:
11:43:52,659 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
11:43:52,659 INFO [NamingHelper] JNDI InitialContext properties:{}
11:43:52,659 INFO [DatasourceConnectionProvider] Using datasource: java:/instanceDS
11:43:52,659 INFO [SchemaUpdate] Running hbm2ddl schema update
11:43:52,659 INFO [SchemaUpdate] fetching database metadata
11:43:52,689 ERROR [SchemaUpdate] could not get database metadata
java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:495)
at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:467)
at net.sf.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:113)


What exactly does this mean and what can I do to avoid this. When I run the app in standalone mode (ie, not using jboss and datasources, but a main). I don't have any issues.

Thanks in advance for any insight you can give me.

-Tommy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 7:02 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 12:29 pm
Posts: 39
Have the same problem, have set following properties:

Code:
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
      <property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
      <property name="jta.UserTransaction">java:comp/UserTransaction</property>


And
Code:
00:49:28,875 INFO  [SchemaUpdate] Running hbm2ddl schema update
00:49:28,875 INFO  [SchemaUpdate] fetching database metadata
00:49:28,875 ERROR [SchemaUpdate] could not get database metadata
java.sql.SQLException: You cannot commit during a managed transaction!
        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:490)
        at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:465)
        at net.sf.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:113)
        at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
        at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)


occurs only at SchemaUpdate.
After the exception i can use the SessionFactory and hibernate sessions as
as wonted.

??


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 9:51 am 
Newbie

Joined: Fri Jul 02, 2004 9:46 am
Posts: 1
I guess you are configuring the SessionFactory within a method in an EJB. You can't commit a transaction that's managed by the container. If that's the case you have to make sure that you declare the Transaction type for that method as NotSupported, this will prevent the EJB container from starting a container managed transaction when calling the method and hibernate will then be able to commit.


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