Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Boris Romashov
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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 ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!