-->
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.  [ 6 posts ] 
Author Message
 Post subject: Auto schema generation with hibernate 2.1.8 and JBoss 4.0.0
PostPosted: Fri Apr 15, 2005 9:36 am 
Newbie

Joined: Fri Apr 15, 2005 9:01 am
Posts: 2
Goodday All

I had hibernate 2.1.8 running standalone in our app succesfully. Our shema generation was done using ant 1.6.2. All running 100%

I then started with the task of having hibernate running in jboss. I have a Sybase jndi datasource up and running in jboss which hibernate connects to and everything is working and all tests is passing. My problem is with the schema generation process. Initialy I launched this process from ant, but we ran into problems with the initial context not being available over the wire (RMI).

I then set the following property in the hibernate.cfg.xml:
"<property name="hbm2ddl.auto">create-drop</property>" - but I get the following error from jboss logs when the schema generation process is envoked:

----- START OF LOG ------

14:44:34,606 INFO [Environment] Hibernate 2.1.8
14:44:34,610 INFO [Environment] hibernate.properties not found
14:44:34,614 INFO [Environment] using CGLIB reflection optimizer
14:44:34,615 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
14:44:34,621 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
14:44:34,621 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
14:44:34,642 INFO [Configuration] Mapping resource: za/co/rmb/dv/domain/hibernate/RafAdminDataRecord.hbm.xml
14:44:35,303 INFO [Binder] Mapping class: za.co.rmb.dv.domain.hibernate.RafAdminDataRecord -> RafAdminDataRecord
14:44:35,500 INFO [Configuration] Configured SessionFactory: null
14:44:35,732 INFO [Configuration] processing one-to-many association mappings
14:44:35,733 INFO [Configuration] processing one-to-one association property references
14:44:35,734 INFO [Configuration] processing foreign key constraints
14:44:35,913 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.SybaseDialect
14:44:35,929 INFO [SettingsFactory] Use outer join fetching: true
14:44:35,941 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.provider.url=jnp://localhost:1099}
14:44:35,943 INFO [DatasourceConnectionProvider] Using datasource: java:/rafDataSource
14:44:35,952 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
14:44:36,429 INFO [SettingsFactory] Use scrollable result sets: true
14:44:36,430 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
14:44:36,430 INFO [SettingsFactory] Optimize cache for minimal puts: false
14:44:36,431 INFO [SettingsFactory] echoing all SQL to stdout
14:44:36,432 INFO [SettingsFactory] Query language substitutions: {}
14:44:36,433 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.EhCacheProvider
14:44:36,442 INFO [Configuration] instantiating and configuring caches
14:44:36,464 WARN [Configurator] No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/opt/jboss/jboss-4.0.0/server/default/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
14:44:36,660 INFO [SessionFactoryImpl] building session factory
14:44:37,077 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
14:44:37,083 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.SybaseDialect
14:44:37,085 INFO [Configuration] processing one-to-many association mappings
14:44:37,086 INFO [Configuration] processing one-to-one association property references
14:44:37,086 INFO [Configuration] processing foreign key constraints
14:44:37,088 INFO [Configuration] processing one-to-many association mappings
14:44:37,089 INFO [Configuration] processing one-to-one association property references
14:44:37,090 INFO [Configuration] processing foreign key constraints
14:44:37,093 INFO [SchemaExport] Running hbm2ddl schema export
14:44:37,095 INFO [SchemaExport] exporting generated schema to database
14:44:37,096 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.provider.url=jnp://localhost:1099}
14:44:37,098 INFO [DatasourceConnectionProvider] Using datasource: java:/rafDataSource
14:44:37,100 ERROR [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 net.sf.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:121)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:84)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:198)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at za.co.rmb.dv.domain.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:29)
at za.co.rmb.dv.domain.hibernate.RafVisitor.visit(RafVisitor.java:39)
at za.co.rmb.dv.domain.hibernate.RafUpdateWrapper.accept(RafUpdateWrapper.java:14)
at za.co.rmb.dv.service.finance.raf.RafAdminRecordConsumer.onMessage(RafAdminRecordConsumer.java:43)
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:585)
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:95)
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:854)
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:877)
at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:159)
at org.jboss.mq.SpySession.run(SpySession.java:351)
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:595)
14:44:37,130 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.SybaseDialect
14:44:37,133 INFO [Configuration] processing one-to-many association mappings
14:44:37,135 INFO [Configuration] processing one-to-one association property references
14:44:37,138 INFO [Configuration] processing foreign key constraints
14:44:37,140 INFO [Configuration] processing one-to-many association mappings
14:44:37,143 INFO [Configuration] processing one-to-one association property references
14:44:37,145 INFO [Configuration] processing foreign key constraints


----- END OF LOG ------

What I don't understand is why the exception is thrown :
" java.sql.SQLException: You cannot commit during a managed transaction! "

Are there any other way to do the Schema generation?

Thanks alot for a GREAT product !!!

Leon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 19, 2005 2:58 am 
Newbie

Joined: Fri Apr 15, 2005 9:01 am
Posts: 2
Hi all, I have solved the problem:

In the message driven bean, the <transaction-type> tag must change from:
<transaction-type>Container</transaction-type> to
<transaction-type>Bean</transaction-type>.

In the hibernate.cfg.xml, add <property name="hbm2ddl.auto">update</property> to the other properties. There are other options than update as well. So here is the complete file:

======= File BEGIN =========

<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property>
<property name="connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="jndi.url">jnp://localhost:1099</property>
<property name="connection.datasource">java:/rafDataSource</property>
<property name="connection.username">*********</property>
<property name="connection.password">*********</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create-drop</property>

<mapping resource="za/co/test/domain/hibernate/AdminDataRecord.hbm.xml"/>
</session-factory>
</hibernate-configuration>

======= File END =========

This will enable the developer to manage the transactions explicitly. The UserTransaction object must be used to begin() and commit() the transaction. The running instance of UserTransaction can be get from the MessageDrivenContext - or probably from any other context.

Well, hope I have help somebody out there as well.
Bye
Leon


Top
 Profile  
 
 Post subject: Can I get you to contact me directly?
PostPosted: Wed Apr 27, 2005 11:12 am 
Beginner
Beginner

Joined: Mon Apr 18, 2005 10:25 am
Posts: 38
Location: Maryland
Leon-I am going back to check your Mbean against mine but I don't get an error when I run the schemaexport however no table is created on my sybase db. I have posted several times and no one seems to be able to help (no responses). As well, you said you were able to generate the .hbm.xml with success. My task looks correct, does not fail but does not create any xml files. I am hoping that we might be able to communicate directly: jacky@itmc-wo.com or by phone: 301-957-2227 EST. I am solo on this and don't know anyone using hibernate let alone with ant, JBoss and Sybase. Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You should try to bootstrap the SessionFactory as part of you application startup. You can use the JBoss-Hibernate integration to acheive this using a HAR file...


Top
 Profile  
 
 Post subject: Clarify bootstrap
PostPosted: Wed Apr 27, 2005 3:54 pm 
Beginner
Beginner

Joined: Mon Apr 18, 2005 10:25 am
Posts: 38
Location: Maryland
Can you clarify bootstrap? I'm not familiar with that term.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 7:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
http://en.wikipedia.org/wiki/Bootstrap


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