-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: New JBoss - Hibernate iteration complete
PostPosted: Mon Aug 30, 2004 4:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The second iteration of the integration code is completed and checked into JBoss CVS. Changes include:
  • New managed operation on the MBean rebuildSessionFactory(); after changes to the MBean properties, perform this managed operation to rebuild the session factory and notify MBean listeners; the MBean tracks changes to its properties and exposes the fact that it has changed via the new "dirty" RO managed property
  • Event generation when MBean's SessionFactory is built or destroyed
  • SessionContext is now aware of changes to MBean's SessionFactory through event notifications
  • Added ability to retreive "unmanaged" session from SessionContext (useful for Hibernate callback handlers)
  • Added ability to define Hibernate Interceptors; the Interceptor must have a no-arg constructor; it can be registered with the MBean (for factory-scoped interceptor) or with the session management interceptors (for session-scoped interceptor)
  • Session management interceptors now accept an "explicitFlush" config parameter; if true (the default), the session will be flushed prior to unbinding and closing


It will be available in the next JBoss 3.2.6 release, or you grab and build it from CVS.

I'll update the Wiki when I get a chance to reflect these new changes; just wanted to give y'all a heads-up.


Last edited by steve on Thu Jul 28, 2005 1:20 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 9:53 pm 
Newbie

Joined: Sat Aug 14, 2004 6:44 am
Posts: 17
Location: Auckland, NZ
Cool. Will it make it into 4.0.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 11:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Should. I'll double check


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 12:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, this will be in 4.0 final.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 4:42 am 
Newbie

Joined: Sat Aug 14, 2004 6:44 am
Posts: 17
Location: Auckland, NZ
Just tried in JBoss 4.0RC2. It appear to mainly included here too, but have not got it to work yet.

1) EhCacheProvider not in the hibernate2.jar shipped with JBoss. The hibernate2.jar must therefore be older than hibernate 2.1.5.
So I replaced the hibernate2.jar with that from 2.1.6

2) I did everything else. HibernateService and HARDeployer start OK. HibernateService is in JNDI at usual place. However, when my EJB looks up the HibernateService, I get an IllegalStateException runtime exception which I catch and log as below.

Code:
2004-09-08 20:35:57,109 DEBUG [org.jboss.ejb.plugins.LogInterceptor] Invoke: [EisTransactionManagerLocal] createTransaction(com.eftwire.torrent.component.eis.server.EisTransactionInfo@d5c166)
2004-09-08 20:35:57,109 DEBUG [org.jboss.hibernate.session.EjbInterceptor] EjbInterceptor intercepted method invocation : public abstract com.eftwire.torrent.component.eis.server.EisTransactionInfo com.eftwire.torrent.component.eis.interfaces.EisTransactionManagerLocal.createTransaction(com.eftwire.torrent.component.eis.server.EisTransactionInfo)
2004-09-08 20:35:57,109 INFO  [org.jboss.hibernate.session.SessionContextHelper] Generating Hibernate session for scoped bind []
2004-09-08 20:35:57,109 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2004-09-08 20:35:57,109 DEBUG [org.jboss.hibernate.session.SessionContext] Session [net.sf.hibernate.impl.SessionImpl@1ca04be] being bound to []
2004-09-08 20:35:57,109 DEBUG [org.jboss.hibernate.session.store.TransactionSessionStorage$TransactionSynch] Preparing synch to manage session [net.sf.hibernate.impl.SessionImpl@1ca04be, true]
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@26a690, cl=org.jboss.mx.loading.UnifiedClassLoader3@1fd56dc{ url=null ,addedOrder=0}
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@26a690, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@151c208{ url=null ,addedOrder=0}
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@26a690, cl=org.jboss.mx.loading.UnifiedClassLoader3@99c1d9{ url=null ,addedOrder=0}
2004-09-08 20:35:57,109 INFO  [com.eftwire.torrent.component.eis.server.EisTransactionManagerBean] Enter: createTransaction
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@26a690, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@85c128{ url=null ,addedOrder=0}
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
2004-09-08 20:35:57,109 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@26a690, cl=org.jboss.mx.loading.UnifiedClassLoader3@14c3ee7{ url=null ,addedOrder=0}
2004-09-08 20:35:57,109 ERROR [com.eftwire.torrent.component.eis.server.EisTransactionManagerBean] SessionFactory with name [java:/hibernate/SessionFactory] not yet registered with SessionContext
java.lang.IllegalStateException: SessionFactory with name [java:/hibernate/SessionFactory] not yet registered with SessionContext
   at org.jboss.hibernate.session.SessionContext.getStorage(SessionContext.java:135)
   at org.jboss.hibernate.session.SessionContext.getSession(SessionContext.java:43)
   at com.eftwire.torrent.component.eis.server.EisTransactionManagerBean.createTransaction(EisTransactionManagerBean.java:64)
   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.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
   at org.jboss.ejb.plugins.AbstractInterceptor.invoke(AbstractInterceptor.java:96)
   at org.jboss.hibernate.session.EjbInterceptor.invoke(EjbInterceptor.java:81)
   at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
   at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:365)
   at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
   at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
   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:859)
   at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
   at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:82)
   at $Proxy84.createTransaction(Unknown Source)
   at com.eftwire.torrent.component.eis.server.TopupRequestHandler.handle(TopupRequestHandler.java:59)
   at com.eftwire.torrent.component.eis.server.EisRequestBean.handle(EisRequestBean.java:59)
   at com.eftwire.torrent.platform.jms.AbstractTorrentMessageBean.onMessage(AbstractTorrentMessageBean.java:71)
   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:859)
   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:534)


