OSGi bundle export versioning












1















I'm pretty new in osgi world, and probably missing something, and i'm having troubles exposing different versions of the same sevice for liferay.



Here is what i am trying to do (and sorry for my english):



I wrote a service, wrapped it in a bundle and successfully deployed it on osgi. My bnd.bnd file looks like this



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


and, once packaged, the manifest file is like this



Manifest-Version: 1.0
Bnd-LastModified: 1542646653910
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


This manifest file declares



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"


and i think this is correct.



Once deployed (successfully) i check the bundle state with the command bundle __BUNDLE_ID__ that gives me



pilot--test-services_7.1.0 [1014]
Id=1014, Status=ACTIVE Data Root=/home/ltrioschi/development/liferay-osgi/liferay-ce-portal-7.1.0-ga1/osgi/state/org.eclipse.osgi/1014/data
"Registered Services"
{it.peernetwork.lr.pilot.testservices.UselessService}={service.id=1607, service.bundleid=1014, service.scope=singleton}
No services in use.
Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.0"[exported]
Imported packages
com.liferay.expando.kernel.exception; version="1.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.model; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.service; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.exception; version="7.2.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.model; version="2.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
org.osgi.framework; version="1.8.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
No fragment bundles
No required bundles


Then i wrote a portlet that requires this service. The bnd.dnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.0],
*

-metatype: *


And once deployed it loads correctly the service and uses it with no issues.



Now...my problem is i need a new version of the service, but i do not want to undeploy the current version.



So i wrote the new version of the service and the new bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.1
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


(the only difference is the Bundle-Version)



Once packaged the only difference in manifest file is the Export-Package line



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.1"


and looks like it smoothly deploys on osgi



g! lb pilot
START LEVEL 20
ID|State |Level|Name
1014|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.0)
1015|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.1)


but with the command bundle ___NEW_BUNDLE_ID___ i get



No exported packages


instead of



Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.1"[exported]


(that i expected). It means (to me) that the bundle is deployed, but none of its services are exposed.



Then i updated my portlets bundle (bnd.bnd) this way



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.1],
*

-metatype: *


(changed version in Import-Package) and deployed on osgi. Deploy was correct, but it still uses the old version of the services bundle (7.1.0) even if Import-Package declares version 7.1.1. It does not give error because of the "missing" requested service version.



Can someone give me some tips about what i am doing wrong?



Thanks in advance.





UPDATE 1



Dependencies in build.gradle file have been updated accordingly with the version specified in bnd.bnd.





UPDATE 2



@quatax



The updated portlet bundle's manifest file has Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.1.1]" (followed by all other required imports)...seems correct to me...





UPDATE 3



@Neil Bartlett (Service version updated to 8.0.0)



I updated pilot--test-services bnd.bnd file setting Bundle-Version: 8.0.0.
The whole bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


Manifest file is



Manifest-Version: 1.0
Bnd-LastModified: 1543316524201
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="8.0.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


. When i deploy it it seems ok (starts and status is "Active"), but bundle ___ID___ says No exported packages



Then i updated pilot--test-portlet's build.gradle setting the correct version of the dependency (8.0.0). It's manifes file says Import-Package: it.peernetwork.lr.pilot.testservices;version="[8.0,9). When i deploy this package it does not start (status "Installed" and error Unresolved requirement: Import-Package: it.peernetwork.lr.pilot.testservices; version="[8.0.0,9.0.0)")





UPDATE 4 -- -- RESOLVED
Thank you very much @Neil. Thanks to your tips i solved my issue. The right advice was this.



Explicitally declaring



Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


in the pilot--test-services's bnd.bnd file (self import, with the opportune version range) makes osgi export correctly the package and loads the correct class instances when required.



The complete bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.2.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices

Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


In pilot--test-portlet's build.gradle file i only had to update the dependency version



compileOnly group: "it.peernetwork.lr", name: "pilot--test-services", version: "7.2.0"


I tried with version 7.1.0, 7.2.0 and 8.0.0 and works smoothly. All "services" bundles are deployed on osgi. Deploying the portlet bundle with different dependency versions always takes the right service.



Thank you again.










