I am trying to migrate our bnd(OSGI) project from java 8 to 9. After first fail i have prepared basic project. However, I got stuck in problems with java versions capability, exacly like bellow (just a part of them, but all are the same with difference to the java version):
! Failed to start bundle org.apache.felix.gogo.command-1.0.2, exception
Could not resolve module: org.apache.felix.gogo.command [12]
Unresolved requirement: Import-Package: org.apache.felix.service.command; version="[1.0.0,2.0.0)"
-> Export-Package: org.apache.felix.service.command; bundle-symbolic-name="org.apache.felix.gogo.runtime"; bundle-version="1.0.0"; version="1.0.0"
org.apache.felix.gogo.runtime [2]
Unresolved requirement: Import-Package: org.osgi.service.event; version="[1.3.0,2.0.0)"; resolution:="optional"
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))"
org.osgi.framework.BundleException: Could not resolve module: org.apache.felix.gogo.command [12]
Unresolved requirement: Import-Package: org.apache.felix.service.command; version="[1.0.0,2.0.0)"
-> Export-Package: org.apache.felix.service.command; bundle-symbolic-name="org.apache.felix.gogo.runtime"; bundle-version="1.0.0"; version="1.0.0"
org.apache.felix.gogo.runtime [2]
Unresolved requirement: Import-Package: org.osgi.service.event; version="[1.3.0,2.0.0)"; resolution:="optional"
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))"
First what I have done was update all dependencies - didn't help though.
I have googled a lot, but with just a few links resulted.
The one which was the closest to the problem didn't help thought - I have added following lines, without result:
run.bndrun
Bundle-RequiredExecutionEnvironment: JavaSE-9
Provide-Capability: osgi.ee;osgi.ee="JavaSE";version:List="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,9"
Maybe upgrade my bnd gradle plugin would help, however the version (I am currently using 3.5) mentioned (4.0) at readme is not available in mavenCentral.
My project specification - basic example repo
Eclipse Oxygen.3a Release (4.7.3a)
Bndtools 3.5.0.REL
Java 9.0.4+11
OSGI 6.0
Gradle 4.4
Gradle bnd plugin - 3.5
BTW: If you are trying to run project in Intellij, problems can occur - at least we didn't cope to run our main project.
Any help would be appreciated, I will do my best to provide you more info if required.
Update
Even when i delete nearly all dependencies (cleaned branch), after launch run.bndrun I am receiving only
could not resolve the bundles: [project.main-1.0.0.201804171613 org.osgi.framework.BundleException: Could not resolve module: project.main [3]
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
]
Failed to start bundle project.main-1.0.0.201804171613, exception Could not resolve module: project.main [3]
Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
project.main is my only bundle.
Bnd 4.0 is not yet released. So it is not in maven central currently.
Also, you need to make sure the version of the Felix framework understands Java 9 and can properly provide the Java 9 ee.
As i mentioned in a comment we have dedpendency to enroute 2.0, which provides old version of org.eclipse.osgi. After manual update to 3.13 problems with Require-capability have disappeared.
Related
I wrote a Liferay module and deployed it successfully.
Then I added this line in build.gradle's dependencies section:
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
After running ./gradlew eclipse I can use the library with no problem in Eclipse. But deployment fails:
12:29:35,454 WARN [fileinstall-/home/nico/liferay/osgi/modules][org_apache_felix_fileinstall:103] Error while starting bundle: file:/home/nico/liferay-dxp-digital-enterprise-7.0-sp3/osgi/modules/de.nico.mymodule-1.0.0.jar
org.osgi.framework.BundleException: Could not resolve module: de.nico.mymodule [1085]_ Unresolved requirement: Import-Package: org.apache.http; version="4.5.3"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:429)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)
I have no idea why it is looking for org.apache.http and not org.apache.httpcomponents.
Here is my bnd.bnd:
Bundle-SymbolicName: de.nico.mymodule
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
How to investigate this problem?
I don't want to download/add the JAR manually.
In your bnd.bnd
add this code ..
Import-Package:\
!org.apache.*,\
\
*
the further investigations will start at the exception messsage. It says that the following requirement is not present at RUNTIME:
Import-Package: org.apache.http; version="4.5.3"
I'm assuming that it's one of the following:
you didn't deploy the httpcomponents (or a version you need .. see Semantic Versioning) libraries to Liferay (as compile works, while deployment fails)
httpcomponents might not be packaged as OSGi bundles. In that case you'll have to decide how to make the code available. Good starting points for more information are the official docs (thanks Andrea, promoting this from the comments) and David Nebinger's blog article
How you add those dependencies to Liferay's runtime is up to you. If the dependencies are OSGi bundles, you can download&deploy them directly. If they're no OSGi bundles, follow one of the techniques described in the linked articles.
I have an Eclipse RCP-based application that has a dependency on a bundle that requires sun.misc. At start time, it is not resolved because it can't find the package:
id State Bundle
150 INSTALLED org.diirt.support.diirt-pva_3.1.6.20170118092719
osgi> start 150
gogo: BundleException: Could not resolve module: org.diirt.support.diirt-pva [150]
Unresolved requirement: Import-Package: org.epics.pvaccess; version="[4.1.0,5.0.0)"
-> Export-Package: org.epics.pvaccess; bundle-symbolic-name="org.epics.pvAccessJava"; bundle-version="4.1.3"; version="4.1.3"; uses:="org.epics.pvdata.pv"
org.epics.pvAccessJava [307]
Unresolved requirement: Import-Package: sun.misc
Meanwhile in the built product's plugins directory is com.diffplug.osgi.extension.sun.misc_0.0.0.jar. This provides the package sun.misc:
Manifest-Version: 1.0
Export-Package: sun.misc
Fragment-Host: system.bundle; extension:=framework
Bundle-ManifestVersion: 2
Bundle-License: public domain - http://unlicense.org/
Bundle-SymbolicName: com.diffplug.osgi.extension.sun.misc
Bundle-Version: 0.0.0
However, this is not loaded when the application starts:
osgi> ss diff
"Framework is launched."
id State Bundle
Why is this required bundle not loaded?
Incidentally, this plugin is required in a feature that is included in the product.
As far as I can tell, sun.misc should be resolvable in com.diffplug.osgi:com.diffplug.osgi.extension.sun.misc:0.0.0
Perhaps you could try adding this to your project?
I am working with a Core for SDN network and I have fails with Karaf module when I type this command:
feature:install core
Could not start bundle mvn:eu.netide.lib/netip/1.1.0-SNAPSHOT in feature(s) core-api-1.1.0-SNAPSHOT: Unresolved constraint in bundle netip [85]: Unable to resolve 85.0: missing requirement [85.0] osgi.wiring.package; (osgi.wiring.package=org.projectfloodlight.openflow.exceptions)
Somebody can help me?
Thanks
"osgi.wiring.package" errors occur because of the lack of dependency in your feature.xml file. You have to add the dependant bundle "org.projectfloodlight.openflow.exceptions" to the core feature in your feature.xml file which would solve your problem. If not; you have to make sure that your pom.xml dependency for the corresponding floodlight library is not marked as "provided".
I am attempting to run an application on Apache Felix, using the Felix Dependency bundles. The container is, for some reason, not loading my bundles.
I am doing my development using Bndtools in Eclipse. I am using the Amdatu bundles.
The bundles I am concerned about are the bundles that are in my "Run Requirements":
org.apache.felix.dependencymanager
org.apache.felix.dependencymanager.shell
org.apache.felix.dependencymanager.runtime
osgi.core
osgi.cmpn
All of the above bundles are taken from the Amdatu repository.
I have two bundles which I created:
com.test.demo.reader
com.test.demo.listener
And these bundles are built using org.apache.felix.dependencymanager and osgi.core.
When I attempt to run OSGi, I am getting the following failures:
! could not resolve the bundles: [com.test.demo.reader-1.0.0 Unresolved constraint in bundle
com.test.demo.reader [8]: Unable to resolve 8.0: missing requirement
[8.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)(!(version>=4.0.0))),
com.test.demo.listener-1.0.0 Unresolved constraint in bundle com.test.demo.listener [9]:
Unable to resolve 9.0: missing requirement [9.0] osgi.wiring.package;
(&(osgi.wiring.package=com.test.demo.reader)(version>=1.0.0)(!(version>=2.0.0)))
[caused by: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package;
(&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)(!(version>=4.0.0)))]]
and
! Failed to start bundle com.test.demo.reader-1.0.0, exception Unresolved constraint in
bundle com.test.demo.reader [8]: Unable to resolve 8.0: missing requirement [8.0]
osgi.wiring.package; (&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)
(!(version>=4.0.0)))
and more
! Failed to start bundle com.test.demo.listener-1.0.0, exception Unresolved constraint in
bundle com.test.demo.listener [9]: Unable to resolve 9.0:
missing requirement [9.0] osgi.wiring.package; (&(osgi.wiring.package=com.test.demo.reader)
(version>=1.0.0)(!(version>=2.0.0))) [caused by: Unable to resolve 8.0: missing requirement
[8.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)
(!(version>=4.0.0)))]
I think I understand what is happening: apparently the org.apache.dm package being used is a version that is somehow incompatible with my bundles. But that doesn't make any sense, because according to the Felix documentation the org.apache.dm package is in the org.apache.felix.dependencymanager bundle. That bundle is from the Amdatu repository and it is the only version of the bundle I am using with my application! How is the version incompatible with my bundles when theirs is the only version that my bundles know about???
Someone please advise. What is causing this failure an how can I fix it?
The problem was the runtime I was running and what appears to be a bug in the Amdatu plugin.
I would not advise using the Amdatu configuration in your OSGi project. Not in its current form.
The various Felix Dependency bundles that I have been using from Amdatu are apparently intended to run under Felix version 5. Unfortunately, the Amdatu environment (the "Amdatu Configuration" that you can select when you choose a configuration template for your project) does not load Version 5. When you select the "Bundle- Hub configuration", your choice of runtime environments includes all Felix environments from Version 4.0.2 to Version 5.2, as well as several versions of Equinox. When you select the "Amdatu Configuration" you only runtime choices are Felix 4.0.2 and Felix 4.2.0.
I was using 4.2.0 Felix, and as a result the dependency bundles were not working.
The Amdatu environment in its current form is unusable in Bndtools. It apparently supplies the right bundles for Version 5 but does not provide that environment for the user.
I did try manually changing the runtime environment io Version 5.2. This did not work because apparently when you select a template, Bndtools puts together whatever runtimes are associated with the template. Because the Amdatu template does not include Felix version 5, the runtime environment is unavailable.
In order to get my application to run, I had to create a new project that used the "Bundle- Hub" template and manually download the dependency bundles from the Felix website and include them in my buil and runtime environments. Unfortunately, neither Bndtools nor Amdatu provides any way to add the Amdatu bundles to project after a template is selected. This means that instead of using the ready- made bundles from Amdatu, you have to go out to the source sites and manually include them.
I will probably ty and find a way to create a new repository that can be included in projects and contains all the Amdatu bundles, then include that repository in the "Bundle- Hub" template. I will also report the problems with environments (as well as seversl other problems I've seen) to the Amdatu folks.
In the meantime, my application runs smoothly now that I have set up the right runtime environment.
Special thanks to earcam, whose questions in the comment above gave me a clue as to what to start looking at to solve this problem...
I have a large Java application that's mostly networking and file processing with lots of DB access. There's no UI. We expose a few web services (embedded Netty) and call some external rest web services. The project is built with Ant. It's about 10 different jars plus maybe 30-40 libraries.
My current task is to move the project to the OSGi framework. I am startling slowly.
Following the examples in "OSGi In Action" chapter 6, I have used the BND ant task to put the entire project into one huge jar file. This worked. I am able to run the program using java -jar. Here's my current .bnd file:
-output: bundle/MerchantServicesBundle.jar
-include: manifest/merchantservices.manifest
Bundle-Name: MerchantServices
Bundle-SymbolicName: com.shopping.services.merchant
Bundle-Version: 4.1
Main-Class: com.shopping.merchant.services.netty.MerchantServices
Class-Path: /home/ppantera/repositories/MerchantJava/modules/MerchantServices/conf/
Private-Package: *
I am using Apache Felix 4.0.3. From the Gogo shell I can install the bundle but when I start it I get this:
org.osgi.framework.BundleException: Unresolved constraint in bundle com.shopping.services.merchant [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (osgi.wiring.package=android.dalvik)
Why does Felix think this is an Android project?
There doesn't seem to be much about this on the 'net. Would you recommend using an older version of Felix so I'm sheltered from the newer OSGi features that could cause me confusion?
I tried adding this to my .bnd file:
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version>=1.7))"
That didn't help. What am I doing wrong? Any other pointers?
It looks like somehow bnd detected a requirement to an Android package, and added that to the MANIFEST.MF, it could be in your code, but could also be in one of your 3rd party libraries.
Check your manifest to be sure, I guess you'll find something like
Import-Package:android.dalvik.
If that's the case you can test the bundle by manually removing that header and see if that helps. When you've got that clear, you can resolve it for example by making that import optional in bnd.
One of easy solution is:
Go to FuseESB console:
Type the command:
osgi:install mvn:commons-io/commons-io/2.1
Replace 'common's-io' with your your dependency's group id and artifact id (Maven)
e.g my dependency was:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
Cheers