• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class visibility between EARs and a Persistence Module

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you will need to put JAR file in both EARs.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic