You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Markus Michel <ne...@googlemail.com> on 2009/07/13 20:47:59 UTC

Using Felix EventAdmin Service?!?

Hi there!

Today I wanted to add the eventadmin service to my OSGi environment.
Therefore I extended the import block of my bundle, which is created within
an eclipse equinox project,  with org.osgi.service.event. After loading the
service I tried to access it by running the following command:

        // get service reference to event admin service
        serviceReference =
bundleContext.getServiceReference(EventAdmin.class.getName());

        // check if service reference is valid
        if (serviceReference != null)
        {
            eventAdmin = (EventAdmin)
bundleContext.getService(serviceReference);
        }

But inside the if-loop I'm getting an error:

java.lang.ClassCastException:
org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator cannot
be cast to org.osgi.service.event.EventAdmin

I'm a little bit confused now, because I thought that the Apache Felix
framework is fully compatible to the OSGi specifications?!? Isn't it
possible to mix equinox components (my bundle) with felix components (the
eventadmin service)?

Does anybody has an idea how I can solve my problem?

BR,

Markus

Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 7/14/09 8:34 AM, Edelson, Justin wrote:
> I think you're missing the compendium bundle.

The compendium bundle shouldn't be necessary since the Event Admin impl 
exports the event admin packages.

-> richard
>
> Justin
>
> On Jul 14, 2009, at 4:34 AM, "Markus Michel" 
> <ma...@uni-duesseldorf.de> wrote:
>
>> BTW:
>>
>> Beside the felix framework itself I'm currently only loading those three
>> bundles:
>>
>> org.apache.felix.shell-1.2.0.jar
>> org.apache.felix.shell.tui-1.2.0.jar
>> org.apache.felix.eventadmin-1.0.0.jar
>>
>> Do I have to add some of the OSGi API bundles as well?
>>
>> BR,
>>
>> Markus
>>
>> 2009/7/14 Markus Michel <ma...@uni-duesseldorf.de>
>>
>>> Hi Richard!
>>>
>>> Of course I can provide more informations. The manifest file of the 
>>> bundle
>>> looks like this:
>>>
>>> Manifest-Version: 1.0
>>> Bundle-ManifestVersion: 2
>>> Bundle-Name: VehiclePushService
>>> Bundle-SymbolicName: VehiclePushService
>>> Bundle-Version: 1.0.0
>>> Bundle-Activator: vehiclePushService.Activator
>>> Import-Package: org.osgi.framework;version="1.3.0",
>>> org.osgi.service.event;version="1.1.0",
>>> vehiclePushService
>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>> Bundle-ClassPath: .,
>>> vehiclePushService.jar
>>> Export-Package:
>>> osgiServices.vehiclePushService,
>>> vehiclePushService
>>>
>>> The content of the bundle looks as follows:
>>>
>>> META-INF/
>>> META-INF/MANIFEST.MF
>>> hostApplication/
>>> hostApplication/vehiclePushService/
>>> osgiFramework/
>>> osgiFramework/vehiclePushService/
>>> vehiclePushService/
>>> META-INF/.classpath
>>> META-INF/.project
>>> vehiclePushService.jar
>>> vehiclePushService/Activator.class
>>> vehiclePushService/OSGiPosition2D.class
>>> vehiclePushService/OSGiVehicle.class
>>> vehiclePushService/OSGiVehiclePushService.class
>>> vehiclePushService/VehicleListener.class
>>> vehiclePushService/VehiclePushEvent.class
>>> vehiclePushService/VehiclePushServiceHandler.class
>>>
>>> Because inside the plug-in dependencies org.eclipse.services is 
>>> referenced
>>> I think that the bundles currently uses the equinox implementation 
>>> of the
>>> eventadmin service. Later on I will try to load the equinox eventadmin
>>> service instead
>>> of the felix eventadmin service. Maybe it's then possible to start my
>>> bundle ...
>>>
>>> BR,
>>>
>>> Markus
>>>
>>>
>>> 2009/7/13 Richard S. Hall <he...@ungoverned.org>
>>>
>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>
>>>>> Hi there!
>>>>>
>>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>>> Therefore I extended the import block of my bundle, which is created
>>>>> within
>>>>> an eclipse equinox project,  with org.osgi.service.event. After 
>>>>> loading
>>>>> the
>>>>> service I tried to access it by running the following command:
>>>>>
>>>>>        // get service reference to event admin service
>>>>>        serviceReference =
>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>
>>>>>        // check if service reference is valid
>>>>>        if (serviceReference != null)
>>>>>        {
>>>>>            eventAdmin = (EventAdmin)
>>>>> bundleContext.getService(serviceReference);
>>>>>        }
>>>>>
>>>>> But inside the if-loop I'm getting an error:
>>>>>
>>>>> java.lang.ClassCastException:
>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>
>
>>>>> cannot
>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>
>>>>> I'm a little bit confused now, because I thought that the Apache 
>>>>> Felix
>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>
>>>>
>>>> While the Felix framework isn't yet 100% compliant, it is very 
>>>> close and
>>>> getting closer every release.
>>>>
>>>> Isn't it
>>>>> possible to mix equinox components (my bundle) with felix 
>>>>> components (the
>>>>> eventadmin service)?
>>>>>
>>>>> Does anybody has an idea how I can solve my problem?
>>>>>
>>>>>
>>>>
>>>> Such a scenario should work, but you didn't provide enough 
>>>> information to
>>>> say why it isn't. Perhaps you could show us your bundle's manifest 
>>>> file as
>>>> well as a "jar tf" of the bundle.
>>>>
>>>> -> richard
>>>>
>>>> BR,
>>>>>
>>>>> Markus
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by "Edelson, Justin" <Ju...@mtvstaff.com>.
I think you're missing the compendium bundle.

Justin

On Jul 14, 2009, at 4:34 AM, "Markus Michel" <markus.michel@uni-duesseldorf.de 
 > wrote:

> BTW:
>
> Beside the felix framework itself I'm currently only loading those  
> three
> bundles:
>
> org.apache.felix.shell-1.2.0.jar
> org.apache.felix.shell.tui-1.2.0.jar
> org.apache.felix.eventadmin-1.0.0.jar
>
> Do I have to add some of the OSGi API bundles as well?
>
> BR,
>
> Markus
>
> 2009/7/14 Markus Michel <ma...@uni-duesseldorf.de>
>
>> Hi Richard!
>>
>> Of course I can provide more informations. The manifest file of the  
>> bundle
>> looks like this:
>>
>> Manifest-Version: 1.0
>> Bundle-ManifestVersion: 2
>> Bundle-Name: VehiclePushService
>> Bundle-SymbolicName: VehiclePushService
>> Bundle-Version: 1.0.0
>> Bundle-Activator: vehiclePushService.Activator
>> Import-Package: org.osgi.framework;version="1.3.0",
>> org.osgi.service.event;version="1.1.0",
>> vehiclePushService
>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>> Bundle-ClassPath: .,
>> vehiclePushService.jar
>> Export-Package:
>> osgiServices.vehiclePushService,
>> vehiclePushService
>>
>> The content of the bundle looks as follows:
>>
>> META-INF/
>> META-INF/MANIFEST.MF
>> hostApplication/
>> hostApplication/vehiclePushService/
>> osgiFramework/
>> osgiFramework/vehiclePushService/
>> vehiclePushService/
>> META-INF/.classpath
>> META-INF/.project
>> vehiclePushService.jar
>> vehiclePushService/Activator.class
>> vehiclePushService/OSGiPosition2D.class
>> vehiclePushService/OSGiVehicle.class
>> vehiclePushService/OSGiVehiclePushService.class
>> vehiclePushService/VehicleListener.class
>> vehiclePushService/VehiclePushEvent.class
>> vehiclePushService/VehiclePushServiceHandler.class
>>
>> Because inside the plug-in dependencies org.eclipse.services is  
>> referenced
>> I think that the bundles currently uses the equinox implementation  
>> of the
>> eventadmin service. Later on I will try to load the equinox  
>> eventadmin
>> service instead
>> of the felix eventadmin service. Maybe it's then possible to start my
>> bundle ...
>>
>> BR,
>>
>> Markus
>>
>>
>> 2009/7/13 Richard S. Hall <he...@ungoverned.org>
>>
>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>
>>>> Hi there!
>>>>
>>>> Today I wanted to add the eventadmin service to my OSGi  
>>>> environment.
>>>> Therefore I extended the import block of my bundle, which is  
>>>> created
>>>> within
>>>> an eclipse equinox project,  with org.osgi.service.event. After  
>>>> loading
>>>> the
>>>> service I tried to access it by running the following command:
>>>>
>>>>        // get service reference to event admin service
>>>>        serviceReference =
>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>
>>>>        // check if service reference is valid
>>>>        if (serviceReference != null)
>>>>        {
>>>>            eventAdmin = (EventAdmin)
>>>> bundleContext.getService(serviceReference);
>>>>        }
>>>>
>>>> But inside the if-loop I'm getting an error:
>>>>
>>>> java.lang.ClassCastException:
>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
 

>>>> cannot
>>>> be cast to org.osgi.service.event.EventAdmin
>>>>
>>>> I'm a little bit confused now, because I thought that the Apache  
>>>> Felix
>>>> framework is fully compatible to the OSGi specifications?!?
>>>>
>>>
>>> While the Felix framework isn't yet 100% compliant, it is very  
>>> close and
>>> getting closer every release.
>>>
>>> Isn't it
>>>> possible to mix equinox components (my bundle) with felix  
>>>> components (the
>>>> eventadmin service)?
>>>>
>>>> Does anybody has an idea how I can solve my problem?
>>>>
>>>>
>>>
>>> Such a scenario should work, but you didn't provide enough  
>>> information to
>>> say why it isn't. Perhaps you could show us your bundle's manifest  
>>> file as
>>> well as a "jar tf" of the bundle.
>>>
>>> -> richard
>>>
>>> BR,
>>>>
>>>> Markus
>>>>
>>>>
>>>>
>>>
>>> --- 
>>> ------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
BTW:

Beside the felix framework itself I'm currently only loading those three
bundles:

org.apache.felix.shell-1.2.0.jar
org.apache.felix.shell.tui-1.2.0.jar
org.apache.felix.eventadmin-1.0.0.jar

Do I have to add some of the OSGi API bundles as well?

BR,

Markus

2009/7/14 Markus Michel <ma...@uni-duesseldorf.de>

> Hi Richard!
>
> Of course I can provide more informations. The manifest file of the bundle
> looks like this:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: VehiclePushService
> Bundle-SymbolicName: VehiclePushService
> Bundle-Version: 1.0.0
> Bundle-Activator: vehiclePushService.Activator
> Import-Package: org.osgi.framework;version="1.3.0",
>  org.osgi.service.event;version="1.1.0",
>  vehiclePushService
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> Bundle-ClassPath: .,
>  vehiclePushService.jar
> Export-Package:
>  osgiServices.vehiclePushService,
>  vehiclePushService
>
> The content of the bundle looks as follows:
>
> META-INF/
> META-INF/MANIFEST.MF
> hostApplication/
> hostApplication/vehiclePushService/
> osgiFramework/
> osgiFramework/vehiclePushService/
> vehiclePushService/
> META-INF/.classpath
> META-INF/.project
> vehiclePushService.jar
> vehiclePushService/Activator.class
> vehiclePushService/OSGiPosition2D.class
> vehiclePushService/OSGiVehicle.class
> vehiclePushService/OSGiVehiclePushService.class
> vehiclePushService/VehicleListener.class
> vehiclePushService/VehiclePushEvent.class
> vehiclePushService/VehiclePushServiceHandler.class
>
> Because inside the plug-in dependencies org.eclipse.services is referenced
> I think that the bundles currently uses the equinox implementation of the
> eventadmin service. Later on I will try to load the equinox eventadmin
> service instead
> of the felix eventadmin service. Maybe it's then possible to start my
> bundle ...
>
> BR,
>
> Markus
>
>
> 2009/7/13 Richard S. Hall <he...@ungoverned.org>
>
> On 7/13/09 2:47 PM, Markus Michel wrote:
>>
>>> Hi there!
>>>
>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>> Therefore I extended the import block of my bundle, which is created
>>> within
>>> an eclipse equinox project,  with org.osgi.service.event. After loading
>>> the
>>> service I tried to access it by running the following command:
>>>
>>>         // get service reference to event admin service
>>>         serviceReference =
>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>
>>>         // check if service reference is valid
>>>         if (serviceReference != null)
>>>         {
>>>             eventAdmin = (EventAdmin)
>>> bundleContext.getService(serviceReference);
>>>         }
>>>
>>> But inside the if-loop I'm getting an error:
>>>
>>> java.lang.ClassCastException:
>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>> cannot
>>> be cast to org.osgi.service.event.EventAdmin
>>>
>>> I'm a little bit confused now, because I thought that the Apache Felix
>>> framework is fully compatible to the OSGi specifications?!?
>>>
>>
>> While the Felix framework isn't yet 100% compliant, it is very close and
>> getting closer every release.
>>
>>  Isn't it
>>> possible to mix equinox components (my bundle) with felix components (the
>>> eventadmin service)?
>>>
>>> Does anybody has an idea how I can solve my problem?
>>>
>>>
>>
>> Such a scenario should work, but you didn't provide enough information to
>> say why it isn't. Perhaps you could show us your bundle's manifest file as
>> well as a "jar tf" of the bundle.
>>
>> -> richard
>>
>>  BR,
>>>
>>> Markus
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>

Re: iPOJO temporary service instances?

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

On 15.07.2009, at 17:27, John Stump wrote:

> Yes, I have been reading about that, and I might go this route. I  
> also saw mentioned that the @Provides annotation supports a  
> "strategy" property to allow me to create a new instance for every  
> request, another requirement I have. Something like this:
>
> @Provides(strategy="instance")
>
> However, "strategy" is not documented in the iPOJO reference card at http://felix.apache.org/site/ipojo-reference-card.html 
> . Is strategy an officially supported property? Will I run into  
> problems in the future if I use it?

It is supported, just the doc is somewhat incomplete ....
Some more info are available here : http://ipojo-dark-side.blogspot.com/2009/04/customized-service-object-creation-with.html

In fact, it allows you to configure when service objects will be  
created and deleted. You can provide your own strategy (one per  
thread, limited life time ...). So, you create an instance providing a  
service. As soon as another iPOJO instance (it must be an iPOJO  
instance because the interaction pattern is different) uses this  
service, the creation strategy is applied. It might be useful in your  
case.

iPOJO provides several creation strategy:
- singleton : create one service object
- OSGi service factory : create one service object per asking bundle
- per instance : create one service object per component instance

In all case, those object are created only when required.

The main difference between creating / deleting instances and using a  
creation strategy is that you're not on the same layer : the first one  
creates component instances, the second one creates pojo objects.

Regards,

Clement


>
> Thanks for your help!
>
> john
>
> -----Original Message-----
> From: Clement Escoffier [mailto:clement.escoffier@gmail.com]
> Sent: Wednesday, July 15, 2009 9:21 AM
> To: users@felix.apache.org
> Subject: Re: iPOJO temporary service instances?
>
>
> On 15.07.2009, at 00:19, John Stump wrote:
>
>> There is a pattern I am trying to recreate within the iPOJO world,
>> but I can't quite figure it out.
>>
>> I want to be able to look up a service, create an instance of it,
>> use it, and toss it away. What iPOJO seems to support is creating
>> instances of services up front and have them ready and waiting. But
>> I don't want that. I want a service to be instantiated on demand.
>> How do I do this?
>>
>> One thought I had was to not create an instance of the service in
>> the metadata.xml, then the client can get the factory of the
>> service, create an instance, then discard it when it is through with
>> it. But this approach seems somewhat clumsy. Is there a better way?
>>
>
> By the way, iPOJO creates service objects only when they are needed
> (laziness) except if you configure it to be immediate.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: iPOJO temporary service instances?

Posted by John Stump <jo...@Navsys.com>.
Yes, I have been reading about that, and I might go this route. I also saw mentioned that the @Provides annotation supports a "strategy" property to allow me to create a new instance for every request, another requirement I have. Something like this:

@Provides(strategy="instance")

However, "strategy" is not documented in the iPOJO reference card at http://felix.apache.org/site/ipojo-reference-card.html. Is strategy an officially supported property? Will I run into problems in the future if I use it?

Thanks for your help!

john

-----Original Message-----
From: Clement Escoffier [mailto:clement.escoffier@gmail.com] 
Sent: Wednesday, July 15, 2009 9:21 AM
To: users@felix.apache.org
Subject: Re: iPOJO temporary service instances?


On 15.07.2009, at 00:19, John Stump wrote:

> There is a pattern I am trying to recreate within the iPOJO world,  
> but I can't quite figure it out.
>
> I want to be able to look up a service, create an instance of it,  
> use it, and toss it away. What iPOJO seems to support is creating  
> instances of services up front and have them ready and waiting. But  
> I don't want that. I want a service to be instantiated on demand.  
> How do I do this?
>
> One thought I had was to not create an instance of the service in  
> the metadata.xml, then the client can get the factory of the  
> service, create an instance, then discard it when it is through with  
> it. But this approach seems somewhat clumsy. Is there a better way?
>

By the way, iPOJO creates service objects only when they are needed  
(laziness) except if you configure it to be immediate.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: iPOJO temporary service instances?

