ServerInfo usage question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ServerInfo usage question

Chris Caspanello
Hey guys,

I'm trying to access the ServerInfo service from my bundle.  In my bundle I
included the following in my pom.xml

    <dependency>
      <groupId>org.apache.karaf</groupId>
      <artifactId>org.apache.karaf.main</artifactId>
      <version>${karaf.version}</version>
      <scope>provided</scope>
    </dependency>

I marked it provided since it is already included by Karaf.  I know this
because I can list the services in Bundle 0 and see the ServerInfo service.
I can also debug my bundle with the following and see the service returned.

        ServiceReference<?> ref = bundleContext.getServiceReference(
"org.apache.karaf.info.ServerInfo" );
        bundleContext.getService( ref );

However if I try try to import the ServerInfo in my class like this:

        ServiceReference<ServerInfo> ref =
bundleContext.getServiceReference(ServerInfo.class);
        ServerInfo serverInfo = (ServerInfo) bundleContext.getService(ref);

Then I get the following bundle wiring error:

osgi.wiring.package;
filter:="(&(osgi.wiring.package=org.apache.karaf.info)(version>=4.0.0)(!(version>=5.0.0)))"]]

Any ideas how I can fix this?

Thanks,
Chris



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
Reply | Threaded
Open this post in threaded view
|

Re: ServerInfo usage question

jbonofre
Hi Chris,

in your bundle, do you use:

org.apache.karaf.info;version="[3,5)"

in the Import-Package ?

I think your import doesn't match exactly the version.

Regards
JB

On 01/10/2018 04:39 AM, Chris Caspanello wrote:

> Hey guys,
>
> I'm trying to access the ServerInfo service from my bundle.  In my bundle I
> included the following in my pom.xml
>
>      <dependency>
>        <groupId>org.apache.karaf</groupId>
>        <artifactId>org.apache.karaf.main</artifactId>
>        <version>${karaf.version}</version>
>        <scope>provided</scope>
>      </dependency>
>
> I marked it provided since it is already included by Karaf.  I know this
> because I can list the services in Bundle 0 and see the ServerInfo service.
> I can also debug my bundle with the following and see the service returned.
>
>          ServiceReference<?> ref = bundleContext.getServiceReference(
> "org.apache.karaf.info.ServerInfo" );
>          bundleContext.getService( ref );
>
> However if I try try to import the ServerInfo in my class like this:
>
>          ServiceReference<ServerInfo> ref =
> bundleContext.getServiceReference(ServerInfo.class);
>          ServerInfo serverInfo = (ServerInfo) bundleContext.getService(ref);
>
> Then I get the following bundle wiring error:
>
> osgi.wiring.package;
> filter:="(&(osgi.wiring.package=org.apache.karaf.info)(version>=4.0.0)(!(version>=5.0.0)))"]]
>
> Any ideas how I can fix this?
>
> Thanks,
> Chris
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: ServerInfo usage question

Guillaume Nodet-2
In reply to this post by Chris Caspanello
That's a bug, the package should be made available.
You add it manually in etc/config.properties by modifying the
org.osgi.framework.system.packages  property and adding:
    org.apache.karaf.info;version="4.2.0.SNAPSHOT"
Could you raise a JIRA about that ?

2018-01-10 4:39 GMT+01:00 Chris Caspanello <[hidden email]>:

> Hey guys,
>
> I'm trying to access the ServerInfo service from my bundle.  In my bundle I
> included the following in my pom.xml
>
>     <dependency>
>       <groupId>org.apache.karaf</groupId>
>       <artifactId>org.apache.karaf.main</artifactId>
>       <version>${karaf.version}</version>
>       <scope>provided</scope>
>     </dependency>
>
> I marked it provided since it is already included by Karaf.  I know this
> because I can list the services in Bundle 0 and see the ServerInfo service.
> I can also debug my bundle with the following and see the service returned.
>
>         ServiceReference<?> ref = bundleContext.getServiceReference(
> "org.apache.karaf.info.ServerInfo" );
>         bundleContext.getService( ref );
>
> However if I try try to import the ServerInfo in my class like this:
>
>         ServiceReference<ServerInfo> ref =
> bundleContext.getServiceReference(ServerInfo.class);
>         ServerInfo serverInfo = (ServerInfo) bundleContext.getService(ref);
>
> Then I get the following bundle wiring error:
>
> osgi.wiring.package;
> filter:="(&(osgi.wiring.package=org.apache.karaf.info)(
> version>=4.0.0)(!(version>=5.0.0)))"]]
>
> Any ideas how I can fix this?
>
> Thanks,
> Chris
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
>



--
------------------------
Guillaume Nodet
Reply | Threaded
Open this post in threaded view
|

Re: ServerInfo usage question

jbonofre
Erf, good catch, I didn't check the package visibility.

Regards
JB

On 01/10/2018 01:07 PM, Guillaume Nodet wrote:

> That's a bug, the package should be made available.
> You add it manually in etc/config.properties by modifying the
> org.osgi.framework.system.packages  property and adding:
>      org.apache.karaf.info;version="4.2.0.SNAPSHOT"
> Could you raise a JIRA about that ?
>
> 2018-01-10 4:39 GMT+01:00 Chris Caspanello <[hidden email]>:
>
>> Hey guys,
>>
>> I'm trying to access the ServerInfo service from my bundle.  In my bundle I
>> included the following in my pom.xml
>>
>>      <dependency>
>>        <groupId>org.apache.karaf</groupId>
>>        <artifactId>org.apache.karaf.main</artifactId>
>>        <version>${karaf.version}</version>
>>        <scope>provided</scope>
>>      </dependency>
>>
>> I marked it provided since it is already included by Karaf.  I know this
>> because I can list the services in Bundle 0 and see the ServerInfo service.
>> I can also debug my bundle with the following and see the service returned.
>>
>>          ServiceReference<?> ref = bundleContext.getServiceReference(
>> "org.apache.karaf.info.ServerInfo" );
>>          bundleContext.getService( ref );
>>
>> However if I try try to import the ServerInfo in my class like this:
>>
>>          ServiceReference<ServerInfo> ref =
>> bundleContext.getServiceReference(ServerInfo.class);
>>          ServerInfo serverInfo = (ServerInfo) bundleContext.getService(ref);
>>
>> Then I get the following bundle wiring error:
>>
>> osgi.wiring.package;
>> filter:="(&(osgi.wiring.package=org.apache.karaf.info)(
>> version>=4.0.0)(!(version>=5.0.0)))"]]
>>
>> Any ideas how I can fix this?
>>
>> Thanks,
>> Chris
>>
>>
>>
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
>>
>
>
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: ServerInfo usage question

Chris Caspanello