Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to share objects between different classloaders?

I need different classloaders to be able to unload classes. But i need to share objects between them (actually i am getting ClassCastException). So what are the solutions to deal with this?. Thanks

like image 549
Wyvern666 Avatar asked Oct 01 '11 03:10

Wyvern666


2 Answers

Objects from different classloaders can interact with each other through interfaces and classes loaded by a common classloader.

like image 68
Andy Thomas Avatar answered Oct 13 '22 23:10

Andy Thomas


One of the primary objectives of using separate classloaders is to prevent exactly the kind of thing that you are trying to do. Security and name conflicts are good reasons for keeping this isolation. Here are a few ways that you can circumvent this isolation.

  1. Using the Common Class Loader

  2. Sharing Libraries Across a Cluster

  3. Packaging the Client JAR for One Application in Another Application

Refer to this link for more details.

like image 40
RHT Avatar answered Oct 14 '22 00:10

RHT