felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sahoo <sa...@sun.com>
Subject Re: brain teaser - embedded felix / class cast exception
Date Tue, 08 Jul 2008 16:25:59 GMT
That basically means the same named class has been defined by two 
different class loaders. Can you check if the bundle that's exporting 
the service and the bundle that's consuming the service are not wired to 
the same org.craig.cache package?

Which bundle is exporting the above package?
How are the service producer and consumer bundles specifying their 
package dependency for the above bundle?

Thanks,
Sahoo

Craig Phillips wrote:
> Hi,
>
> Can't cast a class to it's own type... Huh?  I just got to believe it's
> some kind of class loader thing going on... I really could use a pair of
> eyes from one of the class loader experts out there, I anticipate (I
> brought other eyes nearby to look, they're stumped too)...  Thanks,
> Craig Phillips
>
> Here's the stack error message:
>
> java.lang.ClassCastException: org.craig.cache.CacheServiceMain cannot be
> cast to org.craig.cache.CacheServiceMain
>
> Here's the line of code:
>
> CacheServiceMain cacheServiceMain = (CacheServiceMain) bc.getService(sr)
>
> Here's the context snippet, that creates the felix container, more or
> less:
>
> System.getProperties().setProperty(Main.CONFIG_PROPERTIES_PROP,
>  
> "file:../webapps/craigbox/WEB-INF/felix_config.properties");
> Main.loadSystemProperties();
> Properties configProps = Main.loadConfigProperties();
> List<AutoActivator> list = new ArrayList<AutoActivator>(); // pass
> through
> list.add(new AutoActivator(configProps)); // pass through
> Map map = new StringMap(configProps, false); // pass through
> felix = new Felix(map, list); // there isn't a default constructor
> felix.start();
> BundleContext bc = felix.getBundleContext();
> ServiceReference sr =
> bc.getServiceReference("org.craig.cache.api.CacheServiceMainApi");
> if (sr != null)
> {
>    CacheServiceMain cacheServiceMain =  (CacheServiceMain)
> bc.getService(sr);
>    ... // and the rest, which of course doesn't come in to play
>
>
> PS - To Karl -- As you can tell, I have not done the "set TCL to null",
> but this is in the "parent" code... Note that I do have all the classes
> in the parent dot.jar file, if that's any consolation...
>
>
>   

Mime
View raw message