aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Class visibility between EARs and a Persistence Module Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Class visibility between EARs and a Persistence Module" Watch "Class visibility between EARs and a Persistence Module" New topic
Author

Class visibility between EARs and a Persistence Module

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
I have two EARs and a Persistence Module. What kind of archive (JAR or EAR etc.) shall I use for the Persistence Module so that an Entity in the Persistence Module is visible to both EARs?

SCJP, SCJD, SCWCD, SCBCD
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
JBoss allow one to put the persistence module in a JAR file. That JAR then file must be deployed with the EARs. But what do the JavaEE specs say about it?
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
I think you will need to put JAR file in both EARs.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Maris Orbidans wrote:I think you will need to put JAR file in both EARs.


This would be an option but wouldn't that lead to an JNDI exception "JNDI name already exists" or the like?
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
Darya Akbari wrote:
Maris Orbidans wrote:I think you will need to put JAR file in both EARs.


This would be an option but wouldn't that lead to an JNDI exception "JNDI name already exists" or the like?


AFAIK persistence module doesn't publish anything in JNDI.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Maris Orbidans wrote:AFAIK persistence module doesn't publish anything in JNDI.


That would be great, I will try it out with some application servers.

One last question concerning class visibility is, what will happen when one EAR method use another EAR's method both referencing the same entity? Wouldn't that lead to a class loader exception? How can one handle such requirements of reuse between EARs?
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
Darya Akbari wrote:Wouldn't that lead to a class loader exception?


It depends whether your app server creates a classloader for each EAR. But if you have identical classes (with the same name) in both EARs then you shouldn't have any problems even if you got common classloader for all EARs.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Maris Orbidans wrote:It depends whether your app server creates a classloader for each EAR.


From the JavaEE spec view I think that this is how each app server should work.

Maris Orbidans wrote:But if you have identical classes (with the same name) in both EARs then you shouldn't have any problems even if you got common classloader for all EARs.


I think that should lead to a class loader exception, or what do you mean by common class loader?
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Darya Akbari wrote:
One last question concerning class visibility is, what will happen when one EAR method use another EAR's method both referencing the same entity? Wouldn't that lead to a class loader exception? How can one handle such requirements of reuse between EARs?


I'm still looking for the right thing here
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
Maris Orbidans wrote:
From the JavaEE spec view I think that this is how each app server should work.


It is not specified in J2EE. I am not sure about JEE.

Maris Orbidans wrote:But if you have identical classes (with the same name) in both EARs then you shouldn't have any problems even if you got common classloader for all EARs.

I think that should lead to a class loader exception, or what do you mean by common class loader?



If you have one classloader for all EAR files then you will get class version whichever happens to be first on classpath. If not it should not cause classloader exceptions either.
Why dont you try and tell us how it works.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Maris Orbidans wrote:Why dont you try and tell us how it works.


Before I try anything it must make sense. And so far I've not the feeling that we have anything really worth to try out. The solution must held for all application servers. Other than that would make portability nonsense.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class visibility between EARs and a Persistence Module