share|improve this question

























  • Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

    – quatax
    Nov 20 '18 at 23:24











  • Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

    – Trio
    Nov 21 '18 at 8:15













  • It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

    – quatax
    Nov 21 '18 at 9:43











  • I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

    – Trio
    Nov 21 '18 at 9:54













  • As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

    – Olaf Kock
    Nov 23 '18 at 8:41
















1















I'm pretty new in osgi world, and probably missing something, and i'm having troubles exposing different versions of the same sevice for liferay.



Here is what i am trying to do (and sorry for my english):



I wrote a service, wrapped it in a bundle and successfully deployed it on osgi. My bnd.bnd file looks like this



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


and, once packaged, the manifest file is like this



Manifest-Version: 1.0
Bnd-LastModified: 1542646653910
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


This manifest file declares



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"


and i think this is correct.



Once deployed (successfully) i check the bundle state with the command bundle __BUNDLE_ID__ that gives me



pilot--test-services_7.1.0 [1014]
Id=1014, Status=ACTIVE Data Root=/home/ltrioschi/development/liferay-osgi/liferay-ce-portal-7.1.0-ga1/osgi/state/org.eclipse.osgi/1014/data
"Registered Services"
{it.peernetwork.lr.pilot.testservices.UselessService}={service.id=1607, service.bundleid=1014, service.scope=singleton}
No services in use.
Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.0"[exported]
Imported packages
com.liferay.expando.kernel.exception; version="1.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.model; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.service; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.exception; version="7.2.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.model; version="2.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
org.osgi.framework; version="1.8.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
No fragment bundles
No required bundles


Then i wrote a portlet that requires this service. The bnd.dnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.0],
*

-metatype: *


And once deployed it loads correctly the service and uses it with no issues.



Now...my problem is i need a new version of the service, but i do not want to undeploy the current version.



So i wrote the new version of the service and the new bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.1
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


(the only difference is the Bundle-Version)



Once packaged the only difference in manifest file is the Export-Package line



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.1"


and looks like it smoothly deploys on osgi



g! lb pilot
START LEVEL 20
ID|State |Level|Name
1014|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.0)
1015|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.1)


but with the command bundle ___NEW_BUNDLE_ID___ i get



No exported packages


instead of



Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.1"[exported]


(that i expected). It means (to me) that the bundle is deployed, but none of its services are exposed.



Then i updated my portlets bundle (bnd.bnd) this way



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.1],
*

-metatype: *


(changed version in Import-Package) and deployed on osgi. Deploy was correct, but it still uses the old version of the services bundle (7.1.0) even if Import-Package declares version 7.1.1. It does not give error because of the "missing" requested service version.



Can someone give me some tips about what i am doing wrong?



Thanks in advance.





UPDATE 1



Dependencies in build.gradle file have been updated accordingly with the version specified in bnd.bnd.





UPDATE 2



@quatax



The updated portlet bundle's manifest file has Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.1.1]" (followed by all other required imports)...seems correct to me...





UPDATE 3



@Neil Bartlett (Service version updated to 8.0.0)



I updated pilot--test-services bnd.bnd file setting Bundle-Version: 8.0.0.
The whole bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


Manifest file is



Manifest-Version: 1.0
Bnd-LastModified: 1543316524201
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="8.0.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


. When i deploy it it seems ok (starts and status is "Active"), but bundle ___ID___ says No exported packages



Then i updated pilot--test-portlet's build.gradle setting the correct version of the dependency (8.0.0). It's manifes file says Import-Package: it.peernetwork.lr.pilot.testservices;version="[8.0,9). When i deploy this package it does not start (status "Installed" and error Unresolved requirement: Import-Package: it.peernetwork.lr.pilot.testservices; version="[8.0.0,9.0.0)")





UPDATE 4 -- -- RESOLVED
Thank you very much @Neil. Thanks to your tips i solved my issue. The right advice was this.



Explicitally declaring



Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


in the pilot--test-services's bnd.bnd file (self import, with the opportune version range) makes osgi export correctly the package and loads the correct class instances when required.



The complete bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.2.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices

Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


In pilot--test-portlet's build.gradle file i only had to update the dependency version