Posted by Clement Escoffier <cl...@gmail.com>.
On 15.07.2009, at 00:19, John Stump wrote:

> There is a pattern I am trying to recreate within the iPOJO world,  
> but I can't quite figure it out.
>
> I want to be able to look up a service, create an instance of it,  
> use it, and toss it away. What iPOJO seems to support is creating  
> instances of services up front and have them ready and waiting. But  
> I don't want that. I want a service to be instantiated on demand.  
> How do I do this?
>
> One thought I had was to not create an instance of the service in  
> the metadata.xml, then the client can get the factory of the  
> service, create an instance, then discard it when it is through with  
> it. But this approach seems somewhat clumsy. Is there a better way?
>

By the way, iPOJO creates service objects only when they are needed  
(laziness) except if you configure it to be immediate.

> Thanks!
>
> john
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: iPOJO temporary service instances?

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

On 15.07.2009, at 00:19, John Stump wrote:

> There is a pattern I am trying to recreate within the iPOJO world,  
> but I can't quite figure it out.
>
> I want to be able to look up a service, create an instance of it,  
> use it, and toss it away. What iPOJO seems to support is creating  
> instances of services up front and have them ready and waiting. But  
> I don't want that. I want a service to be instantiated on demand.  
> How do I do this?
>
> One thought I had was to not create an instance of the service in  
> the metadata.xml, then the client can get the factory of the  
> service, create an instance, then discard it when it is through with  
> it. But this approach seems somewhat clumsy. Is there a better way?

That's the main way. However, you can also use the iPOJO API. Then,  
you can declare you component type, directly and easily create  
instances and dispose them.

Regards,

Clement

>
> Thanks!
>
> john
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


iPOJO temporary service instances?

Posted by John Stump <jo...@Navsys.com>.
There is a pattern I am trying to recreate within the iPOJO world, but I can't quite figure it out.

I want to be able to look up a service, create an instance of it, use it, and toss it away. What iPOJO seems to support is creating instances of services up front and have them ready and waiting. But I don't want that. I want a service to be instantiated on demand. How do I do this?

One thought I had was to not create an instance of the service in the metadata.xml, then the client can get the factory of the service, create an instance, then discard it when it is through with it. But this approach seems somewhat clumsy. Is there a better way?

Thanks!

john

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by Karl Pauls <ka...@gmail.com>.
On Wed, Sep 16, 2009 at 11:37 AM, Markus Michel
<ma...@uni-duesseldorf.de> wrote:
> Some minutes ago after reading the whole thread, I found the solution to my
> problem. As Richard already mentioned I have to set the following property:
>
> configMap.put("org.osgi.framework.bundle.parent", "app");
>
> I think that your property does internally the same, or?

Yes, thats what they translate into. Good to know that it works for you now.

regards,

Karl

> Anyway, now my environment is working again :-) Thanks!
>
> BR,
>
> Markus
>
> 2009/9/16 Karl Pauls <ka...@gmail.com>
>
>> On Tue, Sep 15, 2009 at 4:53 PM, Markus Michel
>> <ma...@uni-duesseldorf.de> wrote:
>> > Hi!
>> >
>> > After upgrading to the new framework version 2.0.0 the same error
>> occurred
>> > again, although the event service is still listed in the boot delegation
>> > property. Is there another way to solve my problem? Otherwise I probably
>> > have to continue using the old framework version ...
>>
>> They way you set the bootdelegation has changed a little with the new
>> framework version. You have to set:
>>
>> Constants.FRAMEWORK_BUNDLE_PARENT to
>> Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK
>>
>> That should make it work again.
>>
>> regards,
>>
>> Karl
>>
>> > BTW: What happened to the shell command services? Why it isn't included
>> in
>> > the new version?
>> >
>> > BR,
>> >
>> > Markus
>> >
>> > 2009/7/15 Markus Michel <ma...@uni-duesseldorf.de>
>> >
>> >> I would like to thank you for your help. After adding my services and
>> the
>> >> event admin service to the boot delegation property, my environment was
>> >> working fine. :-)
>> >>
>> >>
>> >> BR,
>> >>
>> >> Markus
>> >>
>> >> 2009/7/14 Richard S. Hall <he...@ungoverned.org>
>> >>
>> >>> I believe the issue is that you are exporting from the system bundle,
>> plus
>> >>> your bundle contains the same packages as you are exporting from the
>> system
>> >>> bundle.
>> >>>
>> >>> So, you have to make sure only one copy is being used. I think your
>> bundle
>> >>> was only exporting osgiServices.vehiclePushService. This means your
>> bundle
>> >>> will always get its own copy, since it doesn't import the package too.
>> If
>> >>> you import it too, then it would likely get wired to the system
>> bundle's
>> >>> export, since resolved packages are preferred and the system bundle
>> will be
>> >>> resolved first.
>> >>>
>> >>> As I mention in my other message, one way around this is in your
>> embedded
>> >>> mode, add the shared packages to the boot delegation property to get
>> them to
>> >>> always load from the class path. Note, if you are using trunk you will
>> need
>> >>> to set a new property to boot delegate to the app class loader
>> >>> (org.osgi.framework.bundle.parent=app).
>> >>>
>> >>> -> richard
>> >>>
>> >>> On 7/14/09 3:55 PM, Markus Michel wrote:
>> >>>
>> >>>> Some weeks ago I tried to use this instructions to get my embedded
>> felix
>> >>>> instance working, but it didn't worked. Afterwards some guy on
>> >>>> stackover.comgave me the hint to put the whole package to the system
>> >>>>
>> >>>> packages path. If I
>> >>>> strictly follow the wiki entry the line within my intialization block
>> >>>> should
>> >>>> look like:
>> >>>>
>> >>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> >>>> "osgiServices.vehiclePushService; version=1.0.0");
>> >>>>
>> >>>> <path to the service includings it's implementation within the host
>> app>
>> >>>>
>> >>>> But if the entry only contains this value, I'm getting the class
>> loading
>> >>>> error again.
>> >>>>
>> >>>> Sorry, but I think that I have some problems in understanding the
>> >>>> explanations on that site completely. As far as I understood it all
>> >>>> packages
>> >>>> within this property should be executed by the some class loader,
>> which
>> >>>> is
>> >>>> used for the system bundle and all other bundles. Therefore there
>> >>>> shouldn't
>> >>>> occur any class loading problems, when the bundle tries to access the
>> >>>> service. Am I wrong? Maybe you can give me a more detailed explanation
>> >>>> ...
>> >>>>
>> >>>> Unfortunately the felix environment has to run in the embedded mode
>> >>>> within
>> >>>> my program, because I want to run and control several osgi instances
>> at
>> >>>> once. I hope that we will be able to solve my problem ...
>> >>>>
>> >>>> BR,
>> >>>>
>> >>>> Markus
>> >>>>
>> >>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>> >>>>
>> >>>>
>> >>>>
>> >>>>> You should read:
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>> >>>>>
>> >>>>> It gives some pointers to running with an embedded framework
>> instance.
>> >>>>> In
>> >>>>> short, your app and all bundles should go through the class path
>> (i.e.,
>> >>>>> system bundle) for any packages shared between the host app and the
>> >>>>> bundles.
>> >>>>>
>> >>>>> To make sure this happens, you could actually put the host/bundle
>> shared
>> >>>>> packages on the boot class path property to make sure everyone gets
>> the
>> >>>>> same
>> >>>>> ones, no matter how the bundles are wired internally. This at least
>> has
>> >>>>> the
>> >>>>> benefit that your bundles will work properly when not used in the
>> >>>>> embedded
>> >>>>> situation.
>> >>>>>
>> >>>>> I knew there was more than what met the eye here. :-)
>> >>>>>
>> >>>>> Embedded mode is alluring to a lot of people coming to OSGi, but
>> there
>> >>>>> are
>> >>>>> lots of hidden issues with it, so better to avoid it if you can.
>> >>>>>
>> >>>>> ->  richard
>> >>>>>
>> >>>>>
>> >>>>> On 7/14/09 1:53 PM, Markus Michel wrote:
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>> You are right. If I remove that line, I'm able to load the event
>> admin
>> >>>>>> service. But the problem is that I cannot remove it, because other
>> >>>>>> parts
>> >>>>>> of
>> >>>>>> my program depends on that information: My "vehiclePushService" is
>> >>>>>> mostly
>> >>>>>> implemented (and started) within the host application but some parts
>> >>>>>> are
>> >>>>>> implemented within the bundle. If I do not add "vehiclePushService"
>> to
>> >>>>>> that
>> >>>>>> line, I'm getting the class loading exception
>> >>>>>>
>> >>>>>> java.lang.ClassCastException:
>> >>>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be
>> cast
>> >>>>>> to
>> >>>>>> osgiServices.vehiclePushService.VehiclePushService
>> >>>>>>
>> >>>>>> , when the bundle tries to use the service. Maybe I have to add the
>> >>>>>> event
>> >>>>>> admin service to that line, too?!?
>> >>>>>>
>> >>>>>> BR,
>> >>>>>>
>> >>>>>> Markus
>> >>>>>>
>> >>>>>> -----
>> >>>>>>
>> >>>>>> Markus,
>> >>>>>>
>> >>>>>> Yes, I believe your embedded configuration is the issue. Why are you
>> >>>>>> doing
>> >>>>>> this:
>> >>>>>>
>> >>>>>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> >>>>>> "osgiServices.vehicleCommunicationService;
>> >>>>>> osgiServices.vehiclePushService;
>> >>>>>> vehiclePushService; vehicleCommunicationService");
>> >>>>>>
>> >>>>>> ?
>> >>>>>>
>> >>>>>> It seems like this is incorrect, since your bundle contains these
>> >>>>>> packages.
>> >>>>>> Try removing this and see what happens.
>> >>>>>>
>> >>>>>> Hi Richard!
>> >>>>>>
>> >>>>>> Here's the bundle which tries to use the felix event admin service.
>> If
>> >>>>>> you
>> >>>>>> wish I can provide you the sources of the bundle, too.
>> >>>>>>
>> >>>>>> If you want to use the bundle, you have to load the following
>> bundles:
>> >>>>>>
>> >>>>>> org.apache.felix.shell-1.2.0.jar
>> >>>>>> org.apache.felix.shell.tui-1.2.0.jar
>> >>>>>> org.apache.felix.eventadmin-1.0.0.jar
>> >>>>>> VehiclePushService_1.0.0.jar
>> >>>>>>
>> >>>>>> Some minutes ago I noticed that the bundle can be loaded
>> successfully
>> >>>>>> if
>> >>>>>> you
>> >>>>>> run it directly from a command-line-based felix instance. The error
>> >>>>>> only
>> >>>>>> occures if you try to run it
>> >>>>>> as an embedded version. Very confusing.
>> >>>>>>
>> >>>>>> Maybe there's something wrong with the configuration of my felix
>> >>>>>> instance:
>> >>>>>>
>> >>>>>>     private void initialize()
>> >>>>>>     {
>> >>>>>>         // create new map for storing the felix configuration
>> >>>>>> properties
>> >>>>>>         configMap = new HashMap<String, Object>();
>> >>>>>>
>> >>>>>>         // export the host provided service interface package
>> >>>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> >>>>>> "osgiServices.vehicleCommunicationService;
>> >>>>>> osgiServices.vehiclePushService;
>> >>>>>> vehiclePushService; vehicleCommunicationService");
>> >>>>>>
>> >>>>>>         // add autoactivator that specifies all services that shall
>> be
>> >>>>>> loaded together with the system bundle
>> >>>>>>         List<Object>   list = new ArrayList<Object>();
>> >>>>>>         list.add(new AutoActivator(configMap));
>> >>>>>>
>> >>>>>>         // create service activators
>> >>>>>>         vehicleCommunicationServiceActivator = new
>> >>>>>> VehicleCommunicationServiceActivator(connection);
>> >>>>>>         list.add(vehicleCommunicationServiceActivator);
>> >>>>>>
>> >>>>>>         vehiclePushServiceActivator = new
>> >>>>>> VehiclePushServiceActivator();
>> >>>>>>         list.add(vehiclePushServiceActivator);
>> >>>>>>
>> >>>>>>         // add service activators to felix instance
>> >>>>>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>> >>>>>> list);
>> >>>>>>
>> >>>>>>         // set felix-cache folder
>> >>>>>>         configMap.put("org.osgi.framework.storage", "felix-cache/" +
>> >>>>>> id);
>> >>>>>>     }
>> >>>>>>
>> >>>>>>
>> >>>>>> BR,
>> >>>>>>
>> >>>>>> Markus
>> >>>>>>
>> >>>>>> -------
>> >>>>>>
>> >>>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>> I don't see anything that immediately looks incorrect. If you want
>> to
>> >>>>>>> send
>> >>>>>>> me your bundle (privately) with the steps to reproduce, I will look
>> at
>> >>>>>>> it.
>> >>>>>>>
>> >>>>>>> ->   richard
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>> Hi Richard!
>> >>>>>>>>
>> >>>>>>>> Of course I can provide more informations. The manifest file of
>> the
>> >>>>>>>> bundle
>> >>>>>>>> looks like this:
>> >>>>>>>>
>> >>>>>>>> Manifest-Version: 1.0
>> >>>>>>>> Bundle-ManifestVersion: 2
>> >>>>>>>> Bundle-Name: VehiclePushService
>> >>>>>>>> Bundle-SymbolicName: VehiclePushService
>> >>>>>>>> Bundle-Version: 1.0.0
>> >>>>>>>> Bundle-Activator: vehiclePushService.Activator
>> >>>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>> >>>>>>>>  org.osgi.service.event;version="1.1.0",
>> >>>>>>>>  vehiclePushService
>> >>>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>> >>>>>>>> Bundle-ClassPath: .,
>> >>>>>>>>  vehiclePushService.jar
>> >>>>>>>> Export-Package:
>> >>>>>>>>  osgiServices.vehiclePushService,
>> >>>>>>>>  vehiclePushService
>> >>>>>>>>
>> >>>>>>>> The content of the bundle looks as follows:
>> >>>>>>>>
>> >>>>>>>> META-INF/
>> >>>>>>>> META-INF/MANIFEST.MF
>> >>>>>>>> hostApplication/
>> >>>>>>>> hostApplication/vehiclePushService/
>> >>>>>>>> osgiFramework/
>> >>>>>>>> osgiFramework/vehiclePushService/
>> >>>>>>>> vehiclePushService/
>> >>>>>>>> META-INF/.classpath
>> >>>>>>>> META-INF/.project
>> >>>>>>>> vehiclePushService.jar
>> >>>>>>>> vehiclePushService/Activator.class
>> >>>>>>>> vehiclePushService/OSGiPosition2D.class
>> >>>>>>>> vehiclePushService/OSGiVehicle.class
>> >>>>>>>> vehiclePushService/OSGiVehiclePushService.class
>> >>>>>>>> vehiclePushService/VehicleListener.class
>> >>>>>>>> vehiclePushService/VehiclePushEvent.class
>> >>>>>>>> vehiclePushService/VehiclePushServiceHandler.class
>> >>>>>>>>
>> >>>>>>>> Because inside the plug-in dependencies org.eclipse.services is
>> >>>>>>>> referenced
>> >>>>>>>> I
>> >>>>>>>> think that the bundles currently uses the equinox implementation
>> of
>> >>>>>>>> the
>> >>>>>>>> eventadmin service. Later on I will try to load the equinox
>> >>>>>>>> eventadmin
>> >>>>>>>> service instead
>> >>>>>>>> of the felix eventadmin service. Maybe it's then possible to start
>> my
>> >>>>>>>> bundle
>> >>>>>>>> ...
>> >>>>>>>>
>> >>>>>>>> BR,
>> >>>>>>>>
>> >>>>>>>> Markus
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>> Hi there!
>> >>>>>>>>>>
>> >>>>>>>>>> Today I wanted to add the eventadmin service to my OSGi
>> >>>>>>>>>> environment.
>> >>>>>>>>>> Therefore I extended the import block of my bundle, which is
>> >>>>>>>>>> created
>> >>>>>>>>>> within
>> >>>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>> >>>>>>>>>> loading
>> >>>>>>>>>> the
>> >>>>>>>>>> service I tried to access it by running the following command:
>> >>>>>>>>>>
>> >>>>>>>>>>         // get service reference to event admin service
>> >>>>>>>>>>         serviceReference =
>> >>>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>> >>>>>>>>>>
>> >>>>>>>>>>         // check if service reference is valid
>> >>>>>>>>>>         if (serviceReference != null)
>> >>>>>>>>>>         {
>> >>>>>>>>>>             eventAdmin = (EventAdmin)
>> >>>>>>>>>> bundleContext.getService(serviceReference);
>> >>>>>>>>>>         }
>> >>>>>>>>>>
>> >>>>>>>>>> But inside the if-loop I'm getting an error:
>> >>>>>>>>>>
>> >>>>>>>>>> java.lang.ClassCastException:
>> >>>>>>>>>>
>> >>>>>>>>>>
>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>> >>>>>>>>>> cannot
>> >>>>>>>>>> be cast to org.osgi.service.event.EventAdmin
>> >>>>>>>>>>
>> >>>>>>>>>> I'm a little bit confused now, because I thought that the Apache
>> >>>>>>>>>> Felix
>> >>>>>>>>>> framework is fully compatible to the OSGi specifications?!?
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>> While the Felix framework isn't yet 100% compliant, it is very
>> close
>> >>>>>>>>> and
>> >>>>>>>>> getting closer every release.
>> >>>>>>>>>
>> >>>>>>>>>  Isn't it
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>> possible to mix equinox components (my bundle) with felix
>> >>>>>>>>>> components
>> >>>>>>>>>> (the
>> >>>>>>>>>> eventadmin service)?
>> >>>>>>>>>>
>> >>>>>>>>>> Does anybody has an idea how I can solve my problem?
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>> Such a scenario should work, but you didn't provide enough
>> >>>>>>>>> information
>> >>>>>>>>> to
>> >>>>>>>>> say why it isn't. Perhaps you could show us your bundle's
>> manifest
>> >>>>>>>>> file
>> >>>>>>>>> as
>> >>>>>>>>> well as a "jar tf" of the bundle.
>> >>>>>>>>>
>> >>>>>>>>> ->    richard
>> >>>>>>>>>
>> >>>>>>>>>  BR,
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>> Markus
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> ---------------------------------------------------------------------
>> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> >>>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >
>>
>>
>>
>> --
>> Karl Pauls
>> karlpauls@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
Some minutes ago after reading the whole thread, I found the solution to my
problem. As Richard already mentioned I have to set the following property:

