Try printing CoreFactoryImpl.class.getClassLoader() within your bundle using the service tracker and then print cso.getClass().getClassLoader() from the service object and see if they are coming from the same class loader.

One thing that seems weird to me, why are you casting to CoreFactoryImpl instead of CoreFactory?

-> richard

Brad Cox wrote:
For the life of me I can't see why this fails. Here's the runup in detail:

coreTracker is a ServiceTracker for CoreServiceImpl, defined in a bundle I'm trying to access from the integration test bundle. These are the relevant declarations:

public interface CoreFactory extends ServiceFactory
public class CoreFactoryImpl implements CoreFactory

Integration test uses a ServiceTracker (CoreTracker) to locate the sole core instance from the core bundle like this:

Object cso = coreTracker.getService();
System.out.println("cso:"+cso);
> cso:com.gestalt.soakit.core.internals.corefactoryi...@dead19

So why should this cast fails with a ClassCastException?
CoreFactoryImpl cs = (CoreFactoryImpl)cso;

I'm going blind from staring at this. Maybe someone can spot what I'm missing. Here's some more detail.

Class csoClass = cso.getClass();
System.out.println("csoClass:"+csoClass);
> csoClass:com.gestalt.soakit.core.internals.CoreFactoryImpl

Class[] csoClasses = csoClass.getClasses();
System.out.println("cso.getClasses():"+csoClass.getClasses());
> cso.getClasses():[Ljava.lang.Class;@1cc5ef

Class[] csoInterfaces = csoClass.getInterfaces();
System.out.println("cso.getInterfaces():"+csoClass.getInterfaces());
> cso.getInterfaces():[Ljava.lang.Class;@c44af4

Here's the full trace

> org.osgi.framework.BundleException: Activator start error in bundle soakit.test [24].
>     at org.apache.felix.framework.Felix._startBundle(Felix.java:1701)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:1578)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:382)
>     at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:363)
> at org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:82) > at org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:276) > at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:167)
>     at java.lang.Thread.run(Thread.java:613)
> Caused by: java.lang.ClassCastException: com.gestalt.soakit.core.internals.CoreFactoryImpl > at com.gestalt.soakit.test.internals.TestImpl.configure(TestImpl.java:49) > at com.gestalt.soakit.test.internals.TestFactoryImpl.createTest(TestFactoryImpl.java:35) > at com.gestalt.soakit.test.TestActivator.start(TestActivator.java:54) > at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:589)
>     at org.apache.felix.framework.Felix._startBundle(Felix.java:1654)
>     ... 7 more
> java.lang.ClassCastException: com.gestalt.soakit.core.internals.CoreFactoryImpl


------------------------------------------------------------------------

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