Ok, but isn't it then just the case that you have the eventadmin
classes on the outside as well as on the inside of the framework? That
would explain the classcast exception as you are trying to assign the
eventadmin service from the inside of the framework to your variable
on the outside.

I guess you need to make sure you are delegating the eventadmin
package down to the bundles inside the framework (you can do that by
adding them to the system package exports). The framework can't
protect you in this case (by returning null for the service) as it
doesn't know what classes you have available on the outside of the
framework.

regards,

Karl

On Wed, Feb 2, 2011 at 5:16 PM, Jackson, Bruce <bru...@qualcomm.com> 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" <karlpa...@gmail.com> 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 <bru...@qualcomm.com>
>>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
>>karlpa...@gmail.com
>
>



-- 
Karl Pauls
karlpa...@gmail.com

Reply via email to