configMap.put("org.osgi.framework.bundle.parent", "app");

I think that your property does internally the same, or?

Anyway, now my environment is working again :-) Thanks!

BR,

Markus

2009/9/16 Karl Pauls <ka...@gmail.com>

> On Tue, Sep 15, 2009 at 4:53 PM, Markus Michel
> <ma...@uni-duesseldorf.de> wrote:
> > Hi!
> >
> > After upgrading to the new framework version 2.0.0 the same error
> occurred
> > again, although the event service is still listed in the boot delegation
> > property. Is there another way to solve my problem? Otherwise I probably
> > have to continue using the old framework version ...
>
> They way you set the bootdelegation has changed a little with the new
> framework version. You have to set:
>
> Constants.FRAMEWORK_BUNDLE_PARENT to
> Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK
>
> That should make it work again.
>
> regards,
>
> Karl
>
> > BTW: What happened to the shell command services? Why it isn't included
> in
> > the new version?
> >
> > BR,
> >
> > Markus
> >
> > 2009/7/15 Markus Michel <ma...@uni-duesseldorf.de>
> >
> >> I would like to thank you for your help. After adding my services and
> the
> >> event admin service to the boot delegation property, my environment was
> >> working fine. :-)
> >>
> >>
> >> BR,
> >>
> >> Markus
> >>
> >> 2009/7/14 Richard S. Hall <he...@ungoverned.org>
> >>
> >>> I believe the issue is that you are exporting from the system bundle,
> plus
> >>> your bundle contains the same packages as you are exporting from the
> system
> >>> bundle.
> >>>
> >>> So, you have to make sure only one copy is being used. I think your
> bundle
> >>> was only exporting osgiServices.vehiclePushService. This means your
> bundle
> >>> will always get its own copy, since it doesn't import the package too.
> If
> >>> you import it too, then it would likely get wired to the system
> bundle's
> >>> export, since resolved packages are preferred and the system bundle
> will be
> >>> resolved first.
> >>>
> >>> As I mention in my other message, one way around this is in your
> embedded
> >>> mode, add the shared packages to the boot delegation property to get
> them to
> >>> always load from the class path. Note, if you are using trunk you will
> need
> >>> to set a new property to boot delegate to the app class loader
> >>> (org.osgi.framework.bundle.parent=app).
> >>>
> >>> -> richard
> >>>
> >>> On 7/14/09 3:55 PM, Markus Michel wrote:
> >>>
> >>>> Some weeks ago I tried to use this instructions to get my embedded
> felix
> >>>> instance working, but it didn't worked. Afterwards some guy on
> >>>> stackover.comgave me the hint to put the whole package to the system
> >>>>
> >>>> packages path. If I
> >>>> strictly follow the wiki entry the line within my intialization block
> >>>> should
> >>>> look like:
> >>>>
> >>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> >>>> "osgiServices.vehiclePushService; version=1.0.0");
> >>>>
> >>>> <path to the service includings it's implementation within the host
> app>
> >>>>
> >>>> But if the entry only contains this value, I'm getting the class
> loading
> >>>> error again.
> >>>>
> >>>> Sorry, but I think that I have some problems in understanding the
> >>>> explanations on that site completely. As far as I understood it all
> >>>> packages
> >>>> within this property should be executed by the some class loader,
> which
> >>>> is
> >>>> used for the system bundle and all other bundles. Therefore there
> >>>> shouldn't
> >>>> occur any class loading problems, when the bundle tries to access the
> >>>> service. Am I wrong? Maybe you can give me a more detailed explanation
> >>>> ...
> >>>>
> >>>> Unfortunately the felix environment has to run in the embedded mode
> >>>> within
> >>>> my program, because I want to run and control several osgi instances
> at
> >>>> once. I hope that we will be able to solve my problem ...
> >>>>
> >>>> BR,
> >>>>
> >>>> Markus
> >>>>
> >>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
> >>>>
> >>>>
> >>>>
> >>>>> You should read:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
> >>>>>
> >>>>> It gives some pointers to running with an embedded framework
> instance.
> >>>>> In
> >>>>> short, your app and all bundles should go through the class path
> (i.e.,
> >>>>> system bundle) for any packages shared between the host app and the
> >>>>> bundles.
> >>>>>
> >>>>> To make sure this happens, you could actually put the host/bundle
> shared
> >>>>> packages on the boot class path property to make sure everyone gets
> the
> >>>>> same
> >>>>> ones, no matter how the bundles are wired internally. This at least
> has
> >>>>> the
> >>>>> benefit that your bundles will work properly when not used in the
> >>>>> embedded
> >>>>> situation.
> >>>>>
> >>>>> I knew there was more than what met the eye here. :-)
> >>>>>
> >>>>> Embedded mode is alluring to a lot of people coming to OSGi, but
> there
> >>>>> are
> >>>>> lots of hidden issues with it, so better to avoid it if you can.
> >>>>>
> >>>>> ->  richard
> >>>>>
> >>>>>
> >>>>> On 7/14/09 1:53 PM, Markus Michel wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>> You are right. If I remove that line, I'm able to load the event
> admin
> >>>>>> service. But the problem is that I cannot remove it, because other
> >>>>>> parts
> >>>>>> of
> >>>>>> my program depends on that information: My "vehiclePushService" is
> >>>>>> mostly
> >>>>>> implemented (and started) within the host application but some parts
> >>>>>> are
> >>>>>> implemented within the bundle. If I do not add "vehiclePushService"
> to
> >>>>>> that
> >>>>>> line, I'm getting the class loading exception
> >>>>>>
> >>>>>> java.lang.ClassCastException:
> >>>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be
> cast
> >>>>>> to
> >>>>>> osgiServices.vehiclePushService.VehiclePushService
> >>>>>>
> >>>>>> , when the bundle tries to use the service. Maybe I have to add the
> >>>>>> event
> >>>>>> admin service to that line, too?!?
> >>>>>>
> >>>>>> BR,
> >>>>>>
> >>>>>> Markus
> >>>>>>
> >>>>>> -----
> >>>>>>
> >>>>>> Markus,
> >>>>>>
> >>>>>> Yes, I believe your embedded configuration is the issue. Why are you
> >>>>>> doing
> >>>>>> this:
> >>>>>>
> >>>>>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> >>>>>> "osgiServices.vehicleCommunicationService;
> >>>>>> osgiServices.vehiclePushService;
> >>>>>> vehiclePushService; vehicleCommunicationService");
> >>>>>>
> >>>>>> ?
> >>>>>>
> >>>>>> It seems like this is incorrect, since your bundle contains these
> >>>>>> packages.
> >>>>>> Try removing this and see what happens.
> >>>>>>
> >>>>>> Hi Richard!
> >>>>>>
> >>>>>> Here's the bundle which tries to use the felix event admin service.
> If
> >>>>>> you
> >>>>>> wish I can provide you the sources of the bundle, too.
> >>>>>>
> >>>>>> If you want to use the bundle, you have to load the following
> bundles:
> >>>>>>
> >>>>>> org.apache.felix.shell-1.2.0.jar
> >>>>>> org.apache.felix.shell.tui-1.2.0.jar
> >>>>>> org.apache.felix.eventadmin-1.0.0.jar
> >>>>>> VehiclePushService_1.0.0.jar
> >>>>>>
> >>>>>> Some minutes ago I noticed that the bundle can be loaded
> successfully
> >>>>>> if
> >>>>>> you
> >>>>>> run it directly from a command-line-based felix instance. The error
> >>>>>> only
> >>>>>> occures if you try to run it
> >>>>>> as an embedded version. Very confusing.
> >>>>>>
> >>>>>> Maybe there's something wrong with the configuration of my felix
> >>>>>> instance:
> >>>>>>
> >>>>>>     private void initialize()
> >>>>>>     {
> >>>>>>         // create new map for storing the felix configuration
> >>>>>> properties
> >>>>>>         configMap = new HashMap<String, Object>();
> >>>>>>
> >>>>>>         // export the host provided service interface package
> >>>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> >>>>>> "osgiServices.vehicleCommunicationService;
> >>>>>> osgiServices.vehiclePushService;
> >>>>>> vehiclePushService; vehicleCommunicationService");
> >>>>>>
> >>>>>>         // add autoactivator that specifies all services that shall
> be
> >>>>>> loaded together with the system bundle
> >>>>>>         List<Object>   list = new ArrayList<Object>();
> >>>>>>         list.add(new AutoActivator(configMap));
> >>>>>>
> >>>>>>         // create service activators
> >>>>>>         vehicleCommunicationServiceActivator = new
> >>>>>> VehicleCommunicationServiceActivator(connection);
> >>>>>>         list.add(vehicleCommunicationServiceActivator);
> >>>>>>
> >>>>>>         vehiclePushServiceActivator = new
> >>>>>> VehiclePushServiceActivator();
> >>>>>>         list.add(vehiclePushServiceActivator);
> >>>>>>
> >>>>>>         // add service activators to felix instance
> >>>>>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
> >>>>>> list);
> >>>>>>
> >>>>>>         // set felix-cache folder
> >>>>>>         configMap.put("org.osgi.framework.storage", "felix-cache/" +
> >>>>>> id);
> >>>>>>     }
> >>>>>>
> >>>>>>
> >>>>>> BR,
> >>>>>>
> >>>>>> Markus
> >>>>>>
> >>>>>> -------
> >>>>>>
> >>>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> I don't see anything that immediately looks incorrect. If you want
> to
> >>>>>>> send
> >>>>>>> me your bundle (privately) with the steps to reproduce, I will look
> at
> >>>>>>> it.
> >>>>>>>
> >>>>>>> ->   richard
> >>>>>>>
> >>>>>>>
> >>>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> Hi Richard!
> >>>>>>>>
> >>>>>>>> Of course I can provide more informations. The manifest file of
> the
> >>>>>>>> bundle
> >>>>>>>> looks like this:
> >>>>>>>>
> >>>>>>>> Manifest-Version: 1.0
> >>>>>>>> Bundle-ManifestVersion: 2
> >>>>>>>> Bundle-Name: VehiclePushService
> >>>>>>>> Bundle-SymbolicName: VehiclePushService
> >>>>>>>> Bundle-Version: 1.0.0
> >>>>>>>> Bundle-Activator: vehiclePushService.Activator
> >>>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
> >>>>>>>>  org.osgi.service.event;version="1.1.0",
> >>>>>>>>  vehiclePushService
> >>>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> >>>>>>>> Bundle-ClassPath: .,
> >>>>>>>>  vehiclePushService.jar
> >>>>>>>> Export-Package:
> >>>>>>>>  osgiServices.vehiclePushService,
> >>>>>>>>  vehiclePushService
> >>>>>>>>
> >>>>>>>> The content of the bundle looks as follows:
> >>>>>>>>
> >>>>>>>> META-INF/
> >>>>>>>> META-INF/MANIFEST.MF
> >>>>>>>> hostApplication/
> >>>>>>>> hostApplication/vehiclePushService/
> >>>>>>>> osgiFramework/
> >>>>>>>> osgiFramework/vehiclePushService/
> >>>>>>>> vehiclePushService/
> >>>>>>>> META-INF/.classpath
> >>>>>>>> META-INF/.project
> >>>>>>>> vehiclePushService.jar
> >>>>>>>> vehiclePushService/Activator.class
> >>>>>>>> vehiclePushService/OSGiPosition2D.class
> >>>>>>>> vehiclePushService/OSGiVehicle.class
> >>>>>>>> vehiclePushService/OSGiVehiclePushService.class
> >>>>>>>> vehiclePushService/VehicleListener.class
> >>>>>>>> vehiclePushService/VehiclePushEvent.class
> >>>>>>>> vehiclePushService/VehiclePushServiceHandler.class
> >>>>>>>>
> >>>>>>>> Because inside the plug-in dependencies org.eclipse.services is
> >>>>>>>> referenced
> >>>>>>>> I
> >>>>>>>> think that the bundles currently uses the equinox implementation
> of
> >>>>>>>> the
> >>>>>>>> eventadmin service. Later on I will try to load the equinox
> >>>>>>>> eventadmin
> >>>>>>>> service instead
> >>>>>>>> of the felix eventadmin service. Maybe it's then possible to start
> my
> >>>>>>>> bundle
> >>>>>>>> ...
> >>>>>>>>
> >>>>>>>> BR,
> >>>>>>>>
> >>>>>>>> Markus
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Hi there!
> >>>>>>>>>>
> >>>>>>>>>> Today I wanted to add the eventadmin service to my OSGi
> >>>>>>>>>> environment.
> >>>>>>>>>> Therefore I extended the import block of my bundle, which is
> >>>>>>>>>> created
> >>>>>>>>>> within
> >>>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
> >>>>>>>>>> loading
> >>>>>>>>>> the
> >>>>>>>>>> service I tried to access it by running the following command:
> >>>>>>>>>>
> >>>>>>>>>>         // get service reference to event admin service
> >>>>>>>>>>         serviceReference =
> >>>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
> >>>>>>>>>>
> >>>>>>>>>>         // check if service reference is valid
> >>>>>>>>>>         if (serviceReference != null)
> >>>>>>>>>>         {
> >>>>>>>>>>             eventAdmin = (EventAdmin)
> >>>>>>>>>> bundleContext.getService(serviceReference);
> >>>>>>>>>>         }
> >>>>>>>>>>
> >>>>>>>>>> But inside the if-loop I'm getting an error:
> >>>>>>>>>>
> >>>>>>>>>> java.lang.ClassCastException:
> >>>>>>>>>>
> >>>>>>>>>>
> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
> >>>>>>>>>> cannot
> >>>>>>>>>> be cast to org.osgi.service.event.EventAdmin
> >>>>>>>>>>
> >>>>>>>>>> I'm a little bit confused now, because I thought that the Apache
> >>>>>>>>>> Felix
> >>>>>>>>>> framework is fully compatible to the OSGi specifications?!?
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> While the Felix framework isn't yet 100% compliant, it is very
> close
> >>>>>>>>> and
> >>>>>>>>> getting closer every release.
> >>>>>>>>>
> >>>>>>>>>  Isn't it
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> possible to mix equinox components (my bundle) with felix
> >>>>>>>>>> components
> >>>>>>>>>> (the
> >>>>>>>>>> eventadmin service)?
> >>>>>>>>>>
> >>>>>>>>>> Does anybody has an idea how I can solve my problem?
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> Such a scenario should work, but you didn't provide enough
> >>>>>>>>> information
> >>>>>>>>> to
> >>>>>>>>> say why it isn't. Perhaps you could show us your bundle's
> manifest
> >>>>>>>>> file
> >>>>>>>>> as
> >>>>>>>>> well as a "jar tf" of the bundle.
> >>>>>>>>>
> >>>>>>>>> ->    richard
> >>>>>>>>>
> >>>>>>>>>  BR,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Markus
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >>>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >
>
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Using Felix EventAdmin Service?!?

Posted by Karl Pauls <ka...@gmail.com>.
On Tue, Sep 15, 2009 at 4:53 PM, Markus Michel
<ma...@uni-duesseldorf.de> wrote:
> Hi!
>
> After upgrading to the new framework version 2.0.0 the same error occurred
> again, although the event service is still listed in the boot delegation
> property. Is there another way to solve my problem? Otherwise I probably
> have to continue using the old framework version ...

They way you set the bootdelegation has changed a little with the new
framework version. You have to set:

Constants.FRAMEWORK_BUNDLE_PARENT to Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK

That should make it work again.

regards,

Karl

