Jboss hibernate service

i have two different ears being deployed in the Jboss. I am trying to start a hibernate service in both of them. If iam doing so , the jboss throws a exception that trying to start the service that has been initialised already.

I am have respective persitance.sar built in the ears which has a Jboss_service.xml and jboss_app.xml has been configured to start the service.

I guess, the service name mentioned in the mbean tag(in jboss-service.xml) has the same name in both the applications. As a result, while deploying the Hibernate service in the second application, it is throwing an error. Please post the jboss-service.xml(or may be something like *-service.xml) present in your hibernate service package(I dont remember the syntax of the mbean tag, so will be able to help you out only after having a look at the file). [ March 29, 2006: Message edited by: jaikiran pai ]

Hi there, I am also facing the same problem. Following are the things tried by me: 1) Having the same sessionFactory name in both the hibernate-service.xml files but it does not work. 2) Setting the ScanForMappingsEnabled attribute to true. When i do this, i get the exception that trying to start the service that has been initialised already.

Can anybody throw some light as to am i missing something or is it a bug with hibernate ....?

Well the scenario is like this, I have two ear files. Say myApp1.ear and myApp2.ear I have class A in myApp1.ear I have class B in myApp2.ear (Actually has a war file also as this part is a web application)

Now, my application demands that i need to have a join (many-to-many relationship) between class A and class B.

When i tried the suggestions you had given having different session factory names, it becomes a class loader issue as I am accessing the class A present in myApp1.ear from the web app.

I hope This makes sense. Can anybody suggest any solutions for this....?

If your application demands this, then why are the two classes not in the same EAR?

I know that it makes life easier having the two classes in the same EAR. The Web application is a new feature and just requires only one class from the other EAR file. It doesn't make sense to have all the classes that are not required for the web app be loaded along with this one class. If i had just this one class on the web app side, I will be duplicating the data leading to many issues as the data I am handling is critical and deals with recording ingests for a show.

It doesn't make sense to have all the classes that are not required for the web app be loaded along with this one class

Absolutely. But if you are joining between ClassA, which is one EAR, and ClassB then ClassB is required for the Web App (unless that is you start adding things to the app server's classpath, but that's a bad idea).

madhuri madhuri
Ranch Hand

Joined: Jan 18, 2006
Posts: 58

posted Apr 04, 2006 10:29:00

0

Originally posted by Paul Sturrock:

Absolutely. But if you are joining between ClassA, which is one EAR, and ClassB then ClassB is required for the Web App (unless that is you start adding things to the app server's classpath, but that's a bad idea).

After a lot of thinking i came up with this solution. I am writing a work around for this by having an EJB in EAR1 to access ClassA from the Web App. But its very ugly and also hurts the performance. Was wondering if anybody had faced this problem earlier? Is it possible with Hibernate or is it a bug ....?

No. And its definately not a bug, you are just trying to use Hibernate in a way it is not supposed to work.

Suppose you have one SessionFactory which is used by two applications. You can use a Hibernate service in JBoss to bind this SessionFactory in to JNDI and make it available to both applications. However, as is the case with any JNDI bound resource the application itself will have to be able to load the classes that are bound in JNDI and for that you will need every class in your SessionFactory in the classpath of both applications. What we do is create our Hibernate DAO layer as a seperate deployable component (a Jar file) and deploy it to every application that uses it.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com