compileOnly group: "it.peernetwork.lr", name: "pilot--test-services", version: "7.2.0"


I tried with version 7.1.0, 7.2.0 and 8.0.0 and works smoothly. All "services" bundles are deployed on osgi. Deploying the portlet bundle with different dependency versions always takes the right service.



Thank you again.










share|improve this question

























  • Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

    – quatax
    Nov 20 '18 at 23:24











  • Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

    – Trio
    Nov 21 '18 at 8:15













  • It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

    – quatax
    Nov 21 '18 at 9:43











  • I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

    – Trio
    Nov 21 '18 at 9:54













  • As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

    – Olaf Kock
    Nov 23 '18 at 8:41














1












1








1








I'm pretty new in osgi world, and probably missing something, and i'm having troubles exposing different versions of the same sevice for liferay.



Here is what i am trying to do (and sorry for my english):



I wrote a service, wrapped it in a bundle and successfully deployed it on osgi. My bnd.bnd file looks like this



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


and, once packaged, the manifest file is like this



Manifest-Version: 1.0
Bnd-LastModified: 1542646653910
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


This manifest file declares



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"


and i think this is correct.



Once deployed (successfully) i check the bundle state with the command bundle __BUNDLE_ID__ that gives me



pilot--test-services_7.1.0 [1014]
Id=1014, Status=ACTIVE Data Root=/home/ltrioschi/development/liferay-osgi/liferay-ce-portal-7.1.0-ga1/osgi/state/org.eclipse.osgi/1014/data
"Registered Services"
{it.peernetwork.lr.pilot.testservices.UselessService}={service.id=1607, service.bundleid=1014, service.scope=singleton}
No services in use.
Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.0"[exported]
Imported packages
com.liferay.expando.kernel.exception; version="1.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.model; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.service; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.exception; version="7.2.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.model; version="2.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
org.osgi.framework; version="1.8.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
No fragment bundles
No required bundles


Then i wrote a portlet that requires this service. The bnd.dnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.0],
*

-metatype: *


And once deployed it loads correctly the service and uses it with no issues.



Now...my problem is i need a new version of the service, but i do not want to undeploy the current version.



So i wrote the new version of the service and the new bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.1
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


(the only difference is the Bundle-Version)



Once packaged the only difference in manifest file is the Export-Package line



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.1"


and looks like it smoothly deploys on osgi



g! lb pilot
START LEVEL 20
ID|State |Level|Name
1014|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.0)
1015|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.1)


but with the command bundle ___NEW_BUNDLE_ID___ i get



No exported packages


instead of



Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.1"[exported]


(that i expected). It means (to me) that the bundle is deployed, but none of its services are exposed.



Then i updated my portlets bundle (bnd.bnd) this way



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.1],
*

-metatype: *


(changed version in Import-Package) and deployed on osgi. Deploy was correct, but it still uses the old version of the services bundle (7.1.0) even if Import-Package declares version 7.1.1. It does not give error because of the "missing" requested service version.



Can someone give me some tips about what i am doing wrong?



Thanks in advance.





UPDATE 1



Dependencies in build.gradle file have been updated accordingly with the version specified in bnd.bnd.





UPDATE 2



@quatax



The updated portlet bundle's manifest file has Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.1.1]" (followed by all other required imports)...seems correct to me...





UPDATE 3



@Neil Bartlett (Service version updated to 8.0.0)



I updated pilot--test-services bnd.bnd file setting Bundle-Version: 8.0.0.
The whole bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


Manifest file is



Manifest-Version: 1.0
Bnd-LastModified: 1543316524201
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="8.0.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


. When i deploy it it seems ok (starts and status is "Active"), but bundle ___ID___ says No exported packages



Then i updated pilot--test-portlet's build.gradle setting the correct version of the dependency (8.0.0). It's manifes file says Import-Package: it.peernetwork.lr.pilot.testservices;version="[8.0,9). When i deploy this package it does not start (status "Installed" and error Unresolved requirement: Import-Package: it.peernetwork.lr.pilot.testservices; version="[8.0.0,9.0.0)")





UPDATE 4 -- -- RESOLVED
Thank you very much @Neil. Thanks to your tips i solved my issue. The right advice was this.