> BTW: What happened to the shell command services? Why it isn't included in
> the new version?
>
> BR,
>
> Markus
>
> 2009/7/15 Markus Michel <ma...@uni-duesseldorf.de>
>
>> I would like to thank you for your help. After adding my services and the
>> event admin service to the boot delegation property, my environment was
>> working fine. :-)
>>
>>
>> BR,
>>
>> Markus
>>
>> 2009/7/14 Richard S. Hall <he...@ungoverned.org>
>>
>>> I believe the issue is that you are exporting from the system bundle, plus
>>> your bundle contains the same packages as you are exporting from the system
>>> bundle.
>>>
>>> So, you have to make sure only one copy is being used. I think your bundle
>>> was only exporting osgiServices.vehiclePushService. This means your bundle
>>> will always get its own copy, since it doesn't import the package too. If
>>> you import it too, then it would likely get wired to the system bundle's
>>> export, since resolved packages are preferred and the system bundle will be
>>> resolved first.
>>>
>>> As I mention in my other message, one way around this is in your embedded
>>> mode, add the shared packages to the boot delegation property to get them to
>>> always load from the class path. Note, if you are using trunk you will need
>>> to set a new property to boot delegate to the app class loader
>>> (org.osgi.framework.bundle.parent=app).
>>>
>>> -> richard
>>>
>>> On 7/14/09 3:55 PM, Markus Michel wrote:
>>>
>>>> Some weeks ago I tried to use this instructions to get my embedded felix
>>>> instance working, but it didn't worked. Afterwards some guy on
>>>> stackover.comgave me the hint to put the whole package to the system
>>>>
>>>> packages path. If I
>>>> strictly follow the wiki entry the line within my intialization block
>>>> should
>>>> look like:
>>>>
>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>> "osgiServices.vehiclePushService; version=1.0.0");
>>>>
>>>> <path to the service includings it's implementation within the host app>
>>>>
>>>> But if the entry only contains this value, I'm getting the class loading
>>>> error again.
>>>>
>>>> Sorry, but I think that I have some problems in understanding the
>>>> explanations on that site completely. As far as I understood it all
>>>> packages
>>>> within this property should be executed by the some class loader, which
>>>> is
>>>> used for the system bundle and all other bundles. Therefore there
>>>> shouldn't
>>>> occur any class loading problems, when the bundle tries to access the
>>>> service. Am I wrong? Maybe you can give me a more detailed explanation
>>>> ...
>>>>
>>>> Unfortunately the felix environment has to run in the embedded mode
>>>> within
>>>> my program, because I want to run and control several osgi instances at
>>>> once. I hope that we will be able to solve my problem ...
>>>>
>>>> BR,
>>>>
>>>> Markus
>>>>
>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>
>>>>
>>>>
>>>>> You should read:
>>>>>
>>>>>
>>>>>
>>>>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>>>>
>>>>> It gives some pointers to running with an embedded framework instance.
>>>>> In
>>>>> short, your app and all bundles should go through the class path (i.e.,
>>>>> system bundle) for any packages shared between the host app and the
>>>>> bundles.
>>>>>
>>>>> To make sure this happens, you could actually put the host/bundle shared
>>>>> packages on the boot class path property to make sure everyone gets the
>>>>> same
>>>>> ones, no matter how the bundles are wired internally. This at least has
>>>>> the
>>>>> benefit that your bundles will work properly when not used in the
>>>>> embedded
>>>>> situation.
>>>>>
>>>>> I knew there was more than what met the eye here. :-)
>>>>>
>>>>> Embedded mode is alluring to a lot of people coming to OSGi, but there
>>>>> are
>>>>> lots of hidden issues with it, so better to avoid it if you can.
>>>>>
>>>>> ->  richard
>>>>>
>>>>>
>>>>> On 7/14/09 1:53 PM, Markus Michel wrote:
>>>>>
>>>>>
>>>>>
>>>>>> You are right. If I remove that line, I'm able to load the event admin
>>>>>> service. But the problem is that I cannot remove it, because other
>>>>>> parts
>>>>>> of
>>>>>> my program depends on that information: My "vehiclePushService" is
>>>>>> mostly
>>>>>> implemented (and started) within the host application but some parts
>>>>>> are
>>>>>> implemented within the bundle. If I do not add "vehiclePushService" to
>>>>>> that
>>>>>> line, I'm getting the class loading exception
>>>>>>
>>>>>> java.lang.ClassCastException:
>>>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast
>>>>>> to
>>>>>> osgiServices.vehiclePushService.VehiclePushService
>>>>>>
>>>>>> , when the bundle tries to use the service. Maybe I have to add the
>>>>>> event
>>>>>> admin service to that line, too?!?
>>>>>>
>>>>>> BR,
>>>>>>
>>>>>> Markus
>>>>>>
>>>>>> -----
>>>>>>
>>>>>> Markus,
>>>>>>
>>>>>> Yes, I believe your embedded configuration is the issue. Why are you
>>>>>> doing
>>>>>> this:
>>>>>>
>>>>>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>>> "osgiServices.vehicleCommunicationService;
>>>>>> osgiServices.vehiclePushService;
>>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>>
>>>>>> ?
>>>>>>
>>>>>> It seems like this is incorrect, since your bundle contains these
>>>>>> packages.
>>>>>> Try removing this and see what happens.
>>>>>>
>>>>>> Hi Richard!
>>>>>>
>>>>>> Here's the bundle which tries to use the felix event admin service. If
>>>>>> you
>>>>>> wish I can provide you the sources of the bundle, too.
>>>>>>
>>>>>> If you want to use the bundle, you have to load the following bundles:
>>>>>>
>>>>>> org.apache.felix.shell-1.2.0.jar
>>>>>> org.apache.felix.shell.tui-1.2.0.jar
>>>>>> org.apache.felix.eventadmin-1.0.0.jar
>>>>>> VehiclePushService_1.0.0.jar
>>>>>>
>>>>>> Some minutes ago I noticed that the bundle can be loaded successfully
>>>>>> if
>>>>>> you
>>>>>> run it directly from a command-line-based felix instance. The error
>>>>>> only
>>>>>> occures if you try to run it
>>>>>> as an embedded version. Very confusing.
>>>>>>
>>>>>> Maybe there's something wrong with the configuration of my felix
>>>>>> instance:
>>>>>>
>>>>>>     private void initialize()
>>>>>>     {
>>>>>>         // create new map for storing the felix configuration
>>>>>> properties
>>>>>>         configMap = new HashMap<String, Object>();
>>>>>>
>>>>>>         // export the host provided service interface package
>>>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>>> "osgiServices.vehicleCommunicationService;
>>>>>> osgiServices.vehiclePushService;
>>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>>
>>>>>>         // add autoactivator that specifies all services that shall be
>>>>>> loaded together with the system bundle
>>>>>>         List<Object>   list = new ArrayList<Object>();
>>>>>>         list.add(new AutoActivator(configMap));
>>>>>>
>>>>>>         // create service activators
>>>>>>         vehicleCommunicationServiceActivator = new
>>>>>> VehicleCommunicationServiceActivator(connection);
>>>>>>         list.add(vehicleCommunicationServiceActivator);
>>>>>>
>>>>>>         vehiclePushServiceActivator = new
>>>>>> VehiclePushServiceActivator();
>>>>>>         list.add(vehiclePushServiceActivator);
>>>>>>
>>>>>>         // add service activators to felix instance
>>>>>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>>>>> list);
>>>>>>
>>>>>>         // set felix-cache folder
>>>>>>         configMap.put("org.osgi.framework.storage", "felix-cache/" +
>>>>>> id);
>>>>>>     }
>>>>>>
>>>>>>
>>>>>> BR,
>>>>>>
>>>>>> Markus
>>>>>>
>>>>>> -------
>>>>>>
>>>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I don't see anything that immediately looks incorrect. If you want to
>>>>>>> send
>>>>>>> me your bundle (privately) with the steps to reproduce, I will look at
>>>>>>> it.
>>>>>>>
>>>>>>> ->   richard
>>>>>>>
>>>>>>>
>>>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi Richard!
>>>>>>>>
>>>>>>>> Of course I can provide more informations. The manifest file of the
>>>>>>>> bundle
>>>>>>>> looks like this:
>>>>>>>>
>>>>>>>> Manifest-Version: 1.0
>>>>>>>> Bundle-ManifestVersion: 2
>>>>>>>> Bundle-Name: VehiclePushService
>>>>>>>> Bundle-SymbolicName: VehiclePushService
>>>>>>>> Bundle-Version: 1.0.0
>>>>>>>> Bundle-Activator: vehiclePushService.Activator
>>>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>>>>>  org.osgi.service.event;version="1.1.0",
>>>>>>>>  vehiclePushService
>>>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>>>>>> Bundle-ClassPath: .,
>>>>>>>>  vehiclePushService.jar
>>>>>>>> Export-Package:
>>>>>>>>  osgiServices.vehiclePushService,
>>>>>>>>  vehiclePushService
>>>>>>>>
>>>>>>>> The content of the bundle looks as follows:
>>>>>>>>
>>>>>>>> META-INF/
>>>>>>>> META-INF/MANIFEST.MF
>>>>>>>> hostApplication/
>>>>>>>> hostApplication/vehiclePushService/
>>>>>>>> osgiFramework/
>>>>>>>> osgiFramework/vehiclePushService/
>>>>>>>> vehiclePushService/
>>>>>>>> META-INF/.classpath
>>>>>>>> META-INF/.project
>>>>>>>> vehiclePushService.jar
>>>>>>>> vehiclePushService/Activator.class
>>>>>>>> vehiclePushService/OSGiPosition2D.class
>>>>>>>> vehiclePushService/OSGiVehicle.class
>>>>>>>> vehiclePushService/OSGiVehiclePushService.class
>>>>>>>> vehiclePushService/VehicleListener.class
>>>>>>>> vehiclePushService/VehiclePushEvent.class
>>>>>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>>>>>
>>>>>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>>>>>> referenced
>>>>>>>> I
>>>>>>>> think that the bundles currently uses the equinox implementation of
>>>>>>>> the
>>>>>>>> eventadmin service. Later on I will try to load the equinox
>>>>>>>> eventadmin
>>>>>>>> service instead
>>>>>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>>>>>> bundle
>>>>>>>> ...
>>>>>>>>
>>>>>>>> BR,
>>>>>>>>
>>>>>>>> Markus
>>>>>>>>
>>>>>>>>
>>>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hi there!
>>>>>>>>>>
>>>>>>>>>> Today I wanted to add the eventadmin service to my OSGi
>>>>>>>>>> environment.
>>>>>>>>>> Therefore I extended the import block of my bundle, which is
>>>>>>>>>> created
>>>>>>>>>> within
>>>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>>>>>> loading
>>>>>>>>>> the
>>>>>>>>>> service I tried to access it by running the following command:
>>>>>>>>>>
>>>>>>>>>>         // get service reference to event admin service
>>>>>>>>>>         serviceReference =
>>>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>>>>>
>>>>>>>>>>         // check if service reference is valid
>>>>>>>>>>         if (serviceReference != null)
>>>>>>>>>>         {
>>>>>>>>>>             eventAdmin = (EventAdmin)
>>>>>>>>>> bundleContext.getService(serviceReference);
>>>>>>>>>>         }
>>>>>>>>>>
>>>>>>>>>> But inside the if-loop I'm getting an error:
>>>>>>>>>>
>>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>>>
>>>>>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>>>>>> cannot
>>>>>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>>>>>
>>>>>>>>>> I'm a little bit confused now, because I thought that the Apache
>>>>>>>>>> Felix
>>>>>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>>>>>> and
>>>>>>>>> getting closer every release.
>>>>>>>>>
>>>>>>>>>  Isn't it
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> possible to mix equinox components (my bundle) with felix
>>>>>>>>>> components
>>>>>>>>>> (the
>>>>>>>>>> eventadmin service)?
>>>>>>>>>>
>>>>>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> Such a scenario should work, but you didn't provide enough
>>>>>>>>> information
>>>>>>>>> to
>>>>>>>>> say why it isn't. Perhaps you could show us your bundle's manifest
>>>>>>>>> file
>>>>>>>>> as
>>>>>>>>> well as a "jar tf" of the bundle.
>>>>>>>>>
>>>>>>>>> ->    richard
>>>>>>>>>
>>>>>>>>>  BR,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Markus
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 9/15/09 16:53, Markus Michel wrote:
> Hi!
>
> After upgrading to the new framework version 2.0.0 the same error occurred
> again, although the event service is still listed in the boot delegation
> property. Is there another way to solve my problem? Otherwise I probably
> have to continue using the old framework version ...
>
> BTW: What happened to the shell command services? Why it isn't included in
> the new version?
>    

It was refactored into the "inspect" command, which allows you to 
inspect the various capabilities and requirements, instead of having 
different commands for each ones. So, now you can do:

     inspect service capability <bundle-id> ...

or for short:

     inspect s c <bundle-id> ...

Likewise you can do:

     inspect service requirement <bundle-id> ... (or inspect s r)

-> richard

