This discussion is archived
1 Reply Latest reply: May 1, 2011 6:19 PM by handat RSS

How can I make server use single class loader for several applications

856875 Newbie
Currently Being Moderated
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 ?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points