Explicitally declaring



Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


in the pilot--test-services's bnd.bnd file (self import, with the opportune version range) makes osgi export correctly the package and loads the correct class instances when required.



The complete bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.2.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices

Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


In pilot--test-portlet's build.gradle file i only had to update the dependency version



compileOnly group: "it.peernetwork.lr", name: "pilot--test-services", version: "7.2.0"


I tried with version 7.1.0, 7.2.0 and 8.0.0 and works smoothly. All "services" bundles are deployed on osgi. Deploying the portlet bundle with different dependency versions always takes the right service.



Thank you again.










share|improve this question
















I'm pretty new in osgi world, and probably missing something, and i'm having troubles exposing different versions of the same sevice for liferay.



Here is what i am trying to do (and sorry for my english):



I wrote a service, wrapped it in a bundle and successfully deployed it on osgi. My bnd.bnd file looks like this



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


and, once packaged, the manifest file is like this



Manifest-Version: 1.0
Bnd-LastModified: 1542646653910
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


This manifest file declares



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.0"


and i think this is correct.



Once deployed (successfully) i check the bundle state with the command bundle __BUNDLE_ID__ that gives me



pilot--test-services_7.1.0 [1014]
Id=1014, Status=ACTIVE Data Root=/home/ltrioschi/development/liferay-osgi/liferay-ce-portal-7.1.0-ga1/osgi/state/org.eclipse.osgi/1014/data
"Registered Services"
{it.peernetwork.lr.pilot.testservices.UselessService}={service.id=1607, service.bundleid=1014, service.scope=singleton}
No services in use.
Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.0"[exported]
Imported packages
com.liferay.expando.kernel.exception; version="1.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.model; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.expando.kernel.service; version="1.1.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.exception; version="7.2.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
com.liferay.portal.kernel.model; version="2.0.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
org.osgi.framework; version="1.8.0" <org.eclipse.osgi_3.10.200.v20150831-0856 [0]>
No fragment bundles
No required bundles


Then i wrote a portlet that requires this service. The bnd.dnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.0],
*

-metatype: *


And once deployed it loads correctly the service and uses it with no issues.



Now...my problem is i need a new version of the service, but i do not want to undeploy the current version.



So i wrote the new version of the service and the new bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.1.1
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


(the only difference is the Bundle-Version)



Once packaged the only difference in manifest file is the Export-Package line



Export-Package: it.peernetwork.lr.pilot.testservices;version="7.1.1"


and looks like it smoothly deploys on osgi



g! lb pilot
START LEVEL 20
ID|State |Level|Name
1014|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.0)
1015|Active | 10|it.peernetwork.lr.pilot.test-services (7.1.1)


but with the command bundle ___NEW_BUNDLE_ID___ i get



No exported packages


instead of



Exported packages
it.peernetwork.lr.pilot.testservices; version="7.1.1"[exported]


(that i expected). It means (to me) that the bundle is deployed, but none of its services are exposed.



Then i updated my portlets bundle (bnd.bnd) this way



Bundle-Name: it.peernetwork.lr.pilot.test-portlet
Bundle-SymbolicName: pilot--test-portlet
Bundle-Version: 7.1.0

Import-Package:
it.peernetwork.lr.pilot.testservices;version=[7.1.1],
*

-metatype: *


(changed version in Import-Package) and deployed on osgi. Deploy was correct, but it still uses the old version of the services bundle (7.1.0) even if Import-Package declares version 7.1.1. It does not give error because of the "missing" requested service version.



Can someone give me some tips about what i am doing wrong?



Thanks in advance.





UPDATE 1



Dependencies in build.gradle file have been updated accordingly with the version specified in bnd.bnd.





UPDATE 2



@quatax



The updated portlet bundle's manifest file has Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.1.1]" (followed by all other required imports)...seems correct to me...





UPDATE 3



@Neil Bartlett (Service version updated to 8.0.0)



I updated pilot--test-services bnd.bnd file setting Bundle-Version: 8.0.0.
The whole bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices


Manifest file is