> BR,
>
> Markus
>
> 2009/7/15 Markus Michel<ma...@uni-duesseldorf.de>
>
>    
>> I would like to thank you for your help. After adding my services and the
>> event admin service to the boot delegation property, my environment was
>> working fine. :-)
>>
>>
>> BR,
>>
>> Markus
>>
>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>
>>      
>>> I believe the issue is that you are exporting from the system bundle, plus
>>> your bundle contains the same packages as you are exporting from the system
>>> bundle.
>>>
>>> So, you have to make sure only one copy is being used. I think your bundle
>>> was only exporting osgiServices.vehiclePushService. This means your bundle
>>> will always get its own copy, since it doesn't import the package too. If
>>> you import it too, then it would likely get wired to the system bundle's
>>> export, since resolved packages are preferred and the system bundle will be
>>> resolved first.
>>>
>>> As I mention in my other message, one way around this is in your embedded
>>> mode, add the shared packages to the boot delegation property to get them to
>>> always load from the class path. Note, if you are using trunk you will need
>>> to set a new property to boot delegate to the app class loader
>>> (org.osgi.framework.bundle.parent=app).
>>>
>>> ->  richard
>>>
>>> On 7/14/09 3:55 PM, Markus Michel wrote:
>>>
>>>        
>>>> Some weeks ago I tried to use this instructions to get my embedded felix
>>>> instance working, but it didn't worked. Afterwards some guy on
>>>> stackover.comgave me the hint to put the whole package to the system
>>>>
>>>> packages path. If I
>>>> strictly follow the wiki entry the line within my intialization block
>>>> should
>>>> look like:
>>>>
>>>>          configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>> "osgiServices.vehiclePushService; version=1.0.0");
>>>>
>>>> <path to the service includings it's implementation within the host app>
>>>>
>>>> But if the entry only contains this value, I'm getting the class loading
>>>> error again.
>>>>
>>>> Sorry, but I think that I have some problems in understanding the
>>>> explanations on that site completely. As far as I understood it all
>>>> packages
>>>> within this property should be executed by the some class loader, which
>>>> is
>>>> used for the system bundle and all other bundles. Therefore there
>>>> shouldn't
>>>> occur any class loading problems, when the bundle tries to access the
>>>> service. Am I wrong? Maybe you can give me a more detailed explanation
>>>> ...
>>>>
>>>> Unfortunately the felix environment has to run in the embedded mode
>>>> within
>>>> my program, because I want to run and control several osgi instances at
>>>> once. I hope that we will be able to solve my problem ...
>>>>
>>>> BR,
>>>>
>>>> Markus
>>>>
>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>
>>>>
>>>>
>>>>          
>>>>> You should read:
>>>>>
>>>>>
>>>>>
>>>>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>>>>
>>>>> It gives some pointers to running with an embedded framework instance.
>>>>> In
>>>>> short, your app and all bundles should go through the class path (i.e.,
>>>>> system bundle) for any packages shared between the host app and the
>>>>> bundles.
>>>>>
>>>>> To make sure this happens, you could actually put the host/bundle shared
>>>>> packages on the boot class path property to make sure everyone gets the
>>>>> same
>>>>> ones, no matter how the bundles are wired internally. This at least has
>>>>> the
>>>>> benefit that your bundles will work properly when not used in the
>>>>> embedded
>>>>> situation.
>>>>>
>>>>> I knew there was more than what met the eye here. :-)
>>>>>
>>>>> Embedded mode is alluring to a lot of people coming to OSGi, but there
>>>>> are
>>>>> lots of hidden issues with it, so better to avoid it if you can.
>>>>>
>>>>> ->   richard
>>>>>
>>>>>
>>>>> On 7/14/09 1:53 PM, Markus Michel wrote:
>>>>>
>>>>>
>>>>>
>>>>>            
>>>>>> You are right. If I remove that line, I'm able to load the event admin
>>>>>> service. But the problem is that I cannot remove it, because other
>>>>>> parts
>>>>>> of
>>>>>> my program depends on that information: My "vehiclePushService" is
>>>>>> mostly
>>>>>> implemented (and started) within the host application but some parts
>>>>>> are
>>>>>> implemented within the bundle. If I do not add "vehiclePushService" to
>>>>>> that
>>>>>> line, I'm getting the class loading exception
>>>>>>
>>>>>> java.lang.ClassCastException:
>>>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast
>>>>>> to
>>>>>> osgiServices.vehiclePushService.VehiclePushService
>>>>>>
>>>>>> , when the bundle tries to use the service. Maybe I have to add the
>>>>>> event
>>>>>> admin service to that line, too?!?
>>>>>>
>>>>>> BR,
>>>>>>
>>>>>> Markus
>>>>>>
>>>>>> -----
>>>>>>
>>>>>> Markus,
>>>>>>
>>>>>> Yes, I believe your embedded configuration is the issue. Why are you
>>>>>> doing
>>>>>> this:
>>>>>>
>>>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>>> "osgiServices.vehicleCommunicationService;
>>>>>> osgiServices.vehiclePushService;
>>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>>
>>>>>> ?
>>>>>>
>>>>>> It seems like this is incorrect, since your bundle contains these
>>>>>> packages.
>>>>>> Try removing this and see what happens.
>>>>>>
>>>>>> Hi Richard!
>>>>>>
>>>>>> Here's the bundle which tries to use the felix event admin service. If
>>>>>> you
>>>>>> wish I can provide you the sources of the bundle, too.
>>>>>>
>>>>>> If you want to use the bundle, you have to load the following bundles:
>>>>>>
>>>>>> org.apache.felix.shell-1.2.0.jar
>>>>>> org.apache.felix.shell.tui-1.2.0.jar
>>>>>> org.apache.felix.eventadmin-1.0.0.jar
>>>>>> VehiclePushService_1.0.0.jar
>>>>>>
>>>>>> Some minutes ago I noticed that the bundle can be loaded successfully
>>>>>> if
>>>>>> you
>>>>>> run it directly from a command-line-based felix instance. The error
>>>>>> only
>>>>>> occures if you try to run it
>>>>>> as an embedded version. Very confusing.
>>>>>>
>>>>>> Maybe there's something wrong with the configuration of my felix
>>>>>> instance:
>>>>>>
>>>>>>      private void initialize()
>>>>>>      {
>>>>>>          // create new map for storing the felix configuration
>>>>>> properties
>>>>>>          configMap = new HashMap<String, Object>();
>>>>>>
>>>>>>          // export the host provided service interface package
>>>>>>          configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>>> "osgiServices.vehicleCommunicationService;
>>>>>> osgiServices.vehiclePushService;
>>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>>
>>>>>>          // add autoactivator that specifies all services that shall be
>>>>>> loaded together with the system bundle
>>>>>>          List<Object>    list = new ArrayList<Object>();
>>>>>>          list.add(new AutoActivator(configMap));
>>>>>>
>>>>>>          // create service activators
>>>>>>          vehicleCommunicationServiceActivator = new
>>>>>> VehicleCommunicationServiceActivator(connection);
>>>>>>          list.add(vehicleCommunicationServiceActivator);
>>>>>>
>>>>>>          vehiclePushServiceActivator = new
>>>>>> VehiclePushServiceActivator();
>>>>>>          list.add(vehiclePushServiceActivator);
>>>>>>
>>>>>>          // add service activators to felix instance
>>>>>>          configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>>>>> list);
>>>>>>
>>>>>>          // set felix-cache folder
>>>>>>          configMap.put("org.osgi.framework.storage", "felix-cache/" +
>>>>>> id);
>>>>>>      }
>>>>>>
>>>>>>
>>>>>> BR,
>>>>>>
>>>>>> Markus
>>>>>>
>>>>>> -------
>>>>>>
>>>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> I don't see anything that immediately looks incorrect. If you want to
>>>>>>> send
>>>>>>> me your bundle (privately) with the steps to reproduce, I will look at
>>>>>>> it.
>>>>>>>
>>>>>>> ->    richard
>>>>>>>
>>>>>>>
>>>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>>>> Hi Richard!
>>>>>>>>
>>>>>>>> Of course I can provide more informations. The manifest file of the
>>>>>>>> bundle
>>>>>>>> looks like this:
>>>>>>>>
>>>>>>>> Manifest-Version: 1.0
>>>>>>>> Bundle-ManifestVersion: 2
>>>>>>>> Bundle-Name: VehiclePushService
>>>>>>>> Bundle-SymbolicName: VehiclePushService
>>>>>>>> Bundle-Version: 1.0.0
>>>>>>>> Bundle-Activator: vehiclePushService.Activator
>>>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>>>>>   org.osgi.service.event;version="1.1.0",
>>>>>>>>   vehiclePushService
>>>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>>>>>> Bundle-ClassPath: .,
>>>>>>>>   vehiclePushService.jar
>>>>>>>> Export-Package:
>>>>>>>>   osgiServices.vehiclePushService,
>>>>>>>>   vehiclePushService
>>>>>>>>
>>>>>>>> The content of the bundle looks as follows:
>>>>>>>>
>>>>>>>> META-INF/
>>>>>>>> META-INF/MANIFEST.MF
>>>>>>>> hostApplication/
>>>>>>>> hostApplication/vehiclePushService/
>>>>>>>> osgiFramework/
>>>>>>>> osgiFramework/vehiclePushService/
>>>>>>>> vehiclePushService/
>>>>>>>> META-INF/.classpath
>>>>>>>> META-INF/.project
>>>>>>>> vehiclePushService.jar
>>>>>>>> vehiclePushService/Activator.class
>>>>>>>> vehiclePushService/OSGiPosition2D.class
>>>>>>>> vehiclePushService/OSGiVehicle.class
>>>>>>>> vehiclePushService/OSGiVehiclePushService.class
>>>>>>>> vehiclePushService/VehicleListener.class
>>>>>>>> vehiclePushService/VehiclePushEvent.class
>>>>>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>>>>>
>>>>>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>>>>>> referenced
>>>>>>>> I
>>>>>>>> think that the bundles currently uses the equinox implementation of
>>>>>>>> the
>>>>>>>> eventadmin service. Later on I will try to load the equinox
>>>>>>>> eventadmin
>>>>>>>> service instead
>>>>>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>>>>>> bundle
>>>>>>>> ...
>>>>>>>>
>>>>>>>> BR,
>>>>>>>>
>>>>>>>> Markus
>>>>>>>>
>>>>>>>>
>>>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>>> Hi there!
>>>>>>>>>>
>>>>>>>>>> Today I wanted to add the eventadmin service to my OSGi
>>>>>>>>>> environment.
>>>>>>>>>> Therefore I extended the import block of my bundle, which is
>>>>>>>>>> created
>>>>>>>>>> within
>>>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>>>>>> loading
>>>>>>>>>> the
>>>>>>>>>> service I tried to access it by running the following command:
>>>>>>>>>>
>>>>>>>>>>          // get service reference to event admin service
>>>>>>>>>>          serviceReference =
>>>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>>>>>
>>>>>>>>>>          // check if service reference is valid
>>>>>>>>>>          if (serviceReference != null)
>>>>>>>>>>          {
>>>>>>>>>>              eventAdmin = (EventAdmin)
>>>>>>>>>> bundleContext.getService(serviceReference);
>>>>>>>>>>          }
>>>>>>>>>>
>>>>>>>>>> But inside the if-loop I'm getting an error:
>>>>>>>>>>
>>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>>>
>>>>>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>>>>>> cannot
>>>>>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>>>>>
>>>>>>>>>> I'm a little bit confused now, because I thought that the Apache
>>>>>>>>>> Felix
>>>>>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>>>>>> and
>>>>>>>>> getting closer every release.
>>>>>>>>>
>>>>>>>>>   Isn't it
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>>> possible to mix equinox components (my bundle) with felix
>>>>>>>>>> components
>>>>>>>>>> (the
>>>>>>>>>> eventadmin service)?
>>>>>>>>>>
>>>>>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>> Such a scenario should work, but you didn't provide enough
>>>>>>>>> information
>>>>>>>>> to
>>>>>>>>> say why it isn't. Perhaps you could show us your bundle's manifest
>>>>>>>>> file
>>>>>>>>> as
>>>>>>>>> well as a "jar tf" of the bundle.
>>>>>>>>>
>>>>>>>>> ->     richard
>>>>>>>>>
>>>>>>>>>   BR,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>>> Markus
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>>                
>>>>>>
>>>>>>              
>>>>>            
>>>>
>>>>          
>>>        
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
Hi!

After upgrading to the new framework version 2.0.0 the same error occurred
again, although the event service is still listed in the boot delegation
property. Is there another way to solve my problem? Otherwise I probably
have to continue using the old framework version ...

BTW: What happened to the shell command services? Why it isn't included in
the new version?

BR,

Markus

2009/7/15 Markus Michel <ma...@uni-duesseldorf.de>

> I would like to thank you for your help. After adding my services and the
> event admin service to the boot delegation property, my environment was
> working fine. :-)
>
>
> BR,
>
> Markus
>
> 2009/7/14 Richard S. Hall <he...@ungoverned.org>
>
>> I believe the issue is that you are exporting from the system bundle, plus
>> your bundle contains the same packages as you are exporting from the system
>> bundle.
>>
>> So, you have to make sure only one copy is being used. I think your bundle
>> was only exporting osgiServices.vehiclePushService. This means your bundle
>> will always get its own copy, since it doesn't import the package too. If
>> you import it too, then it would likely get wired to the system bundle's
>> export, since resolved packages are preferred and the system bundle will be
>> resolved first.
>>
>> As I mention in my other message, one way around this is in your embedded
>> mode, add the shared packages to the boot delegation property to get them to
>> always load from the class path. Note, if you are using trunk you will need
>> to set a new property to boot delegate to the app class loader
>> (org.osgi.framework.bundle.parent=app).
>>
>> -> richard
>>
>> On 7/14/09 3:55 PM, Markus Michel wrote:
>>
>>> Some weeks ago I tried to use this instructions to get my embedded felix
>>> instance working, but it didn't worked. Afterwards some guy on
>>> stackover.comgave me the hint to put the whole package to the system
>>>
>>> packages path. If I
>>> strictly follow the wiki entry the line within my intialization block
>>> should
>>> look like:
>>>
>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>> "osgiServices.vehiclePushService; version=1.0.0");
>>>
>>> <path to the service includings it's implementation within the host app>
>>>
>>> But if the entry only contains this value, I'm getting the class loading
>>> error again.
>>>
>>> Sorry, but I think that I have some problems in understanding the
>>> explanations on that site completely. As far as I understood it all
>>> packages
>>> within this property should be executed by the some class loader, which
>>> is
>>> used for the system bundle and all other bundles. Therefore there
>>> shouldn't
>>> occur any class loading problems, when the bundle tries to access the
>>> service. Am I wrong? Maybe you can give me a more detailed explanation
>>> ...
>>>
>>> Unfortunately the felix environment has to run in the embedded mode
>>> within
>>> my program, because I want to run and control several osgi instances at
>>> once. I hope that we will be able to solve my problem ...
>>>
>>> BR,
>>>
>>> Markus
>>>
>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>
>>>
>>>
>>>> You should read:
>>>>
>>>>
>>>>
>>>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>>>
>>>> It gives some pointers to running with an embedded framework instance.
>>>> In
>>>> short, your app and all bundles should go through the class path (i.e.,
>>>> system bundle) for any packages shared between the host app and the
>>>> bundles.
>>>>
>>>> To make sure this happens, you could actually put the host/bundle shared
>>>> packages on the boot class path property to make sure everyone gets the
>>>> same
>>>> ones, no matter how the bundles are wired internally. This at least has
>>>> the
>>>> benefit that your bundles will work properly when not used in the
>>>> embedded
>>>> situation.
>>>>
>>>> I knew there was more than what met the eye here. :-)
>>>>
>>>> Embedded mode is alluring to a lot of people coming to OSGi, but there
>>>> are
>>>> lots of hidden issues with it, so better to avoid it if you can.
>>>>
>>>> ->  richard
>>>>
>>>>
>>>> On 7/14/09 1:53 PM, Markus Michel wrote:
>>>>
>>>>
>>>>
>>>>> You are right. If I remove that line, I'm able to load the event admin
>>>>> service. But the problem is that I cannot remove it, because other
>>>>> parts
>>>>> of
>>>>> my program depends on that information: My "vehiclePushService" is
>>>>> mostly
>>>>> implemented (and started) within the host application but some parts
>>>>> are
>>>>> implemented within the bundle. If I do not add "vehiclePushService" to
>>>>> that
>>>>> line, I'm getting the class loading exception
>>>>>
>>>>> java.lang.ClassCastException:
>>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast
>>>>> to
>>>>> osgiServices.vehiclePushService.VehiclePushService
>>>>>
>>>>> , when the bundle tries to use the service. Maybe I have to add the
>>>>> event
>>>>> admin service to that line, too?!?
>>>>>
>>>>> BR,
>>>>>
>>>>> Markus
>>>>>
>>>>> -----
>>>>>
>>>>> Markus,
>>>>>
>>>>> Yes, I believe your embedded configuration is the issue. Why are you
>>>>> doing
>>>>> this:
>>>>>
>>>>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>> "osgiServices.vehicleCommunicationService;
>>>>> osgiServices.vehiclePushService;
>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>
>>>>> ?
>>>>>
>>>>> It seems like this is incorrect, since your bundle contains these
>>>>> packages.
>>>>> Try removing this and see what happens.
>>>>>
>>>>> Hi Richard!
>>>>>
>>>>> Here's the bundle which tries to use the felix event admin service. If
>>>>> you
>>>>> wish I can provide you the sources of the bundle, too.
>>>>>
>>>>> If you want to use the bundle, you have to load the following bundles:
>>>>>
>>>>> org.apache.felix.shell-1.2.0.jar
>>>>> org.apache.felix.shell.tui-1.2.0.jar
>>>>> org.apache.felix.eventadmin-1.0.0.jar
>>>>> VehiclePushService_1.0.0.jar
>>>>>
>>>>> Some minutes ago I noticed that the bundle can be loaded successfully
>>>>> if
>>>>> you
>>>>> run it directly from a command-line-based felix instance. The error
>>>>> only
>>>>> occures if you try to run it
>>>>> as an embedded version. Very confusing.
>>>>>
>>>>> Maybe there's something wrong with the configuration of my felix
>>>>> instance:
>>>>>
>>>>>     private void initialize()
>>>>>     {
>>>>>         // create new map for storing the felix configuration
>>>>> properties
>>>>>         configMap = new HashMap<String, Object>();
>>>>>
>>>>>         // export the host provided service interface package
>>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>>> "osgiServices.vehicleCommunicationService;
>>>>> osgiServices.vehiclePushService;
>>>>> vehiclePushService; vehicleCommunicationService");
>>>>>
>>>>>         // add autoactivator that specifies all services that shall be
>>>>> loaded together with the system bundle
>>>>>         List<Object>   list = new ArrayList<Object>();
>>>>>         list.add(new AutoActivator(configMap));
>>>>>
>>>>>         // create service activators
>>>>>         vehicleCommunicationServiceActivator = new
>>>>> VehicleCommunicationServiceActivator(connection);
>>>>>         list.add(vehicleCommunicationServiceActivator);
>>>>>
>>>>>         vehiclePushServiceActivator = new
>>>>> VehiclePushServiceActivator();
>>>>>         list.add(vehiclePushServiceActivator);
>>>>>
>>>>>         // add service activators to felix instance
>>>>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>>>> list);
>>>>>
>>>>>         // set felix-cache folder
>>>>>         configMap.put("org.osgi.framework.storage", "felix-cache/" +
>>>>> id);
>>>>>     }
>>>>>
>>>>>
>>>>> BR,
>>>>>
>>>>> Markus
>>>>>
>>>>> -------
>>>>>
>>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> I don't see anything that immediately looks incorrect. If you want to
>>>>>> send
>>>>>> me your bundle (privately) with the steps to reproduce, I will look at
>>>>>> it.
>>>>>>
>>>>>> ->   richard
>>>>>>
>>>>>>
>>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi Richard!
>>>>>>>
>>>>>>> Of course I can provide more informations. The manifest file of the
>>>>>>> bundle
>>>>>>> looks like this:
>>>>>>>
>>>>>>> Manifest-Version: 1.0
>>>>>>> Bundle-ManifestVersion: 2
>>>>>>> Bundle-Name: VehiclePushService
>>>>>>> Bundle-SymbolicName: VehiclePushService
>>>>>>> Bundle-Version: 1.0.0
>>>>>>> Bundle-Activator: vehiclePushService.Activator
>>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>>>>  org.osgi.service.event;version="1.1.0",
>>>>>>>  vehiclePushService
>>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>>>>> Bundle-ClassPath: .,
>>>>>>>  vehiclePushService.jar
>>>>>>> Export-Package:
>>>>>>>  osgiServices.vehiclePushService,
>>>>>>>  vehiclePushService
>>>>>>>
>>>>>>> The content of the bundle looks as follows:
>>>>>>>
>>>>>>> META-INF/
>>>>>>> META-INF/MANIFEST.MF
>>>>>>> hostApplication/
>>>>>>> hostApplication/vehiclePushService/
>>>>>>> osgiFramework/
>>>>>>> osgiFramework/vehiclePushService/
>>>>>>> vehiclePushService/
>>>>>>> META-INF/.classpath
>>>>>>> META-INF/.project
>>>>>>> vehiclePushService.jar
>>>>>>> vehiclePushService/Activator.class
>>>>>>> vehiclePushService/OSGiPosition2D.class
>>>>>>> vehiclePushService/OSGiVehicle.class
>>>>>>> vehiclePushService/OSGiVehiclePushService.class
>>>>>>> vehiclePushService/VehicleListener.class
>>>>>>> vehiclePushService/VehiclePushEvent.class
>>>>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>>>>
>>>>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>>>>> referenced
>>>>>>> I
>>>>>>> think that the bundles currently uses the equinox implementation of
>>>>>>> the
>>>>>>> eventadmin service. Later on I will try to load the equinox
>>>>>>> eventadmin
>>>>>>> service instead
>>>>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>>>>> bundle
>>>>>>> ...
>>>>>>>
>>>>>>> BR,
>>>>>>>
>>>>>>> Markus
>>>>>>>
>>>>>>>
>>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hi there!
>>>>>>>>>
>>>>>>>>> Today I wanted to add the eventadmin service to my OSGi
>>>>>>>>> environment.
>>>>>>>>> Therefore I extended the import block of my bundle, which is
>>>>>>>>> created
>>>>>>>>> within
>>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>>>>> loading
>>>>>>>>> the
>>>>>>>>> service I tried to access it by running the following command:
>>>>>>>>>
>>>>>>>>>         // get service reference to event admin service
>>>>>>>>>         serviceReference =
>>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>>>>
>>>>>>>>>         // check if service reference is valid
>>>>>>>>>         if (serviceReference != null)
>>>>>>>>>         {
>>>>>>>>>             eventAdmin = (EventAdmin)
>>>>>>>>> bundleContext.getService(serviceReference);
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>> But inside the if-loop I'm getting an error:
>>>>>>>>>
>>>>>>>>> java.lang.ClassCastException:
>>>>>>>>>
>>>>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>>>>> cannot
>>>>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>>>>
>>>>>>>>> I'm a little bit confused now, because I thought that the Apache
>>>>>>>>> Felix
>>>>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>>>>> and
>>>>>>>> getting closer every release.
>>>>>>>>
>>>>>>>>  Isn't it
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> possible to mix equinox components (my bundle) with felix
>>>>>>>>> components
>>>>>>>>> (the
>>>>>>>>> eventadmin service)?
>>>>>>>>>
>>>>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Such a scenario should work, but you didn't provide enough
>>>>>>>> information
>>>>>>>> to
>>>>>>>> say why it isn't. Perhaps you could show us your bundle's manifest
>>>>>>>> file
>>>>>>>> as
>>>>>>>> well as a "jar tf" of the bundle.
>>>>>>>>
>>>>>>>> ->    richard
>>>>>>>>
>>>>>>>>  BR,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Markus
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>

Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
I would like to thank you for your help. After adding my services and the
event admin service to the boot delegation property, my environment was
working fine. :-)

