Hi, This looks like a classic case of ClassCastException on a class/interface that was loaded using two different class loaders. The interface of EventAdmin that you are referencing was loaded using a different class loader than the class loader that was used by the framework.
Regards, Lucas On Wed, Feb 2, 2011 at 1:32 PM, Jackson, Bruce <[email protected]> wrote: > I've added the following code to see what I'm actually getting back from > the service lookup as below: > > Object o = context.getService(ref);; > Class c = o.getClass(); > > while(c != null) { > > System.err.println(">> ea service: " + c.getName()); > c = c.getSuperclass(); > > } > > > I get the following output: > > 02-02 16:27:43.049: WARN/System.err(12909): >> ea service: > org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator > 02-02 16:27:43.049: WARN/System.err(12909): >> ea service: java.lang.Object > > So, something odd is certainly happening here. > > > > On 02/02/2011 16:16, "Jackson, Bruce" <[email protected]> wrote: > >>Its from my code: all of the other lines of the stack trace are in my code >>and not the framework/event admin service. >> >> >> >>On 02/02/2011 16:11, "Karl Pauls" <[email protected]> wrote: >> >>>Is this exception happening inside felix/eventadmin code or inside >>>your code? Could you maybe provide the stacktrace of the exception? >>> >>>regards, >>> >>>Karl >>> >>>On Wed, Feb 2, 2011 at 5:04 PM, Jackson, Bruce <[email protected]> >>>wrote: >>>> Hi All >>>> >>>> I'm using an embedded instance of Felix, and trying to post a simple >>>>event to the EventAdmin service. My code is trivial: >>>> >>>> >>>> ServiceReference ref = >>>>context.getServiceReference(EventAdmin.class.getName()); >>>> >>>> if(ref != null) { >>>> >>>> EventAdmin ea = (EventAdmin) context.getService(ref); >>>> >>>> if(ea != null) { >>>> >>>> ea.postEvent(evt); >>>> >>>> } >>>> >>>> } >>>> >>>> The only unusual thing is that I'm calling this from "outside" the >>>>framework, so I get my BundleContext object by calling: >>>> >>>> BundleContext context = felix.getBundleContext(); >>>> >>>> When I run this, I get the following ClassCastException: >>>> >>>> 02-02 15:49:28.839: ERROR/SkiftaService(12471): >>>>java.lang.ClassCastException: >>>>org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator >>>> >>>> Now, if this was a ClassLoader issue, I'd expect the >>>>context.getServiceReference() to return null, but this isn't the case. >>>>Anyone got aany idea why I'm getting this? >>>> >>>> Thanks >>>> >>>> Bruce >>>> >>> >>> >>> >>>-- >>>Karl Pauls >>>[email protected] >> > >