Manifest-Version: 1.0
Bnd-LastModified: 1543316524201
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServic
esActivator
Bundle-ClassPath: .,lib/pn--logger-7.1.0.jar,lib/pn--services-base-7.1
.0.jar,lib/pn--prop-files-7.1.0.jar,lib/gson-2.8.5.jar,lib/pn--expand
o-values-7.1.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 8.0.0
Created-By: 1.8.0_191 (Oracle Corporation)
Export-Package: it.peernetwork.lr.pilot.testservices;version="8.0.0"
Import-Package: com.liferay.expando.kernel.exception;version="[1.0,2)"
,com.liferay.expando.kernel.model;version="[1.1,2)",com.liferay.expan
do.kernel.service;version="[1.1,2)",com.liferay.portal.kernel.excepti
on;version="[7.2,8)",com.liferay.portal.kernel.model;version="[2.0,3)
",it.peernetwork.lr.pilot.testservices,org.osgi.framework;version="[1
.8,2)"
Javac-Debug: on
Javac-Deprecation: off
Javac-Encoding: UTF-8
Private-Package: it.peernetwork.lr.pilot.test.services.impl,it.peernet
work.lr.pilot.testservices.impl,it.peernetwork.lr.pilot.testservices.
x,lib,it.peernetwork.lr.logger,it.peernetwork.lr.servicesbase,it.peer
network.lr.propfiles,it.peernetwork.lr.propfiles.utils,com.google.gso
n,com.google.gson.annotations,com.google.gson.internal,com.google.gso
n.internal.bind,com.google.gson.internal.bind.util,com.google.gson.in
ternal.reflect,com.google.gson.reflect,com.google.gson.stream,it.peer
network.lr.expandovalues
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007


. When i deploy it it seems ok (starts and status is "Active"), but bundle ___ID___ says No exported packages



Then i updated pilot--test-portlet's build.gradle setting the correct version of the dependency (8.0.0). It's manifes file says Import-Package: it.peernetwork.lr.pilot.testservices;version="[8.0,9). When i deploy this package it does not start (status "Installed" and error Unresolved requirement: Import-Package: it.peernetwork.lr.pilot.testservices; version="[8.0.0,9.0.0)")





UPDATE 4 -- -- RESOLVED
Thank you very much @Neil. Thanks to your tips i solved my issue. The right advice was this.



Explicitally declaring



Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


in the pilot--test-services's bnd.bnd file (self import, with the opportune version range) makes osgi export correctly the package and loads the correct class instances when required.



The complete bnd.bnd file is



Bundle-Name: it.peernetwork.lr.pilot.test-services
Bundle-SymbolicName: pilot--test-services
Bundle-Version: 7.2.0
Bundle-Activator: it.peernetwork.lr.pilot.testservices.impl.TestServicesActivator
Export-Package: it.peernetwork.lr.pilot.testservices

Import-Package: it.peernetwork.lr.pilot.testservices;version="[7.2,8)",
*


In pilot--test-portlet's build.gradle file i only had to update the dependency version



compileOnly group: "it.peernetwork.lr", name: "pilot--test-services", version: "7.2.0"


I tried with version 7.1.0, 7.2.0 and 8.0.0 and works smoothly. All "services" bundles are deployed on osgi. Deploying the portlet bundle with different dependency versions always takes the right service.



Thank you again.







osgi versioning liferay-7 bnd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 6 '18 at 9:35







Trio

















asked Nov 20 '18 at 10:18









TrioTrio

386




386













  • Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

    – quatax
    Nov 20 '18 at 23:24











  • Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

    – Trio
    Nov 21 '18 at 8:15













  • It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

    – quatax
    Nov 21 '18 at 9:43











  • I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

    – Trio
    Nov 21 '18 at 9:54













  • As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

    – Olaf Kock
    Nov 23 '18 at 8:41



















  • Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

    – quatax
    Nov 20 '18 at 23:24











  • Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

    – Trio
    Nov 21 '18 at 8:15













  • It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

    – quatax
    Nov 21 '18 at 9:43











  • I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

    – Trio
    Nov 21 '18 at 9:54













  • As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

    – Olaf Kock
    Nov 23 '18 at 8:41

















Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

