Hi,
I have some problems during the work .when I start the project, the error which mean
An Import-Package could not be resolved. Caused by missing constraint in bundle <com.fujitsu.storagesystem.evcp.EvcpService_3.0.0>
constraint: <Import-Package: org.quartz; version="0.0.0">
An Import-Package could not be resolved. Caused by missing constraint in bundle <org.quartz-scheduler.quartz_2.2.1>
constraint: <Import-Package: com.mchange.v2.c3p0; version="0.0.0">
appeared.I looked up the FAQ, and i put the 3rd party library(org.quartz) i need in Export-Package,Import-Package and write its classpath in the Bundle-ClassPath,but it still didn't work.
I tried to follow the QA "How to package a library as an OGSI bundle?",but when i create a temp.mf and click "run generation of MANIFEST.MF" ,the temp.mf has no change ,so this method i gave up. I also delete the
serves and create a new one to start ,it still here.
I want someone to help me ,how to do with this problem ,thanks!
Looking at your attached MANIFEST.MF it looks like you didn't understand the FAQ "How to use 3rd party java libraries?"
It starts with:
Your java plugin can use 3rd party jars if they are packaged as OSGI bundles (i.e. contain the correct OSGI metadata in order to be installed by the Virgo server) or are nested inside the plugin's bundle (see Note 1. below)
The "or" means you can't mix both solutions as you did.
Bundle-ClassPath: lib/stxs.jar,
lib/ganymed-ssh2.jar,
lib/vim25.jar,
lib/vsphere-client-lib.jar, => what is this library?
lib/ESFRMISample.jar,
lib/quartz/quartz-2.2.1.jar
.
Import-Package: org.apache.commons.logging,
com.vmware.vise.data,
com.vmware.vise.data.query,
com.vmware.vise.usersession,
com.vmware.vise.vim.data,
javax.crypto.spec,
javax.crypto,
javax.net.ssl,
org.osgi.framework,
com.vmware.vim25, |
com.ctc.wstx.stax, | => These 3 packages don't need to be imported because the libraries as included in the bundle
org.quartz |
Thank you for your reply.
the FAQ of SDK5.1 as bellow:
Your java plugin can use 3rd party jars as long as they are packaged as OSGI bundles, i.e. contain the correct OSGI metadata in order to be installed by the Virgo server. This metadata, in MANIFEST.MF, includes the list of packages exported by the library, in Export-Packages. In turn your java plugin's manifest should have the 3rd party's packages it uses in Import-Packages, so that Virgo can establish dependencies between your bundle and the 3rd party jars.
Once you have libraries packaged as OSGI bundles you need to copy them in a location known to the server:
For instance the vsphere-views sample uses two external libraries: gson-2.0.jar and vim25.jar. Its plugin-package.xml lists those two libraries at the top of bundlesOrder:
... <bundlesOrder&g; <!-- vim25 and gson are loaded first to satisfy dependencies --&g; <bundle id="com.vmware.wsvim25" /&g; <bundle id="com.google.gson" /&g; <bundle id="com.vmware.samples.custompropertyprovider" /&g; <bundle id="com.vmware.samples.custompropertyui" /&g; <bundle id="com.vmware.samples.viewspropertiesui" /&g; <bundle id="com.vmware.samples.wssdkprovider" /&g; <bundle id="com.vmware.samples.wssdkui" /&g; </bundlesOrder&g;
Note that in some cases a library that you need is already available in server/repository/usr as part of Virgo standard installation (you will get a deployment error if you try to deploy it a second time with your plugin package). In other cases you may want to use a different version that the one installed with Virgo. For instance you'd like to use httpclient-4.2 and Virgo contains only httpclient-4.0.1. This is not a problem: package httpclient-4.2.jar with your plugin and make sure to include the correct version number next to the package names in your Import-Packages. The correct library will be loaded by your plugin's class loader, it won't interfer with other bundles that may be using a different version, this is one of the advantages of OSGI 🙂
It dose not mention the solution " nested inside the plugin's bundle ", So for the SDK5.1, dose it support both two solutions which you replied?
The way OSGI bundles work is not related to the Web Client SDK version. The FAQ from SDK 5.5 has better information so you should look at it even if you are still using SDK 5.1.
Thank you for your help, I have solved the problem.
Hi Laurent,
I have really no idea how OSGi or bundles work, so excuse me if this question sounds a bit elementary. I'm developing a REST layer inside my vCenter 5.5 Adapter, and I'm running into severe issues while using Jersey 2.17 as the REST framework (I'm not using Maven, just the default ANT scripts that VMware bundles with its samples). I checked the jaxws-rs-xxxxx.jar file, and it appears to be a proper bundle. However, whatever I try, it does not get included by Virgo. It always complains that my service could not start due to a missing constraint with version 0.0.0 (even if I specify the version as:
Import-Package:
javax.ws.rs.client;version="2.0.1"
I even manually copied the JAR inside the Virgo server's ext (and then tried with usr) folder, but no luck. It just does not get included!
So in case I want to try the Bundle-ClassPath approach, what I don't understand is which path the following refers to:
Bundle-ClassPath:.,lib/xyz.jar
In the above example, where should the lib folder exist? Where the project root is? Where the manifest file is?
Please help! It's terribly frustrating working with OSGi when it simply does not allow any other way!
Regards.
I agree that OSGI can be frustrating the first time you are exposed to it. We tried to make our docs and FAQs as helpful as possible. Did you see the FAQ How to use 3rd party java libraries? It contains this note which answers your question:
The path in question starts at the root level of your bundle jar file. So if you use ".,lib/xyz.jar" instead then your need xyz.jar to be in a lib folder inside the bundle.
A bundle MANIFEST.MF is always located in the META-INF folder.
Hi Laurentsd,
I'm developing a REST layer inside vCenter6, and I'm having the issues while using 3rd party jersey-bundle-1.18.jar(Downloaded as an OSGI bundle)
As per the FAQ( using 3rd party jars), I have placed the jar in Virgo's server/repository/usr and restarted the server, under manifest.mf Dependencies->Import package am able to add com.sun.jersey.api.client(with version), Add virgo's usr location as STS build path to resolve STS buildpath issue, In ANT script I pointed the jar location to virgo's usr location and build success, while trying to deploy the bundle in dev environment I got the error,
An Import-Package could not be resolved. Resolver error data <Import-Package: com.sun.jersey.api.client; version="[1.18.0,1.18.0]">. Caused by missing constraint in bundle <com.mycompany.service.testservice_1.0.0>
constraint: <Import-Package: com.sun.jersey.api.client; version="[1.18.0,1.18.0]">
An Import-Package could not be resolved. Resolver error data <Import-Package: com.sun.grizzly.http; version="[1.9.0,2.0.0)">. Caused by missing constraint in bundle <com.sun.jersey.bundle_1.18.0>
constraint: <Import-Package: com.sun.grizzly.http; version="[1.9.0,2.0.0)">
Please help me to resolve this problem