Is there something different (from the current wiki page) that I must do to use this update ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:27 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Hi,

I guess you haven't added the SessionFactoryName tag to your hibernate-service.xml which is included in the HAR file.
Mine looks like:
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=HibernateTicketsystem">
<attribute name="DatasourceName">java:/PostgresDS</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
<attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
<attribute name="DefaultSchema">public</attribute>
</mbean>
and I'm using JBoss 3.2.6 and 4.0.
Hope this helps

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 7:53 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
david.wade wrote:
Just tried in JBoss 4.0RC2. It appear to mainly included here too, but have not got it to work yet.


2) I did everything else. HibernateService and HARDeployer start OK. HibernateService is in JNDI at usual place. However, when my EJB looks up the HibernateService, I get an IllegalStateException runtime exception which I catch and log as below.


David,

We've been discussing with Steve here http://forum.hibernate.org/viewtopic.php?t=933927 about some issues of the current jboss-hibernate integration stuff.

Recently, Steve added bindName parameter which is optional and should be equal of jndiName by default.

But there's a small bug in current version (Steve, fix it please).
Code:
      this.explicitBindName = bindName != null;

should be
Code:
      this.explicitBindName = (bindName != null && bindName.length()!=0);


This is because for absent servlet filter parameter null is returned, but for ejb interceptor

Code:
            <interceptor service="jboss.har:service=Hibernate" scope="transaction">org.jboss.hibernate.session.EjbInterceptor</interceptor>


config.getAttribute("bindName") returns an empty string.


David, by the way as you're using this stuff - maybe you could share your opinion about things we're discussing at http://forum.hibernate.org/viewtopic.php?t=933927 ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 11:00 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
David - just to clarify my previous post - this bug is the source of your exception.
While it's not fixed, just add explicit bindName in interceptor description.
bindName="java:/hibernate/SessionFactory"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 7:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I actually just removed the bindName stuff.

I also renamed SessionContext -> HibernateContext. I never really liked the SessionContext name because of the name clash with javax.ejb.SessionContext.

I also implemented what is hopefully a fix to the issue you are seeing. Essentially, the HibernateContext stuff is now using ENC internally to store the "current session". This is a bit verbose currently due to jboss naming not being able handle non-serializable objects as bind values. Currently this stuff is only in HEAD. I'll move it to the 3.2.6 branch as soon as I get time. In the meantime, you're more than welcome to build that module from HEAD and drop it into your 3.2.6 install.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 2:21 pm 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
steve wrote:
Essentially, the HibernateContext stuff is now using ENC internally to store the "current session".


Thanks, Steve. This is exactly what I initially suggested. Seems to work perfect by now..

One bug found: in TransactionSessionStorage$TransactionSync
session.flush() should be moved from afterCompletion() to beforeCompletion() and there HibernateException should be rethrown as runtime to make TM rollback transaction in case hibernate cannot persist changes.
(or is there a better way to setRollbackOnly from beforeCompletion() ? )


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 1:15 am 
Newbie

Joined: Sat Aug 14, 2004 6:44 am
Posts: 17
Location: Auckland, NZ
Thanks for the input everybody.

I took the easy option of downloading the latest source and rebuilding jboss-hibernate.jar. This allowed everything to be done as per the wiki with the exception of using
Code:
org.jboss.hibernate.session.HibernateContext.getSession("java:/hibernate/SessionFactory");

instead to get the session.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 10, 2004 5:09 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
Correction to my previous post: rethrowing exception is not necessary indeed, since hibernate itself initiates rollback in case of error.

But moving flush() still necessary.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 18, 2004 4:39 am 
Newbie

Joined: Sat Sep 18, 2004 4:30 am
Posts: 2
Location: Pune, India
I have JBoss 3.2.5, Hibernate 2.1 and mySQL 4.0.18. Does that mean I have to wait that long to integrate Hibernate with JBoss? If not, any easy solution for a newbie?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 3:39 pm 
Newbie

Joined: Tue Nov 11, 2003 5:25 pm
Posts: 17
Location: Milwaukee, Wi
smtalim wrote:
I have JBoss 3.2.5, Hibernate 2.1 and mySQL 4.0.18. Does that mean I have to wait that long to integrate Hibernate with JBoss? If not, any easy solution for a newbie?


You can use it with just about any version of JBoss. Just create a JBoss .sar file and deploy it. Below is an example jboss-service.xml that I've used with version 3.2.3 and 3.2.6. Search the Hibernate forums for more info, and also see http://www.hibernate.org/66.html for some detailed instructions.

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=Ora9DS</depends>
<attribute name="MapResources">
<snip> put your hibernate mapping (.hbm.xml) files here
</attribute>
<attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
<attribute name="Datasource">java:/Ora9DS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="JdbcBatchSize">0</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute>
<attribute name="CacheProvider">net.sf.hibernate.cache.TreeCacheProvider</attribute>
</mbean>
</server>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 7:16 pm 
Regular
Regular

Joined: Thu Aug 26, 2004 9:23 pm
Posts: 71
Would it be possible to add MinimalPutsEnabled as an attribute of org.jboss.hibernate.jmx.Hibernate?

Mike


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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.