This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Java Products and Servers and the fly likes Glassfish2: how can I make server use single class loader for several applications 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 » Products » Other Java Products and Servers
Bookmark "Glassfish2: how can I make server use single class loader for several applications " Watch "Glassfish2: how can I make server use single class loader for several applications " New topic
Author

Glassfish2: how can I make server use single class loader for several applications

Boris Romashov
Ranch Hand

Joined: Feb 23, 2009
Posts: 38
I have several web/ejb applications. These applications use some common libraries and should share instances of classes from those libraries.
But applications are being deployed independently thus packaging all them to EAR is not acceptable.
I suppose the problem is that each application uses separate class loader.
How can I make AS use single class loader for a set of applications?

Different applications depend on different libraries so I need a way that will not share library for all applications on the domain but only for some exact applications.

When I placed common jar to %domain%/lib - all works. But that jar is shared between all applications on the domain.
When I tried to place common jar to %domain%/lib/applibs and specified --libraries attribute on deploying I got exception
java.lang.ClassCastException: a.FirstDao cannot be cast to a.FirstDao

Here http://download.oracle.com/docs/cd/E19879-01/820-4336/6nfqd2b1t/index.html I read:
If multiple applications or modules refer to the same libraries, classes in those libraries are automatically shared.
This can reduce the memory footprint and allow sharing of static information.

Does it mean that classes should be able to be casted ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Glassfish2: how can I make server use single class loader for several applications
 
Similar Threads
compilation error in JSP
Internet/Intranet apps using the same code
Order in which class is searched
JBoss class loading and reading .properties files
new to tomcat