File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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 ?
 
Consider Paul's rocket mass heater.
 
subject: Glassfish2: how can I make server use single class loader for several applications