-->
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: Hibernate as a service under JBoss 3.2.2
PostPosted: Mon Dec 22, 2003 4:08 pm 
Newbie

Joined: Mon Dec 22, 2003 12:39 pm
Posts: 5
Location: Lexington, MA USA
We have (are trying to) use Hibernate 2.1 final in conjunction with the JBoss 3.2.2 container. The container is configured to operate as part of a high-availability cluster, uses MySQL as the under-lying defaultDS and persistence container. MySQL is installed as a service and is the defaultDS provider.

We have installed Hibernate 2.1 final as a service with the following MBEAN:
<?xml version="1.0" encoding="UTF-8"?>

<!--
|==============================================================================
| Hibernate Service Configuration
|==============================================================================
-->

<server>
<mbean
code="net.sf.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,name=HibernateFactory">

<depends>
jboss.jca:service=RARDeployer
</depends>

<!-- Make it deploy ONLY after DataSource had been started -->
<depends>
jboss.jca:service=LocalTxCM,name=DefaultDS
</depends>

<!-- Hold off on map sources... not ready yet.
<attribute name="MapResources">
hibernate_mappings/radar_msg_250.hbm.xml,
hibernate_mappings/radar_msg_210.hbm.xml
</attribute>
-->

<attribute name="JndiName">
java:/hibernate/HibernateFactory
</attribute>

<attribute name="Datasource">
java:/DefaultDS
</attribute>

<attribute name="Dialect">
net.sf.hibernate.dialect.MySQLDialect
</attribute>

<attribute name="TransactionStrategy">
net.sf.hibernate.transaction.JTATransactionFactory
</attribute>

<attribute name="TransactionManagerLookupStrategy">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</attribute>

<attribute name="UseOuterJoin">
false
</attribute>

<attribute name="ShowSql">
false
</attribute>

<attribute name="UserTransactionName">
java:/UserTransaction
</attribute>

</mbean>
</server>

This configuration seems to work to a point but there is an unresolved item in the LOG4J output. I am trying to resolve the issue but don't understand the messages I see. The snippet from the log is as follows:
<snip>...
12:04:09,171 INFO [FarmMemberService] Creating
12:04:09,171 INFO [FarmMemberService] Created
12:04:09,171 INFO [AbstractDeploymentScanner$ScannerThread] Running
12:04:09,171 INFO [CachedConnectionManager] Starting
12:04:09,203 INFO [CachedConnectionManager] Started
12:04:09,203 INFO [TxConnectionManager] Starting
12:04:09,234 INFO [JaasSecurityManagerService] Created securityMgr=org.jboss.security.plugins.JaasSecurityManager@205df9
12:04:09,234 INFO [JaasSecurityManagerService] setCachePolicy, c=org.jboss.util.TimedCachePolicy@1a2264c
12:04:09,234 INFO [JaasSecurityManagerService] Added JmsXARealm, org.jboss.security.plugins.SecurityDomainContext@804a77 to map
12:04:09,250 INFO [JmsXA] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=TxCM,name=JmsXA to JNDI name 'java:/JmsXA'
12:04:09,250 INFO [TxConnectionManager] Started
12:04:09,250 INFO [TxConnectionManager] Starting
12:04:09,265 INFO [DefaultDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=DefaultDS to JNDI name 'java:/DefaultDS'
12:04:09,265 INFO [TxConnectionManager] Started
12:04:09,265 INFO [HibernateServiceMBean] starting service at JNDI name: java:/hibernate/HibernateFactory
12:04:09,265 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=java:/hibernate/HibernateFactory, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=false, hibernate.use_outer_join=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory, hibernate.connection.datasource=java:/DefaultDS, jta.UserTransaction=java:/UserTransaction}
12:04:09,296 INFO [Environment] Hibernate 2.1 final
12:04:09,312 INFO [Environment] hibernate.properties not found
12:04:09,312 INFO [Environment] using CGLIB reflection optimizer
12:04:09,312 INFO [Configuration] processing one-to-many association mappings
12:04:09,328 INFO [Configuration] processing one-to-one association property references
12:04:09,328 INFO [Configuration] processing foreign key constraints
12:04:09,375 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
12:04:09,375 INFO [SettingsFactory] Use outer join fetching: false
12:04:09,375 INFO [NamingHelper] JNDI InitialContext properties:{}
12:04:09,390 INFO [DatasourceConnectionProvider] Using datasource: java:/DefaultDS
12:04:09,390 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
12:04:09,390 INFO [NamingHelper] JNDI InitialContext properties:{}
12:04:09,406 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
12:04:09,406 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
12:04:09,406 INFO [NamingHelper] JNDI InitialContext properties:{}
12:04:09,406 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
12:04:09,406 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
12:04:09,796 INFO [SettingsFactory] Use scrollable result sets: true
12:04:09,796 INFO [SettingsFactory] JDBC 2 max batch size: 15
12:04:09,796 INFO [SettingsFactory] Query language substitutions: {}
12:04:09,796 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
12:04:09,796 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
12:04:09,859 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/HibernateFactory
12:04:09,859 INFO [NamingHelper] JNDI InitialContext properties:{}
12:04:09,859 INFO [NamingHelper] Creating subcontext: hibernate
12:04:09,859 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/HibernateFactory
12:04:09,859 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
12:04:09,859 INFO [PersistenceManager] Starting
12:04:09,937 INFO [PersistenceManager] Started
12:04:09,937 INFO [DestinationManager] Starting
12:04:09,953 INFO [DestinationManager] Started
12:04:09,953 INFO [A] Starting
12:04:09,984 INFO [A] Bound to JNDI name: queue/A
12:04:09,984 INFO [A] Started
12:04:09,984 INFO [B] Starting
12:04:09,984 INFO [B] Bound to JNDI name: queue/B
12:04:09,984 INFO [B] Started
12:04:09,984 INFO [C] Starting
12:04:09,984 INFO [C] Bound to JNDI name: queue/C
12:04:09,984 INFO [C] Started
12:04:09,984 INFO [D] Starting
12:04:10,000 INFO [D] Bound to JNDI name: queue/D
12:04:10,000 INFO [D] Started
12:04:10,000 INFO [ex] Starting
12:04:10,000 INFO [ex] Bound to JNDI name: queue/ex
12:04:10,000 INFO [ex] Started
12:04:10,000 INFO [SecurityManager] Starting
12:04:10,015 INFO [JaasSecurityManagerService] Created securityMgr=org.jboss.security.plugins.JaasSecurityManager@a42c89
12:04:10,031 INFO [JaasSecurityManagerService] setCachePolicy, c=org.jboss.util.TimedCachePolicy@67e92a
12:04:10,031 INFO [JaasSecurityManagerService] Added jbossmq, org.jboss.security.plugins.SecurityDomainContext@1fccfe3 to map
12:04:10,031 INFO [SecurityManager] Started
...<snip>

My questions/issues are as follows:
A) At first, ehcache was unresolved, so I added the ehcache jar to the application classpath (.../lib/ehcache.jar). This seemed to resolve the issue of not finding the ehcache object, but led to the next issue(s). Since JBoss has built-in Cache, Coherency, and Transaction managers, why do I need ehcache? Why aren't the default JBoss services bound here instead?

B) From the log above:
....
12:04:09,296 INFO [Environment] Hibernate 2.1 final
...
12:04:09,375 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
...
12:04:09,796 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
12:04:09,796 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
12:04:09,859 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/HibernateFactory
12:04:09,859 INFO [NamingHelper] JNDI InitialContext properties:{}
12:04:09,859 INFO [NamingHelper] Creating subcontext: hibernate
12:04:09,859 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/HibernateFactory
12:04:09,859 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
...

Why does The HibernateServiceMBean say it could not build the session factory object? It says it couldn't instantiate the CacheProvider, didn't this happen in the prior step, when the SettingsFactory supposedly linked the cacheFactory service?

There seems to be some unresolved issue around the session "[HibernateServiceMBean] Could not build SessionFactory using the MBean classpath ". Why doesn't Hibernate link up with the default Session services within JBoss? What about the JBoss JTA service that the service MBEAN tried to link in. What became of that? Shouldn't the SessionFactoryObject be bound to an equivalent JTA service?

I am a bit puzzled since these appeared to be working (in some form) under Jboss using either of the last 2 Hibernate candidate builds. Just dropping in 2.1 final with assoicated jars broke things.

Any information you can share would be appreciated.

Thank you.

_________________
Normand Martel
Software Engineer
MIT Lincoln Labratory
Lexington, MA USA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 5:11 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
The following link has been updated to cover Hibernate 2.1 and JBoss http://www.hibernate.org/66.html, and addresses some of your issues.

From this documentation:

In the Mbean jboss-serice.xml:

Quote:
UserTransactionName, TransactionStrategy and TransactionManagerLookupStrategy appear to be required under JBoss if you are using Hibernate transactions.


ie.

Code:
       <attribute name="UserTransactionName">UserTransaction</attribute>
       <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>


The UserTransactionName needs to be "UserTransaction".


The default caching mechanism in Hibernate 2.1 is ehcache. You can change it via the CacheProvider attribute in the jboss-service.xml. I have not tried using the TreeCache in JBoss, but you would use:

Code:
<attribute name="CacheProvider">net.sf.hibernate.cache.TreeCacheProvider</attribute>


Check out http://www.hibernate.org/hib_docs/reference/html/performance.html#performance-s3


Cheers,


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 5:26 pm 
Newbie

Joined: Mon Dec 22, 2003 12:39 pm
Posts: 5
Location: Lexington, MA USA
Hi Sherman,

Thanks for the reply.

The UserTransaction resovles okay with the JNDI name Java:/UserTransaction (it's in the tree this way).

The key, as you stated in your message, was changing the cache over to the TreeCache. I took a SWAG at this while you were posting. I added the TreeCacheProvider element as you suggested in your post. I also added the JBOSS_xxxx.jar files to my deployment lib to resolve the class-path-based loading.

This at least gets the services up and running.

Now, something new is up...see the last message of this log.

15:52:11,921 INFO [DefaultDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=DefaultDS to JNDI name 'java:/DefaultDS'
15:52:11,937 INFO [TxConnectionManager] Started
15:52:11,937 INFO [HibernateServiceMBean] starting service at JNDI name: java:/hibernate/HibernateFactory
15:52:11,937 INFO [HibernateServiceMBean] service properties: {hibernate.cache.provider_class=net.sf.hibernate.cache.TreeCacheProvider, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.use_outer_join=false, hibernate.session_factory_name=java:/hibernate/HibernateFactory, hibernate.connection.datasource=java:/DefaultDS, jta.UserTransaction=java:/UserTransaction, hibernate.show_sql=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory}
15:52:11,968 INFO [Environment] Hibernate 2.1 final
15:52:11,968 INFO [Environment] hibernate.properties not found
15:52:11,984 INFO [Environment] using CGLIB reflection optimizer
15:52:11,984 INFO [Configuration] processing one-to-many association mappings
15:52:11,984 INFO [Configuration] processing one-to-one association property references
15:52:11,984 INFO [Configuration] processing foreign key constraints
15:52:12,031 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
15:52:12,031 INFO [SettingsFactory] Use outer join fetching: false
15:52:12,046 INFO [NamingHelper] JNDI InitialContext properties:{}
15:52:12,062 INFO [DatasourceConnectionProvider] Using datasource: java:/DefaultDS
15:52:12,062 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
15:52:12,062 INFO [NamingHelper] JNDI InitialContext properties:{}
15:52:12,062 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
15:52:12,078 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
15:52:12,078 INFO [NamingHelper] JNDI InitialContext properties:{}
15:52:12,078 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
15:52:12,078 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
15:52:12,484 INFO [SettingsFactory] Use scrollable result sets: true
15:52:12,484 INFO [SettingsFactory] JDBC 2 max batch size: 15
15:52:12,484 INFO [SettingsFactory] Query language substitutions: {}
15:52:12,484 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.TreeCacheProvider
15:52:12,500 INFO [Configuration] instantiating and configuring caches
15:52:12,687 INFO [SessionFactoryImpl] building session factory
15:52:12,750 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/HibernateFactory
15:52:12,750 INFO [NamingHelper] JNDI InitialContext properties:{}
15:52:12,750 INFO [NamingHelper] Creating subcontext: hibernate
15:52:12,750 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/HibernateFactory
15:52:12,750 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext

What is the WARN, Initial context did no implement EventContext?
What is an event context?

_________________
Normand Martel
Software Engineer
MIT Lincoln Labratory
Lexington, MA USA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 5:32 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Quote:
What is the WARN, Initial context did no implement EventContext?


I have not looked into this, but there is no problem seeing that message - everything works fine.


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 5:41 pm 
Newbie

Joined: Mon Dec 22, 2003 12:39 pm
Posts: 5
Location: Lexington, MA USA
Hi Sherman,

This is almost real-time posting, yikes!

I agree with your statement that the system functions. I am running a prototype system and all messages/beans and the like seem to be working properly.

I am inclined to think that there is no issue with the WARN message, but hoped the developer (maybe yourself?) would answer with a definitive response.

Lastly, I posted (on a separate thread), is there a way to tie the Cache Invalidation Bridge (JGCacheInvalidationBridge) in JBoss into this second-level cache?

This would be a great thing to do as the Cache Invalidation Bridge currently tracks the first-level container cache. It would be great to extend the notion of invalidating all cache tiers when an entity was modified (or marked dirty/invalid by the timer process).

Thanks

_________________
Normand Martel
Software Engineer
MIT Lincoln Labratory
Lexington, MA USA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 5:57 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Sorry, I ain't the developer, just a lowly documenter of the path I went through to get the JBoss/Hibernate set up running nicely.

From the code comments on the TreeCache area, this is Gavin's baby.


Sherman


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.