>> i cannot cast a class that loaded from felix to a class that loaded from 
>> default class loader, even two classes are the same.

Actually, the classes are not the same. This is weird, but Java defines the 
identity of a class as the combination of the fully qualified classname + the 
classloader through which the class is loaded. So classes from different 
classloaders are always treated as different.

Either move the stuff that needs the class to a bundle that imports the class 
(probably very difficult) or do what Marcel suggested and make a common 
interface that is then exported as a framework package.

-Stijn


-----Original Message-----
From: Marcel Offermans [mailto:[email protected]] 
Sent: zondag 13 oktober 2013 23:56
To: [email protected]
Subject: Re: questions about felix

On Oct 13, 2013, at 22:54 PM, Peter Cheung <[email protected]> wrote:

> Dear All   I have a standalone java app that embedded felix. I can start it, 
> load bundle and call the method from bundle (using reflection). 1) My first 
> question is, using reflection is not efficiency.  I imported the class from 
> bundle to my host app, it popup "ClassCastException", because i cannot cast a 
> class that loaded from felix to a class that loaded from default class 
> loader, even two classes are the same. Any workaround?2) I am using maven, 
> how to i add bundle dependency to pom.xml?  pom.xml seems not searching the 
> felix bundle repository. 

You cannot "see" classes that are loaded as part of bundles from your app. It 
does not help to duplicate them either. The best option is to create an 
interface, add that to your application, expose it as an exported package 
through the system bundle, and have the class in the bunde import and implement 
this interface. That way the interface is shared between the app and any bundle 
that imports it.

Hope that helps.

Greetings, Marcel


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to