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...


Reply via email to