– quatax
Nov 20 '18 at 23:24





Did you take a look in the log? Has there been a org.osgi.framework.BundleException while deploying your Test-Portlet?

– quatax
Nov 20 '18 at 23:24













Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

– Trio
Nov 21 '18 at 8:15







Hi @quatax. I have no exceptions in tomcat's log (it says the bundle "STARTED") and the portlet bundle has Status=ACTIVE on osgi (seen by bundle ___PORTLET_BUNDLE_ID___ command). I know no more log files i can check...if there are more logs, please tell me where to find them, so i can take a look.

– Trio
Nov 21 '18 at 8:15















It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

– quatax
Nov 21 '18 at 9:43





It was more or less a wild guess. What does your updated Test-Portlet's manifest say about the imported packages? Could you upload your project somewhere (e.g. GitHub)? It would definitely help to see the whole project, including all gradle files - otherwise I'd have to keep guessing.

– quatax
Nov 21 '18 at 9:43













I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

– Trio
Nov 21 '18 at 9:54







I updated the answer with the required info. I'm sorry but i am not allowed to public this code as it's company property. I'll try to give you all informations you need here, but i cannot share the whole project (don't know if java files can be relevant in this context)

– Trio
Nov 21 '18 at 9:54















As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

– Olaf Kock
Nov 23 '18 at 8:41





As you can't share the whole project (and nobody would be interested in the exact code anyways), I recommend to build an MCVE - not only could it be shared easily, but it's a great way to isolate the exact issue at hand and learn about the underlying basics. On a related note: I see it as weird that one bundle is dependent on an exact version of another bundle. Consider using semantic versioning and make your portlet dependent on the API of the services. Then deploy the required version of the services. Update major version only if absolutely necessary

– Olaf Kock
Nov 23 '18 at 8:41












1 Answer
1






active

oldest

votes


















2














I recommend deleting the Import-Package instruction from your bnd.bnd file for the pilot--test-portlet bundle. It is not necessary: bnd will generate all the imports you need based on the actual requirements in your code.



Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. This is correct when your bundle makes use of the package itself in addition to exporting it. Therefore when you install both v7.1.0 and v7.1.1, the v7.1.0 bundle will import the package from the other version instead of exporting the older version. The pilot--test-portlet correctly imports from version 7.1.1.



In other words, everything here is working the way it should.






share|improve this answer
























  • Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

    – Trio
    Nov 23 '18 at 14:38











  • You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

    – Trio
    Nov 23 '18 at 14:49











  • Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

    – Neil Bartlett
    Nov 23 '18 at 14:56











  • Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

    – Neil Bartlett
    Nov 23 '18 at 14:58











  • I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

    – Trio
    Nov 23 '18 at 16:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390805%2fosgi-bundle-export-versioning%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I recommend deleting the Import-Package instruction from your bnd.bnd file for the pilot--test-portlet bundle. It is not necessary: bnd will generate all the imports you need based on the actual requirements in your code.



Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. This is correct when your bundle makes use of the package itself in addition to exporting it. Therefore when you install both v7.1.0 and v7.1.1, the v7.1.0 bundle will import the package from the other version instead of exporting the older version. The pilot--test-portlet correctly imports from version 7.1.1.



In other words, everything here is working the way it should.






share|improve this answer
























  • Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

    – Trio
    Nov 23 '18 at 14:38











  • You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

    – Trio
    Nov 23 '18 at 14:49











  • Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

    – Neil Bartlett
    Nov 23 '18 at 14:56











  • Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

    – Neil Bartlett
    Nov 23 '18 at 14:58











  • I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

    – Trio
    Nov 23 '18 at 16:01
















2














I recommend deleting the Import-Package instruction from your bnd.bnd file for the pilot--test-portlet bundle. It is not necessary: bnd will generate all the imports you need based on the actual requirements in your code.



Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. This is correct when your bundle makes use of the package itself in addition to exporting it. Therefore when you install both v7.1.0 and v7.1.1, the v7.1.0 bundle will import the package from the other version instead of exporting the older version. The pilot--test-portlet correctly imports from version 7.1.1.



In other words, everything here is working the way it should.






share|improve this answer
























  • Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

    – Trio
    Nov 23 '18 at 14:38











  • You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

    – Trio
    Nov 23 '18 at 14:49











  • Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

    – Neil Bartlett
    Nov 23 '18 at 14:56











  • Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

    – Neil Bartlett
    Nov 23 '18 at 14:58











  • I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

    – Trio
    Nov 23 '18 at 16:01














2












2








2







I recommend deleting the Import-Package instruction from your bnd.bnd file for the pilot--test-portlet bundle. It is not necessary: bnd will generate all the imports you need based on the actual requirements in your code.



Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. This is correct when your bundle makes use of the package itself in addition to exporting it. Therefore when you install both v7.1.0 and v7.1.1, the v7.1.0 bundle will import the package from the other version instead of exporting the older version. The pilot--test-portlet correctly imports from version 7.1.1.



In other words, everything here is working the way it should.






share|improve this answer













I recommend deleting the Import-Package instruction from your bnd.bnd file for the pilot--test-portlet bundle. It is not necessary: bnd will generate all the imports you need based on the actual requirements in your code.



Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. This is correct when your bundle makes use of the package itself in addition to exporting it. Therefore when you install both v7.1.0 and v7.1.1, the v7.1.0 bundle will import the package from the other version instead of exporting the older version. The pilot--test-portlet correctly imports from version 7.1.1.



In other words, everything here is working the way it should.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 14:56









Neil BartlettNeil Bartlett

21.2k22969




21.2k22969













  • Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

    – Trio
    Nov 23 '18 at 14:38











  • You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

    – Trio
    Nov 23 '18 at 14:49











  • Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

    – Neil Bartlett
    Nov 23 '18 at 14:56











  • Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

    – Neil Bartlett
    Nov 23 '18 at 14:58











  • I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

    – Trio
    Nov 23 '18 at 16:01



















  • Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

    – Trio
    Nov 23 '18 at 14:38











  • You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

    – Trio
    Nov 23 '18 at 14:49











  • Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

    – Neil Bartlett
    Nov 23 '18 at 14:56











  • Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

    – Neil Bartlett
    Nov 23 '18 at 14:58











  • I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

    – Trio
    Nov 23 '18 at 16:01

















Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

– Trio
Nov 23 '18 at 14:38





Hello Neil and thank you for the answer. If i remove Import-Package the import in manifest file becomes it.peernetwork.lr.pilot.testservices;version="[7.1,8)". This is ok in this scenario so i'll do it, but if i want (in another project maybe) refer to a specific version of a bundle, the way i was going is the correct one, right? Anyway, you sad: The pilot--test-portlet correctly imports from version 7.1.1. It does not. I have different log messages in these versions and i can tell the version used by pilot--test-portlet is 7.1.0. Maybe i am missing somethig...

– Trio
Nov 23 '18 at 14:38













You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

– Trio
Nov 23 '18 at 14:49





You said Your original bundle pilot--test-services both exports and imports the package it.peernetwork.lr.pilot.testservices. I do not understand what you mean with " both exports and imports"...i only export it...how do i import?

– Trio
Nov 23 '18 at 14:49













Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

– Neil Bartlett
Nov 23 '18 at 14:56





Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome.

– Neil Bartlett
Nov 23 '18 at 14:56













Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

– Neil Bartlett
Nov 23 '18 at 14:58





Regarding the import and export, you can see this in the manifest for pilot--test-services. Bnd has generated this because your bundle both exports the package and uses it internally. In order to reduce class space fragmentation, importing the package from the other version is better than creating a second export. I cannot see any good reason for exporting both version 7.1.0 and version 7.1.1 of the same package!

– Neil Bartlett
Nov 23 '18 at 14:58













I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

– Trio
Nov 23 '18 at 16:01





I've checked manifest file of pilot--test-services and there is the package both in import and export. Now i got it. Thank you. Oh yes I see. The "newer" bundle is importing from the "older" bundle. This is also a valid outcome: this means i have no "explicit" way to "choose" wich version of a service my portlet will use? OSGi loads "random" class and i can only undeploy old versions or change major release?

– Trio
Nov 23 '18 at 16:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390805%2fosgi-bundle-export-versioning%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules