*
The moose likes EJB and other Java EE Technologies and the fly likes Sharing Objects between Webapps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Sharing Objects between Webapps" Watch "Sharing Objects between Webapps" New topic
Author

Sharing Objects between Webapps

Stephen Callaghan
Greenhorn

Joined: Feb 26, 2002
Posts: 12
I'm trying to allow one webapp in its own Context to reference an objects instance in another webapp (within the same tomcat container).
I've tried singleton pattern (since i thought it was the same VM it would be shared) and I've tried binding it to JNDI but no luck. The second webapp can never see the first live instance (i tried crossContext="true" in both Context tags too but no luck).
Do i have to go down the RMI or EJB route to achieve what I want? Its not that big a project and i'm not sure if i could sell the investment in time setting that up to the company.
Any help or pointers much appreciated.
btw, its an Admin Type webapp that is trying to see into the other webapps to display current status information for some specific information and allow operations like start/stop on a couple of objects.


==========================<br />Stephen Callaghan<br />SC Java Programmer<br />SC Java Developer<br />SC Web Component Developer<br />SC Enterprise Architect I
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
W'd it work if the singleton is packaged in a jar and kept inside the shared common\lib folder of tomcat? I mean all the webapps s'd be able to see the single instance of this class.
If we have one classloader/webapp guess the singleton class will get loaded as many times even though it lies in the same JVM.
Stephen Callaghan
Greenhorn

Joined: Feb 26, 2002
Posts: 12
Of course!!!
Couldnt understand why the singleton wouldnt work but it is indeed the classloaders. Have put common code under "common/lib" and removed from individual web apps and it works perfectly. I guess thats why they call it "common"!!
Thanks so much for your help in this.
Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sharing Objects between Webapps
 
Similar Threads
Tomcat virtual hosting, does each host need it's own subdirectory off webapps?
Need help with multiple contexts for a webapp
Problem with referencing session information from 2 contexts, one a subfolder of another
Cross Context sharing of Objects
mapping a URL to a java class