-->
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: JBoss HAR Deployer
PostPosted: Wed Sep 05, 2007 10:03 am 
Newbie

Joined: Sun Jan 14, 2007 2:52 pm
Posts: 19
Hibernate version: 3.2.5ga

Name and version of the database you are using:
MySQL 5.0.42

I currently have a Hibernate based application which has a Session factory managed by Spring. As this is duplicated across many projects on the application server we have seperated out annotated domain and dao classes into a seperate Maven artifact. We would like to share a single deployment and SessionFactory across all applications running on the server. From the Java Persistence with Hibernate book the ideal solution seems to be to simply share the session factory using JNDI. Our Spring configuration can easily be updated to obtain the SessionFactory from JNDI.

My problem is what is currently the best practice of getting the SessionFactory into JNDI and sharing the deployment? The Hibernate and JBoss wiki both make references to the HAR deployer. However this seems to have been discountinued in the more recent versions of JBoss AS. We are using the Enerprise Application Platform 4.2. HAR deployments are only mentioned in one line of the manual and no alternative is offered. The old tutorials also only mention HBM mapping files being auto detected and not annotated classes.

What is the best way to acheive this? Any tips, code, links very much appreciated.

Thank you,
Martin.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 10:21 am 
Newbie

Joined: Mon Dec 03, 2007 9:53 am
Posts: 12
Bump.

I'm looking into this as well. However, I'm using JBoss AS 4.0.2 and the included deployer is very outdated and uses Hibernate 3.0.x. I'm wondering if it is worth the trouble updating this deployer with Hibernate 3.2.5, as it impacts the entire server.

When looking at the CaveatEmpor example, which I understand is some kind of blue print, the HAR approach is not used.

Which approach did you end up using?

/Anders


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 11, 2007 10:24 am 
Newbie

Joined: Mon Dec 03, 2007 9:53 am
Posts: 12
OK, after hours of reading, this is what I have found out:

* The HARDeployer is removed in favor of the SARDeployer (in later JBoss AS that is, not sure exactly in what version this happened though).
* The SARDeployer then accepts .har archives as well (earlier on, the HARDeployer handled these). In .har files, mapping files are automatically discovered (possibly you need to turn on some configuration for this to happen).
* Using a .har file will utilize the Hibernate jmx bean included in JBoss AS (org.jboss.hibernate.jmx.Hibernate), which differs slightly from the on included in Hibernate itself (se next bullet).
* In the Hibernate distro (I've used 3.2.5), there is a jmx bean (org.hibernate.jmx.HibernateService) that makes it possible to initialize a Hibernate SessionFactory through a (jmx) service. Create a .sar file, define this in the jboss-service.xml, and include the necessary hibernate jars, pojos, mappings. Mapping files are NOT automatically discovered though.
* You could also initialize Hibernate and create the SessionFactory within your code, in the way it's done in the CaveatEmptor.

Regardless which way you go, the SessionFactory is/can be bound to jndi for you to look up when needed.

As I'm using JBoss AS 4.0.2 I've decided to build a .sar file and not use a deployer (I've removed the old included jboss-hibernate.deployer), as I guess it would require quite a bit of work to upgrade it. I decided it would be a nicer solution to have the SessionFactory initialized as a service instead of by static code blocks or some other home-grown solution.


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.