BR,

Markus

2009/7/14 Richard S. Hall <he...@ungoverned.org>

> I believe the issue is that you are exporting from the system bundle, plus
> your bundle contains the same packages as you are exporting from the system
> bundle.
>
> So, you have to make sure only one copy is being used. I think your bundle
> was only exporting osgiServices.vehiclePushService. This means your bundle
> will always get its own copy, since it doesn't import the package too. If
> you import it too, then it would likely get wired to the system bundle's
> export, since resolved packages are preferred and the system bundle will be
> resolved first.
>
> As I mention in my other message, one way around this is in your embedded
> mode, add the shared packages to the boot delegation property to get them to
> always load from the class path. Note, if you are using trunk you will need
> to set a new property to boot delegate to the app class loader
> (org.osgi.framework.bundle.parent=app).
>
> -> richard
>
> On 7/14/09 3:55 PM, Markus Michel wrote:
>
>> Some weeks ago I tried to use this instructions to get my embedded felix
>> instance working, but it didn't worked. Afterwards some guy on
>> stackover.comgave me the hint to put the whole package to the system
>>
>> packages path. If I
>> strictly follow the wiki entry the line within my intialization block
>> should
>> look like:
>>
>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> "osgiServices.vehiclePushService; version=1.0.0");
>>
>> <path to the service includings it's implementation within the host app>
>>
>> But if the entry only contains this value, I'm getting the class loading
>> error again.
>>
>> Sorry, but I think that I have some problems in understanding the
>> explanations on that site completely. As far as I understood it all
>> packages
>> within this property should be executed by the some class loader, which is
>> used for the system bundle and all other bundles. Therefore there
>> shouldn't
>> occur any class loading problems, when the bundle tries to access the
>> service. Am I wrong? Maybe you can give me a more detailed explanation ...
>>
>> Unfortunately the felix environment has to run in the embedded mode within
>> my program, because I want to run and control several osgi instances at
>> once. I hope that we will be able to solve my problem ...
>>
>> BR,
>>
>> Markus
>>
>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>
>>
>>
>>> You should read:
>>>
>>>
>>>
>>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>>
>>> It gives some pointers to running with an embedded framework instance. In
>>> short, your app and all bundles should go through the class path (i.e.,
>>> system bundle) for any packages shared between the host app and the
>>> bundles.
>>>
>>> To make sure this happens, you could actually put the host/bundle shared
>>> packages on the boot class path property to make sure everyone gets the
>>> same
>>> ones, no matter how the bundles are wired internally. This at least has
>>> the
>>> benefit that your bundles will work properly when not used in the
>>> embedded
>>> situation.
>>>
>>> I knew there was more than what met the eye here. :-)
>>>
>>> Embedded mode is alluring to a lot of people coming to OSGi, but there
>>> are
>>> lots of hidden issues with it, so better to avoid it if you can.
>>>
>>> ->  richard
>>>
>>>
>>> On 7/14/09 1:53 PM, Markus Michel wrote:
>>>
>>>
>>>
>>>> You are right. If I remove that line, I'm able to load the event admin
>>>> service. But the problem is that I cannot remove it, because other parts
>>>> of
>>>> my program depends on that information: My "vehiclePushService" is
>>>> mostly
>>>> implemented (and started) within the host application but some parts are
>>>> implemented within the bundle. If I do not add "vehiclePushService" to
>>>> that
>>>> line, I'm getting the class loading exception
>>>>
>>>> java.lang.ClassCastException:
>>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast to
>>>> osgiServices.vehiclePushService.VehiclePushService
>>>>
>>>> , when the bundle tries to use the service. Maybe I have to add the
>>>> event
>>>> admin service to that line, too?!?
>>>>
>>>> BR,
>>>>
>>>> Markus
>>>>
>>>> -----
>>>>
>>>> Markus,
>>>>
>>>> Yes, I believe your embedded configuration is the issue. Why are you
>>>> doing
>>>> this:
>>>>
>>>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>> "osgiServices.vehicleCommunicationService;
>>>> osgiServices.vehiclePushService;
>>>> vehiclePushService; vehicleCommunicationService");
>>>>
>>>> ?
>>>>
>>>> It seems like this is incorrect, since your bundle contains these
>>>> packages.
>>>> Try removing this and see what happens.
>>>>
>>>> Hi Richard!
>>>>
>>>> Here's the bundle which tries to use the felix event admin service. If
>>>> you
>>>> wish I can provide you the sources of the bundle, too.
>>>>
>>>> If you want to use the bundle, you have to load the following bundles:
>>>>
>>>> org.apache.felix.shell-1.2.0.jar
>>>> org.apache.felix.shell.tui-1.2.0.jar
>>>> org.apache.felix.eventadmin-1.0.0.jar
>>>> VehiclePushService_1.0.0.jar
>>>>
>>>> Some minutes ago I noticed that the bundle can be loaded successfully if
>>>> you
>>>> run it directly from a command-line-based felix instance. The error only
>>>> occures if you try to run it
>>>> as an embedded version. Very confusing.
>>>>
>>>> Maybe there's something wrong with the configuration of my felix
>>>> instance:
>>>>
>>>>     private void initialize()
>>>>     {
>>>>         // create new map for storing the felix configuration properties
>>>>         configMap = new HashMap<String, Object>();
>>>>
>>>>         // export the host provided service interface package
>>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>>> "osgiServices.vehicleCommunicationService;
>>>> osgiServices.vehiclePushService;
>>>> vehiclePushService; vehicleCommunicationService");
>>>>
>>>>         // add autoactivator that specifies all services that shall be
>>>> loaded together with the system bundle
>>>>         List<Object>   list = new ArrayList<Object>();
>>>>         list.add(new AutoActivator(configMap));
>>>>
>>>>         // create service activators
>>>>         vehicleCommunicationServiceActivator = new
>>>> VehicleCommunicationServiceActivator(connection);
>>>>         list.add(vehicleCommunicationServiceActivator);
>>>>
>>>>         vehiclePushServiceActivator = new VehiclePushServiceActivator();
>>>>         list.add(vehiclePushServiceActivator);
>>>>
>>>>         // add service activators to felix instance
>>>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
>>>> list);
>>>>
>>>>         // set felix-cache folder
>>>>         configMap.put("org.osgi.framework.storage", "felix-cache/" +
>>>> id);
>>>>     }
>>>>
>>>>
>>>> BR,
>>>>
>>>> Markus
>>>>
>>>> -------
>>>>
>>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> I don't see anything that immediately looks incorrect. If you want to
>>>>> send
>>>>> me your bundle (privately) with the steps to reproduce, I will look at
>>>>> it.
>>>>>
>>>>> ->   richard
>>>>>
>>>>>
>>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi Richard!
>>>>>>
>>>>>> Of course I can provide more informations. The manifest file of the
>>>>>> bundle
>>>>>> looks like this:
>>>>>>
>>>>>> Manifest-Version: 1.0
>>>>>> Bundle-ManifestVersion: 2
>>>>>> Bundle-Name: VehiclePushService
>>>>>> Bundle-SymbolicName: VehiclePushService
>>>>>> Bundle-Version: 1.0.0
>>>>>> Bundle-Activator: vehiclePushService.Activator
>>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>>>  org.osgi.service.event;version="1.1.0",
>>>>>>  vehiclePushService
>>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>>>> Bundle-ClassPath: .,
>>>>>>  vehiclePushService.jar
>>>>>> Export-Package:
>>>>>>  osgiServices.vehiclePushService,
>>>>>>  vehiclePushService
>>>>>>
>>>>>> The content of the bundle looks as follows:
>>>>>>
>>>>>> META-INF/
>>>>>> META-INF/MANIFEST.MF
>>>>>> hostApplication/
>>>>>> hostApplication/vehiclePushService/
>>>>>> osgiFramework/
>>>>>> osgiFramework/vehiclePushService/
>>>>>> vehiclePushService/
>>>>>> META-INF/.classpath
>>>>>> META-INF/.project
>>>>>> vehiclePushService.jar
>>>>>> vehiclePushService/Activator.class
>>>>>> vehiclePushService/OSGiPosition2D.class
>>>>>> vehiclePushService/OSGiVehicle.class
>>>>>> vehiclePushService/OSGiVehiclePushService.class
>>>>>> vehiclePushService/VehicleListener.class
>>>>>> vehiclePushService/VehiclePushEvent.class
>>>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>>>
>>>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>>>> referenced
>>>>>> I
>>>>>> think that the bundles currently uses the equinox implementation of
>>>>>> the
>>>>>> eventadmin service. Later on I will try to load the equinox eventadmin
>>>>>> service instead
>>>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>>>> bundle
>>>>>> ...
>>>>>>
>>>>>> BR,
>>>>>>
>>>>>> Markus
>>>>>>
>>>>>>
>>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi there!
>>>>>>>>
>>>>>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>>>>>> Therefore I extended the import block of my bundle, which is created
>>>>>>>> within
>>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>>>> loading
>>>>>>>> the
>>>>>>>> service I tried to access it by running the following command:
>>>>>>>>
>>>>>>>>         // get service reference to event admin service
>>>>>>>>         serviceReference =
>>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>>>
>>>>>>>>         // check if service reference is valid
>>>>>>>>         if (serviceReference != null)
>>>>>>>>         {
>>>>>>>>             eventAdmin = (EventAdmin)
>>>>>>>> bundleContext.getService(serviceReference);
>>>>>>>>         }
>>>>>>>>
>>>>>>>> But inside the if-loop I'm getting an error:
>>>>>>>>
>>>>>>>> java.lang.ClassCastException:
>>>>>>>>
>>>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>>>> cannot
>>>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>>>
>>>>>>>> I'm a little bit confused now, because I thought that the Apache
>>>>>>>> Felix
>>>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>>>> and
>>>>>>> getting closer every release.
>>>>>>>
>>>>>>>  Isn't it
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> possible to mix equinox components (my bundle) with felix components
>>>>>>>> (the
>>>>>>>> eventadmin service)?
>>>>>>>>
>>>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Such a scenario should work, but you didn't provide enough
>>>>>>> information
>>>>>>> to
>>>>>>> say why it isn't. Perhaps you could show us your bundle's manifest
>>>>>>> file
>>>>>>> as
>>>>>>> well as a "jar tf" of the bundle.
>>>>>>>
>>>>>>> ->    richard
>>>>>>>
>>>>>>>  BR,
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Markus
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>

Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I believe the issue is that you are exporting from the system bundle, 
plus your bundle contains the same packages as you are exporting from 
the system bundle.

So, you have to make sure only one copy is being used. I think your 
bundle was only exporting osgiServices.vehiclePushService. This means 
your bundle will always get its own copy, since it doesn't import the 
package too. If you import it too, then it would likely get wired to the 
system bundle's export, since resolved packages are preferred and the 
system bundle will be resolved first.

As I mention in my other message, one way around this is in your 
embedded mode, add the shared packages to the boot delegation property 
to get them to always load from the class path. Note, if you are using 
trunk you will need to set a new property to boot delegate to the app 
class loader (org.osgi.framework.bundle.parent=app).

-> richard

On 7/14/09 3:55 PM, Markus Michel wrote:
> Some weeks ago I tried to use this instructions to get my embedded felix
> instance working, but it didn't worked. Afterwards some guy on
> stackover.comgave me the hint to put the whole package to the system
> packages path. If I
> strictly follow the wiki entry the line within my intialization block should
> look like:
>
>          configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> "osgiServices.vehiclePushService; version=1.0.0");
>
> <path to the service includings it's implementation within the host app>
>
> But if the entry only contains this value, I'm getting the class loading
> error again.
>
> Sorry, but I think that I have some problems in understanding the
> explanations on that site completely. As far as I understood it all packages
> within this property should be executed by the some class loader, which is
> used for the system bundle and all other bundles. Therefore there shouldn't
> occur any class loading problems, when the bundle tries to access the
> service. Am I wrong? Maybe you can give me a more detailed explanation ...
>
> Unfortunately the felix environment has to run in the embedded mode within
> my program, because I want to run and control several osgi instances at
> once. I hope that we will be able to solve my problem ...
>
> BR,
>
> Markus
>
> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>
>    
>> You should read:
>>
>>
>> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>>
>> It gives some pointers to running with an embedded framework instance. In
>> short, your app and all bundles should go through the class path (i.e.,
>> system bundle) for any packages shared between the host app and the bundles.
>>
>> To make sure this happens, you could actually put the host/bundle shared
>> packages on the boot class path property to make sure everyone gets the same
>> ones, no matter how the bundles are wired internally. This at least has the
>> benefit that your bundles will work properly when not used in the embedded
>> situation.
>>
>> I knew there was more than what met the eye here. :-)
>>
>> Embedded mode is alluring to a lot of people coming to OSGi, but there are
>> lots of hidden issues with it, so better to avoid it if you can.
>>
>> ->  richard
>>
>>
>> On 7/14/09 1:53 PM, Markus Michel wrote:
>>
>>      
>>> You are right. If I remove that line, I'm able to load the event admin
>>> service. But the problem is that I cannot remove it, because other parts
>>> of
>>> my program depends on that information: My "vehiclePushService" is mostly
>>> implemented (and started) within the host application but some parts are
>>> implemented within the bundle. If I do not add "vehiclePushService" to
>>> that
>>> line, I'm getting the class loading exception
>>>
>>> java.lang.ClassCastException:
>>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast to
>>> osgiServices.vehiclePushService.VehiclePushService
>>>
>>> , when the bundle tries to use the service. Maybe I have to add the event
>>> admin service to that line, too?!?
>>>
>>> BR,
>>>
>>> Markus
>>>
>>> -----
>>>
>>> Markus,
>>>
>>> Yes, I believe your embedded configuration is the issue. Why are you doing
>>> this:
>>>
>>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>> "osgiServices.vehicleCommunicationService;
>>> osgiServices.vehiclePushService;
>>> vehiclePushService; vehicleCommunicationService");
>>>
>>> ?
>>>
>>> It seems like this is incorrect, since your bundle contains these
>>> packages.
>>> Try removing this and see what happens.
>>>
>>> Hi Richard!
>>>
>>> Here's the bundle which tries to use the felix event admin service. If you
>>> wish I can provide you the sources of the bundle, too.
>>>
>>> If you want to use the bundle, you have to load the following bundles:
>>>
>>> org.apache.felix.shell-1.2.0.jar
>>> org.apache.felix.shell.tui-1.2.0.jar
>>> org.apache.felix.eventadmin-1.0.0.jar
>>> VehiclePushService_1.0.0.jar
>>>
>>> Some minutes ago I noticed that the bundle can be loaded successfully if
>>> you
>>> run it directly from a command-line-based felix instance. The error only
>>> occures if you try to run it
>>> as an embedded version. Very confusing.
>>>
>>> Maybe there's something wrong with the configuration of my felix instance:
>>>
>>>      private void initialize()
>>>      {
>>>          // create new map for storing the felix configuration properties
>>>          configMap = new HashMap<String, Object>();
>>>
>>>          // export the host provided service interface package
>>>          configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>>> "osgiServices.vehicleCommunicationService;
>>> osgiServices.vehiclePushService;
>>> vehiclePushService; vehicleCommunicationService");
>>>
>>>          // add autoactivator that specifies all services that shall be
>>> loaded together with the system bundle
>>>          List<Object>   list = new ArrayList<Object>();
>>>          list.add(new AutoActivator(configMap));
>>>
>>>          // create service activators
>>>          vehicleCommunicationServiceActivator = new
>>> VehicleCommunicationServiceActivator(connection);
>>>          list.add(vehicleCommunicationServiceActivator);
>>>
>>>          vehiclePushServiceActivator = new VehiclePushServiceActivator();
>>>          list.add(vehiclePushServiceActivator);
>>>
>>>          // add service activators to felix instance
>>>          configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
>>>
>>>          // set felix-cache folder
>>>          configMap.put("org.osgi.framework.storage", "felix-cache/" + id);
>>>      }
>>>
>>>
>>> BR,
>>>
>>> Markus
>>>
>>> -------
>>>
>>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>>
>>>
>>>
>>>        
>>>> I don't see anything that immediately looks incorrect. If you want to
>>>> send
>>>> me your bundle (privately) with the steps to reproduce, I will look at
>>>> it.
>>>>
>>>> ->   richard
>>>>
>>>>
>>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>>
>>>>
>>>>
>>>>          
>>>>> Hi Richard!
>>>>>
>>>>> Of course I can provide more informations. The manifest file of the
>>>>> bundle
>>>>> looks like this:
>>>>>
>>>>> Manifest-Version: 1.0
>>>>> Bundle-ManifestVersion: 2
>>>>> Bundle-Name: VehiclePushService
>>>>> Bundle-SymbolicName: VehiclePushService
>>>>> Bundle-Version: 1.0.0
>>>>> Bundle-Activator: vehiclePushService.Activator
>>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>>   org.osgi.service.event;version="1.1.0",
>>>>>   vehiclePushService
>>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>>> Bundle-ClassPath: .,
>>>>>   vehiclePushService.jar
>>>>> Export-Package:
>>>>>   osgiServices.vehiclePushService,
>>>>>   vehiclePushService
>>>>>
>>>>> The content of the bundle looks as follows:
>>>>>
>>>>> META-INF/
>>>>> META-INF/MANIFEST.MF
>>>>> hostApplication/
>>>>> hostApplication/vehiclePushService/
>>>>> osgiFramework/
>>>>> osgiFramework/vehiclePushService/
>>>>> vehiclePushService/
>>>>> META-INF/.classpath
>>>>> META-INF/.project
>>>>> vehiclePushService.jar
>>>>> vehiclePushService/Activator.class
>>>>> vehiclePushService/OSGiPosition2D.class
>>>>> vehiclePushService/OSGiVehicle.class
>>>>> vehiclePushService/OSGiVehiclePushService.class
>>>>> vehiclePushService/VehicleListener.class
>>>>> vehiclePushService/VehiclePushEvent.class
>>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>>
>>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>>> referenced
>>>>> I
>>>>> think that the bundles currently uses the equinox implementation of the
>>>>> eventadmin service. Later on I will try to load the equinox eventadmin
>>>>> service instead
>>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>>> bundle
>>>>> ...
>>>>>
>>>>> BR,
>>>>>
>>>>> Markus
>>>>>
>>>>>
>>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> Hi there!
>>>>>>>
>>>>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>>>>> Therefore I extended the import block of my bundle, which is created
>>>>>>> within
>>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>>> loading
>>>>>>> the
>>>>>>> service I tried to access it by running the following command:
>>>>>>>
>>>>>>>          // get service reference to event admin service
>>>>>>>          serviceReference =
>>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>>
>>>>>>>          // check if service reference is valid
>>>>>>>          if (serviceReference != null)
>>>>>>>          {
>>>>>>>              eventAdmin = (EventAdmin)
>>>>>>> bundleContext.getService(serviceReference);
>>>>>>>          }
>>>>>>>
>>>>>>> But inside the if-loop I'm getting an error:
>>>>>>>
>>>>>>> java.lang.ClassCastException:
>>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>>> cannot
>>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>>
>>>>>>> I'm a little bit confused now, because I thought that the Apache Felix
>>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>>> and
>>>>>> getting closer every release.
>>>>>>
>>>>>>   Isn't it
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> possible to mix equinox components (my bundle) with felix components
>>>>>>> (the
>>>>>>> eventadmin service)?
>>>>>>>
>>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> Such a scenario should work, but you didn't provide enough information
>>>>>> to
>>>>>> say why it isn't. Perhaps you could show us your bundle's manifest file
>>>>>> as
>>>>>> well as a "jar tf" of the bundle.
>>>>>>
>>>>>> ->    richard
>>>>>>
>>>>>>   BR,
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> Markus
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>>
>>>>>            
>>>
>>>        
>
>    

Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
Some weeks ago I tried to use this instructions to get my embedded felix
instance working, but it didn't worked. Afterwards some guy on
stackover.comgave me the hint to put the whole package to the system
packages path. If I
strictly follow the wiki entry the line within my intialization block should
look like:

        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"osgiServices.vehiclePushService; version=1.0.0");

<path to the service includings it's implementation within the host app>

But if the entry only contains this value, I'm getting the class loading
error again.

Sorry, but I think that I have some problems in understanding the
explanations on that site completely. As far as I understood it all packages
within this property should be executed by the some class loader, which is
used for the system bundle and all other bundles. Therefore there shouldn't
occur any class loading problems, when the bundle tries to access the
service. Am I wrong? Maybe you can give me a more detailed explanation ...

Unfortunately the felix environment has to run in the embedded mode within
my program, because I want to run and control several osgi instances at
once. I hope that we will be able to solve my problem ...

BR,

Markus

2009/7/14 Richard S. Hall <he...@ungoverned.org>

> You should read:
>
>
> http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
>
> It gives some pointers to running with an embedded framework instance. In
> short, your app and all bundles should go through the class path (i.e.,
> system bundle) for any packages shared between the host app and the bundles.
>
> To make sure this happens, you could actually put the host/bundle shared
> packages on the boot class path property to make sure everyone gets the same
> ones, no matter how the bundles are wired internally. This at least has the
> benefit that your bundles will work properly when not used in the embedded
> situation.
>
> I knew there was more than what met the eye here. :-)
>
> Embedded mode is alluring to a lot of people coming to OSGi, but there are
> lots of hidden issues with it, so better to avoid it if you can.
>
> -> richard
>
>
> On 7/14/09 1:53 PM, Markus Michel wrote:
>
>> You are right. If I remove that line, I'm able to load the event admin
>> service. But the problem is that I cannot remove it, because other parts
>> of
>> my program depends on that information: My "vehiclePushService" is mostly
>> implemented (and started) within the host application but some parts are
>> implemented within the bundle. If I do not add "vehiclePushService" to
>> that
>> line, I'm getting the class loading exception
>>
>> java.lang.ClassCastException:
>> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast to
>> osgiServices.vehiclePushService.VehiclePushService
>>
>> , when the bundle tries to use the service. Maybe I have to add the event
>> admin service to that line, too?!?
>>
>> BR,
>>
>> Markus
>>
>> -----
>>
>> Markus,
>>
>> Yes, I believe your embedded configuration is the issue. Why are you doing
>> this:
>>
>>        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> "osgiServices.vehicleCommunicationService;
>> osgiServices.vehiclePushService;
>> vehiclePushService; vehicleCommunicationService");
>>
>> ?
>>
>> It seems like this is incorrect, since your bundle contains these
>> packages.
>> Try removing this and see what happens.
>>
>> Hi Richard!
>>
>> Here's the bundle which tries to use the felix event admin service. If you
>> wish I can provide you the sources of the bundle, too.
>>
>> If you want to use the bundle, you have to load the following bundles:
>>
>> org.apache.felix.shell-1.2.0.jar
>> org.apache.felix.shell.tui-1.2.0.jar
>> org.apache.felix.eventadmin-1.0.0.jar
>> VehiclePushService_1.0.0.jar
>>
>> Some minutes ago I noticed that the bundle can be loaded successfully if
>> you
>> run it directly from a command-line-based felix instance. The error only
>> occures if you try to run it
>> as an embedded version. Very confusing.
>>
>> Maybe there's something wrong with the configuration of my felix instance:
>>
>>     private void initialize()
>>     {
>>         // create new map for storing the felix configuration properties
>>         configMap = new HashMap<String, Object>();
>>
>>         // export the host provided service interface package
>>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
>> "osgiServices.vehicleCommunicationService;
>> osgiServices.vehiclePushService;
>> vehiclePushService; vehicleCommunicationService");
>>
>>         // add autoactivator that specifies all services that shall be
>> loaded together with the system bundle
>>         List<Object>  list = new ArrayList<Object>();
>>         list.add(new AutoActivator(configMap));
>>
>>         // create service activators
>>         vehicleCommunicationServiceActivator = new
>> VehicleCommunicationServiceActivator(connection);
>>         list.add(vehicleCommunicationServiceActivator);
>>
>>         vehiclePushServiceActivator = new VehiclePushServiceActivator();
>>         list.add(vehiclePushServiceActivator);
>>
>>         // add service activators to felix instance
>>         configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
>>
>>         // set felix-cache folder
>>         configMap.put("org.osgi.framework.storage", "felix-cache/" + id);
>>     }
>>
>>
>> BR,
>>
>> Markus
>>
>> -------
>>
>> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>>
>>
>>
>>> I don't see anything that immediately looks incorrect. If you want to
>>> send
>>> me your bundle (privately) with the steps to reproduce, I will look at
>>> it.
>>>
>>> ->  richard
>>>
>>>
>>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>>
>>>
>>>
>>>> Hi Richard!
>>>>
>>>> Of course I can provide more informations. The manifest file of the
>>>> bundle
>>>> looks like this:
>>>>
>>>> Manifest-Version: 1.0
>>>> Bundle-ManifestVersion: 2
>>>> Bundle-Name: VehiclePushService
>>>> Bundle-SymbolicName: VehiclePushService
>>>> Bundle-Version: 1.0.0
>>>> Bundle-Activator: vehiclePushService.Activator
>>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>>  org.osgi.service.event;version="1.1.0",
>>>>  vehiclePushService
>>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>>> Bundle-ClassPath: .,
>>>>  vehiclePushService.jar
>>>> Export-Package:
>>>>  osgiServices.vehiclePushService,
>>>>  vehiclePushService
>>>>
>>>> The content of the bundle looks as follows:
>>>>
>>>> META-INF/
>>>> META-INF/MANIFEST.MF
>>>> hostApplication/
>>>> hostApplication/vehiclePushService/
>>>> osgiFramework/
>>>> osgiFramework/vehiclePushService/
>>>> vehiclePushService/
>>>> META-INF/.classpath
>>>> META-INF/.project
>>>> vehiclePushService.jar
>>>> vehiclePushService/Activator.class
>>>> vehiclePushService/OSGiPosition2D.class
>>>> vehiclePushService/OSGiVehicle.class
>>>> vehiclePushService/OSGiVehiclePushService.class
>>>> vehiclePushService/VehicleListener.class
>>>> vehiclePushService/VehiclePushEvent.class
>>>> vehiclePushService/VehiclePushServiceHandler.class
>>>>
>>>> Because inside the plug-in dependencies org.eclipse.services is
>>>> referenced
>>>> I
>>>> think that the bundles currently uses the equinox implementation of the
>>>> eventadmin service. Later on I will try to load the equinox eventadmin
>>>> service instead
>>>> of the felix eventadmin service. Maybe it's then possible to start my
>>>> bundle
>>>> ...
>>>>
>>>> BR,
>>>>
>>>> Markus
>>>>
>>>>
>>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi there!
>>>>>>
>>>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>>>> Therefore I extended the import block of my bundle, which is created
>>>>>> within
>>>>>> an eclipse equinox project,  with org.osgi.service.event. After
>>>>>> loading
>>>>>> the
>>>>>> service I tried to access it by running the following command:
>>>>>>
>>>>>>         // get service reference to event admin service
>>>>>>         serviceReference =
>>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>>
>>>>>>         // check if service reference is valid
>>>>>>         if (serviceReference != null)
>>>>>>         {
>>>>>>             eventAdmin = (EventAdmin)
>>>>>> bundleContext.getService(serviceReference);
>>>>>>         }
>>>>>>
>>>>>> But inside the if-loop I'm getting an error:
>>>>>>
>>>>>> java.lang.ClassCastException:
>>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>>> cannot
>>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>>
>>>>>> I'm a little bit confused now, because I thought that the Apache Felix
>>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> While the Felix framework isn't yet 100% compliant, it is very close
>>>>> and
>>>>> getting closer every release.
>>>>>
>>>>>  Isn't it
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> possible to mix equinox components (my bundle) with felix components
>>>>>> (the
>>>>>> eventadmin service)?
>>>>>>
>>>>>> Does anybody has an idea how I can solve my problem?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Such a scenario should work, but you didn't provide enough information
>>>>> to
>>>>> say why it isn't. Perhaps you could show us your bundle's manifest file
>>>>> as
>>>>> well as a "jar tf" of the bundle.
>>>>>
>>>>> ->   richard
>>>>>
>>>>>  BR,
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Markus
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>

Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
You should read:

     
http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html

It gives some pointers to running with an embedded framework instance. 
In short, your app and all bundles should go through the class path 
(i.e., system bundle) for any packages shared between the host app and 
the bundles.

To make sure this happens, you could actually put the host/bundle shared 
packages on the boot class path property to make sure everyone gets the 
same ones, no matter how the bundles are wired internally. This at least 
has the benefit that your bundles will work properly when not used in 
the embedded situation.

I knew there was more than what met the eye here. :-)

Embedded mode is alluring to a lot of people coming to OSGi, but there 
are lots of hidden issues with it, so better to avoid it if you can.

-> richard

On 7/14/09 1:53 PM, Markus Michel wrote:
> You are right. If I remove that line, I'm able to load the event admin
> service. But the problem is that I cannot remove it, because other parts of
> my program depends on that information: My "vehiclePushService" is mostly
> implemented (and started) within the host application but some parts are
> implemented within the bundle. If I do not add "vehiclePushService" to that
> line, I'm getting the class loading exception
>
> java.lang.ClassCastException:
> osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast to
> osgiServices.vehiclePushService.VehiclePushService
>
> , when the bundle tries to use the service. Maybe I have to add the event
> admin service to that line, too?!?
>
> BR,
>
> Markus
>
> -----
>
> Markus,
>
> Yes, I believe your embedded configuration is the issue. Why are you doing
> this:
>
>         configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> "osgiServices.vehicleCommunicationService; osgiServices.vehiclePushService;
> vehiclePushService; vehicleCommunicationService");
>
> ?
>
> It seems like this is incorrect, since your bundle contains these packages.
> Try removing this and see what happens.
>
> Hi Richard!
>
> Here's the bundle which tries to use the felix event admin service. If you
> wish I can provide you the sources of the bundle, too.
>
> If you want to use the bundle, you have to load the following bundles:
>
> org.apache.felix.shell-1.2.0.jar
> org.apache.felix.shell.tui-1.2.0.jar
> org.apache.felix.eventadmin-1.0.0.jar
> VehiclePushService_1.0.0.jar
>
> Some minutes ago I noticed that the bundle can be loaded successfully if you
> run it directly from a command-line-based felix instance. The error only
> occures if you try to run it
> as an embedded version. Very confusing.
>
> Maybe there's something wrong with the configuration of my felix instance:
>
>      private void initialize()
>      {
>          // create new map for storing the felix configuration properties
>          configMap = new HashMap<String, Object>();
>
>          // export the host provided service interface package
>          configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
> "osgiServices.vehicleCommunicationService; osgiServices.vehiclePushService;
> vehiclePushService; vehicleCommunicationService");
>
>          // add autoactivator that specifies all services that shall be
> loaded together with the system bundle
>          List<Object>  list = new ArrayList<Object>();
>          list.add(new AutoActivator(configMap));
>
>          // create service activators
>          vehicleCommunicationServiceActivator = new
> VehicleCommunicationServiceActivator(connection);
>          list.add(vehicleCommunicationServiceActivator);
>
>          vehiclePushServiceActivator = new VehiclePushServiceActivator();
>          list.add(vehiclePushServiceActivator);
>
>          // add service activators to felix instance
>          configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
>
>          // set felix-cache folder
>          configMap.put("org.osgi.framework.storage", "felix-cache/" + id);
>      }
>
>
> BR,
>
> Markus
>
> -------
>
> 2009/7/14 Richard S. Hall<he...@ungoverned.org>
>
>    
>> I don't see anything that immediately looks incorrect. If you want to send
>> me your bundle (privately) with the steps to reproduce, I will look at it.
>>
>> ->  richard
>>
>>
>> On 7/14/09 4:20 AM, Markus Michel wrote:
>>
>>      
>>> Hi Richard!
>>>
>>> Of course I can provide more informations. The manifest file of the bundle
>>> looks like this:
>>>
>>> Manifest-Version: 1.0
>>> Bundle-ManifestVersion: 2
>>> Bundle-Name: VehiclePushService
>>> Bundle-SymbolicName: VehiclePushService
>>> Bundle-Version: 1.0.0
>>> Bundle-Activator: vehiclePushService.Activator
>>> Import-Package: org.osgi.framework;version="1.3.0",
>>>   org.osgi.service.event;version="1.1.0",
>>>   vehiclePushService
>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>>> Bundle-ClassPath: .,
>>>   vehiclePushService.jar
>>> Export-Package:
>>>   osgiServices.vehiclePushService,
>>>   vehiclePushService
>>>
>>> The content of the bundle looks as follows:
>>>
>>> META-INF/
>>> META-INF/MANIFEST.MF
>>> hostApplication/
>>> hostApplication/vehiclePushService/
>>> osgiFramework/
>>> osgiFramework/vehiclePushService/
>>> vehiclePushService/
>>> META-INF/.classpath
>>> META-INF/.project
>>> vehiclePushService.jar
>>> vehiclePushService/Activator.class
>>> vehiclePushService/OSGiPosition2D.class
>>> vehiclePushService/OSGiVehicle.class
>>> vehiclePushService/OSGiVehiclePushService.class
>>> vehiclePushService/VehicleListener.class
>>> vehiclePushService/VehiclePushEvent.class
>>> vehiclePushService/VehiclePushServiceHandler.class
>>>
>>> Because inside the plug-in dependencies org.eclipse.services is referenced
>>> I
>>> think that the bundles currently uses the equinox implementation of the
>>> eventadmin service. Later on I will try to load the equinox eventadmin
>>> service instead
>>> of the felix eventadmin service. Maybe it's then possible to start my
>>> bundle
>>> ...
>>>
>>> BR,
>>>
>>> Markus
>>>
>>>
>>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>>
>>>
>>>
>>>        
>>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>>
>>>>
>>>>
>>>>          
>>>>> Hi there!
>>>>>
>>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>>> Therefore I extended the import block of my bundle, which is created
>>>>> within
>>>>> an eclipse equinox project,  with org.osgi.service.event. After loading
>>>>> the
>>>>> service I tried to access it by running the following command:
>>>>>
>>>>>          // get service reference to event admin service
>>>>>          serviceReference =
>>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>>
>>>>>          // check if service reference is valid
>>>>>          if (serviceReference != null)
>>>>>          {
>>>>>              eventAdmin = (EventAdmin)
>>>>> bundleContext.getService(serviceReference);
>>>>>          }
>>>>>
>>>>> But inside the if-loop I'm getting an error:
>>>>>
>>>>> java.lang.ClassCastException:
>>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>>> cannot
>>>>> be cast to org.osgi.service.event.EventAdmin
>>>>>
>>>>> I'm a little bit confused now, because I thought that the Apache Felix
>>>>> framework is fully compatible to the OSGi specifications?!?
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> While the Felix framework isn't yet 100% compliant, it is very close and
>>>> getting closer every release.
>>>>
>>>>   Isn't it
>>>>
>>>>
>>>>          
>>>>> possible to mix equinox components (my bundle) with felix components
>>>>> (the
>>>>> eventadmin service)?
>>>>>
>>>>> Does anybody has an idea how I can solve my problem?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> Such a scenario should work, but you didn't provide enough information to
>>>> say why it isn't. Perhaps you could show us your bundle's manifest file
>>>> as
>>>> well as a "jar tf" of the bundle.
>>>>
>>>> ->   richard
>>>>
>>>>   BR,
>>>>
>>>>
>>>>          
>>>>> Markus
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>          
>>>
>>>        
>
>
>    

Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
You are right. If I remove that line, I'm able to load the event admin
service. But the problem is that I cannot remove it, because other parts of
my program depends on that information: My "vehiclePushService" is mostly
implemented (and started) within the host application but some parts are
implemented within the bundle. If I do not add "vehiclePushService" to that
line, I'm getting the class loading exception

java.lang.ClassCastException:
osgiServices.vehiclePushService.VehiclePushServiceImpl cannot be cast to
osgiServices.vehiclePushService.VehiclePushService

, when the bundle tries to use the service. Maybe I have to add the event
admin service to that line, too?!?

BR,

Markus

-----

Markus,

Yes, I believe your embedded configuration is the issue. Why are you doing
this:

       configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"osgiServices.vehicleCommunicationService; osgiServices.vehiclePushService;
vehiclePushService; vehicleCommunicationService");

?

It seems like this is incorrect, since your bundle contains these packages.
Try removing this and see what happens.

Hi Richard!

Here's the bundle which tries to use the felix event admin service. If you
wish I can provide you the sources of the bundle, too.

If you want to use the bundle, you have to load the following bundles:

org.apache.felix.shell-1.2.0.jar
org.apache.felix.shell.tui-1.2.0.jar
org.apache.felix.eventadmin-1.0.0.jar
VehiclePushService_1.0.0.jar

Some minutes ago I noticed that the bundle can be loaded successfully if you
run it directly from a command-line-based felix instance. The error only
occures if you try to run it
as an embedded version. Very confusing.

Maybe there's something wrong with the configuration of my felix instance:

    private void initialize()
    {
        // create new map for storing the felix configuration properties
        configMap = new HashMap<String, Object>();

        // export the host provided service interface package
        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"osgiServices.vehicleCommunicationService; osgiServices.vehiclePushService;
vehiclePushService; vehicleCommunicationService");

        // add autoactivator that specifies all services that shall be
loaded together with the system bundle
        List<Object> list = new ArrayList<Object>();
        list.add(new AutoActivator(configMap));

        // create service activators
        vehicleCommunicationServiceActivator = new
VehicleCommunicationServiceActivator(connection);
        list.add(vehicleCommunicationServiceActivator);

        vehiclePushServiceActivator = new VehiclePushServiceActivator();
        list.add(vehiclePushServiceActivator);

        // add service activators to felix instance
        configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);

        // set felix-cache folder
        configMap.put("org.osgi.framework.storage", "felix-cache/" + id);
    }


BR,

Markus

-------

2009/7/14 Richard S. Hall <he...@ungoverned.org>

> I don't see anything that immediately looks incorrect. If you want to send
> me your bundle (privately) with the steps to reproduce, I will look at it.
>
> -> richard
>
>
> On 7/14/09 4:20 AM, Markus Michel wrote:
>
>> Hi Richard!
>>
>> Of course I can provide more informations. The manifest file of the bundle
>> looks like this:
>>
>> Manifest-Version: 1.0
>> Bundle-ManifestVersion: 2
>> Bundle-Name: VehiclePushService
>> Bundle-SymbolicName: VehiclePushService
>> Bundle-Version: 1.0.0
>> Bundle-Activator: vehiclePushService.Activator
>> Import-Package: org.osgi.framework;version="1.3.0",
>>  org.osgi.service.event;version="1.1.0",
>>  vehiclePushService
>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>> Bundle-ClassPath: .,
>>  vehiclePushService.jar
>> Export-Package:
>>  osgiServices.vehiclePushService,
>>  vehiclePushService
>>
>> The content of the bundle looks as follows:
>>
>> META-INF/
>> META-INF/MANIFEST.MF
>> hostApplication/
>> hostApplication/vehiclePushService/
>> osgiFramework/
>> osgiFramework/vehiclePushService/
>> vehiclePushService/
>> META-INF/.classpath
>> META-INF/.project
>> vehiclePushService.jar
>> vehiclePushService/Activator.class
>> vehiclePushService/OSGiPosition2D.class
>> vehiclePushService/OSGiVehicle.class
>> vehiclePushService/OSGiVehiclePushService.class
>> vehiclePushService/VehicleListener.class
>> vehiclePushService/VehiclePushEvent.class
>> vehiclePushService/VehiclePushServiceHandler.class
>>
>> Because inside the plug-in dependencies org.eclipse.services is referenced
>> I
>> think that the bundles currently uses the equinox implementation of the
>> eventadmin service. Later on I will try to load the equinox eventadmin
>> service instead
>> of the felix eventadmin service. Maybe it's then possible to start my
>> bundle
>> ...
>>
>> BR,
>>
>> Markus
>>
>>
>> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>>
>>
>>
>>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>>
>>>
>>>
>>>> Hi there!
>>>>
>>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>>> Therefore I extended the import block of my bundle, which is created
>>>> within
>>>> an eclipse equinox project,  with org.osgi.service.event. After loading
>>>> the
>>>> service I tried to access it by running the following command:
>>>>
>>>>         // get service reference to event admin service
>>>>         serviceReference =
>>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>>
>>>>         // check if service reference is valid
>>>>         if (serviceReference != null)
>>>>         {
>>>>             eventAdmin = (EventAdmin)
>>>> bundleContext.getService(serviceReference);
>>>>         }
>>>>
>>>> But inside the if-loop I'm getting an error:
>>>>
>>>> java.lang.ClassCastException:
>>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>>> cannot
>>>> be cast to org.osgi.service.event.EventAdmin
>>>>
>>>> I'm a little bit confused now, because I thought that the Apache Felix
>>>> framework is fully compatible to the OSGi specifications?!?
>>>>
>>>>
>>>>
>>> While the Felix framework isn't yet 100% compliant, it is very close and
>>> getting closer every release.
>>>
>>>  Isn't it
>>>
>>>
>>>> possible to mix equinox components (my bundle) with felix components
>>>> (the
>>>> eventadmin service)?
>>>>
>>>> Does anybody has an idea how I can solve my problem?
>>>>
>>>>
>>>>
>>>>
>>> Such a scenario should work, but you didn't provide enough information to
>>> say why it isn't. Perhaps you could show us your bundle's manifest file
>>> as
>>> well as a "jar tf" of the bundle.
>>>
>>> ->  richard
>>>
>>>  BR,
>>>
>>>
>>>> Markus
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>


-- 
Mit freundlichen Grüßen,

Markus Michel

Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I don't see anything that immediately looks incorrect. If you want to 
send me your bundle (privately) with the steps to reproduce, I will look 
at it.

-> richard

On 7/14/09 4:20 AM, Markus Michel wrote:
> Hi Richard!
>
> Of course I can provide more informations. The manifest file of the bundle
> looks like this:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: VehiclePushService
> Bundle-SymbolicName: VehiclePushService
> Bundle-Version: 1.0.0
> Bundle-Activator: vehiclePushService.Activator
> Import-Package: org.osgi.framework;version="1.3.0",
>   org.osgi.service.event;version="1.1.0",
>   vehiclePushService
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
> Bundle-ClassPath: .,
>   vehiclePushService.jar
> Export-Package:
>   osgiServices.vehiclePushService,
>   vehiclePushService
>
> The content of the bundle looks as follows:
>
> META-INF/
> META-INF/MANIFEST.MF
> hostApplication/
> hostApplication/vehiclePushService/
> osgiFramework/
> osgiFramework/vehiclePushService/
> vehiclePushService/
> META-INF/.classpath
> META-INF/.project
> vehiclePushService.jar
> vehiclePushService/Activator.class
> vehiclePushService/OSGiPosition2D.class
> vehiclePushService/OSGiVehicle.class
> vehiclePushService/OSGiVehiclePushService.class
> vehiclePushService/VehicleListener.class
> vehiclePushService/VehiclePushEvent.class
> vehiclePushService/VehiclePushServiceHandler.class
>
> Because inside the plug-in dependencies org.eclipse.services is referenced I
> think that the bundles currently uses the equinox implementation of the
> eventadmin service. Later on I will try to load the equinox eventadmin
> service instead
> of the felix eventadmin service. Maybe it's then possible to start my bundle
> ...
>
> BR,
>
> Markus
>
>
> 2009/7/13 Richard S. Hall<he...@ungoverned.org>
>
>    
>> On 7/13/09 2:47 PM, Markus Michel wrote:
>>
>>      
>>> Hi there!
>>>
>>> Today I wanted to add the eventadmin service to my OSGi environment.
>>> Therefore I extended the import block of my bundle, which is created
>>> within
>>> an eclipse equinox project,  with org.osgi.service.event. After loading
>>> the
>>> service I tried to access it by running the following command:
>>>
>>>          // get service reference to event admin service
>>>          serviceReference =
>>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>>
>>>          // check if service reference is valid
>>>          if (serviceReference != null)
>>>          {
>>>              eventAdmin = (EventAdmin)
>>> bundleContext.getService(serviceReference);
>>>          }
>>>
>>> But inside the if-loop I'm getting an error:
>>>
>>> java.lang.ClassCastException:
>>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>>> cannot
>>> be cast to org.osgi.service.event.EventAdmin
>>>
>>> I'm a little bit confused now, because I thought that the Apache Felix
>>> framework is fully compatible to the OSGi specifications?!?
>>>
>>>        
>> While the Felix framework isn't yet 100% compliant, it is very close and
>> getting closer every release.
>>
>>   Isn't it
>>      
>>> possible to mix equinox components (my bundle) with felix components (the
>>> eventadmin service)?
>>>
>>> Does anybody has an idea how I can solve my problem?
>>>
>>>
>>>        
>> Such a scenario should work, but you didn't provide enough information to
>> say why it isn't. Perhaps you could show us your bundle's manifest file as
>> well as a "jar tf" of the bundle.
>>
>> ->  richard
>>
>>   BR,
>>      
>>> Markus
>>>
>>>
>>>
>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>      
>
>    

Re: Using Felix EventAdmin Service?!?

Posted by Markus Michel <ma...@uni-duesseldorf.de>.
Hi Richard!

Of course I can provide more informations. The manifest file of the bundle
looks like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: VehiclePushService
Bundle-SymbolicName: VehiclePushService
Bundle-Version: 1.0.0
Bundle-Activator: vehiclePushService.Activator
Import-Package: org.osgi.framework;version="1.3.0",
 org.osgi.service.event;version="1.1.0",
 vehiclePushService
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
 vehiclePushService.jar
Export-Package:
 osgiServices.vehiclePushService,
 vehiclePushService

The content of the bundle looks as follows:

META-INF/
META-INF/MANIFEST.MF
hostApplication/
hostApplication/vehiclePushService/
osgiFramework/
osgiFramework/vehiclePushService/
vehiclePushService/
META-INF/.classpath
META-INF/.project
vehiclePushService.jar
vehiclePushService/Activator.class
vehiclePushService/OSGiPosition2D.class
vehiclePushService/OSGiVehicle.class
vehiclePushService/OSGiVehiclePushService.class
vehiclePushService/VehicleListener.class
vehiclePushService/VehiclePushEvent.class
vehiclePushService/VehiclePushServiceHandler.class

Because inside the plug-in dependencies org.eclipse.services is referenced I
think that the bundles currently uses the equinox implementation of the
eventadmin service. Later on I will try to load the equinox eventadmin
service instead
of the felix eventadmin service. Maybe it's then possible to start my bundle
...

BR,

Markus


2009/7/13 Richard S. Hall <he...@ungoverned.org>

> On 7/13/09 2:47 PM, Markus Michel wrote:
>
>> Hi there!
>>
>> Today I wanted to add the eventadmin service to my OSGi environment.
>> Therefore I extended the import block of my bundle, which is created
>> within
>> an eclipse equinox project,  with org.osgi.service.event. After loading
>> the
>> service I tried to access it by running the following command:
>>
>>         // get service reference to event admin service
>>         serviceReference =
>> bundleContext.getServiceReference(EventAdmin.class.getName());
>>
>>         // check if service reference is valid
>>         if (serviceReference != null)
>>         {
>>             eventAdmin = (EventAdmin)
>> bundleContext.getService(serviceReference);
>>         }
>>
>> But inside the if-loop I'm getting an error:
>>
>> java.lang.ClassCastException:
>> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
>> cannot
>> be cast to org.osgi.service.event.EventAdmin
>>
>> I'm a little bit confused now, because I thought that the Apache Felix
>> framework is fully compatible to the OSGi specifications?!?
>>
>
> While the Felix framework isn't yet 100% compliant, it is very close and
> getting closer every release.
>
>  Isn't it
>> possible to mix equinox components (my bundle) with felix components (the
>> eventadmin service)?
>>
>> Does anybody has an idea how I can solve my problem?
>>
>>
>
> Such a scenario should work, but you didn't provide enough information to
> say why it isn't. Perhaps you could show us your bundle's manifest file as
> well as a "jar tf" of the bundle.
>
> -> richard
>
>  BR,
>>
>> Markus
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Using Felix EventAdmin Service?!?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 7/13/09 2:47 PM, Markus Michel wrote:
> Hi there!
>
> Today I wanted to add the eventadmin service to my OSGi environment.
> Therefore I extended the import block of my bundle, which is created within
> an eclipse equinox project,  with org.osgi.service.event. After loading the
> service I tried to access it by running the following command:
>
>          // get service reference to event admin service
>          serviceReference =
> bundleContext.getServiceReference(EventAdmin.class.getName());
>
>          // check if service reference is valid
>          if (serviceReference != null)
>          {
>              eventAdmin = (EventAdmin)
> bundleContext.getService(serviceReference);
>          }
>
> But inside the if-loop I'm getting an error:
>
> java.lang.ClassCastException:
> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator cannot
> be cast to org.osgi.service.event.EventAdmin
>
> I'm a little bit confused now, because I thought that the Apache Felix
> framework is fully compatible to the OSGi specifications?!?

While the Felix framework isn't yet 100% compliant, it is very close and 
getting closer every release.

> Isn't it
> possible to mix equinox components (my bundle) with felix components (the
> eventadmin service)?
>
> Does anybody has an idea how I can solve my problem?
>    

Such a scenario should work, but you didn't provide enough information 
to say why it isn't. Perhaps you could show us your bundle's manifest 
file as well as a "jar tf" of the bundle.

-> richard

> BR,
>
> Markus
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org