You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by SapnaB <sa...@gmail.com> on 2014/06/17 02:54:37 UTC

Missing Constraint: Import-Package: com.sun.jersey.api.client

Hi All,

I have added some client code in my osgi bundle using jersey. I have added
jersey-bundle dependency in my pom.xml as below:
 <dependency>
	<groupId>com.sun.jersey</groupId>
	<artifactId>jersey-bundle</artifactId>
	<version>1.18.1</version>
</dependency>

The imported packages in my class are: com.sun.jersey.api.client.* and thats
why the Import Package section of pom.xml looks like:
 <Import-Package>
            com.sun.jersey.api.client,                        
            org.apache.felix.service.command,
            org.apache.felix.gogo.commands,
            org.apache.karaf.shell.console,
              *
 </Import-Package>

problem is after installation, once I start the bundle, I get the following
error:
Reason: Missing Constraint: Import-Package: com.sun.jersey.api.client;
version="[1.18.0,2.0.0)"

Im really not able to figure out what karaf is trying to say, since I can
see the following imports in my manifest:
Import-Package: com.sun.jersey.api.client;version="[1.18,2)",com.sun.jer
 sey.api.client.config;version="[1.18,2)",javax.ws.rs.core;version="[1.1
 ,2)",org.apache.felix.gogo.commands;version="[0.10,1)",org.apache.felix
 .service.command;version="[0.10,1)";status=provisional,org.apache.karaf
 .shell.console;version="[2.2,3)",org.osgi.service.blueprint;version="[1
 .0.0,2.0.0)"

Any help is greatly appreciated.

Thanks,
Sapna





--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by SapnaB <sa...@gmail.com>.
Hi All,

Thanks for the help. I was able to resolve the issue by installing
jersey-client using the wrap command.
Package *com.sun.jersey.api.client* is under jerser-client jar which was
earlier not installed in Karaf.

Thanks,
Sapna



--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033590.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Christian Schneider <ch...@die-schneider.net>.
Try the command package:exports . It lists all exported packages and the 
bundles that export them. You will also see the exported version there.
Compare that with the imports you see from headers <bundleid> of your 
own bundle. If the import range matches the exports then it works.

If the jersey bundles are not already osgi bundles then the wrap command 
will export the package but not add a version. So an import with a range 
will fail.
So defining the import by hand in the maven bundle plugin config without 
a version should help. You can also add parameters for the wrap to 
specify the exported package version but this may be more diffult to 
achieve.

An even better option may be to try the jersey bundle from servicemix 
bundles :
<dependency>
     <groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.jersey-core</artifactId>
     <version>1.11_1</version>
</dependency>

They should have correct exports.

Christian


Am 17.06.2014 09:09, schrieb SapnaB:
> Did that too.. Uninstalled all the jersey jars I had deployed earlier on
> Karaf, and re-deployed using the wrap command. Also re-installed my bundle..
> but the problem still exists.
>
> I wish Karaf gave more explanatory error messages. I really cant find
> anything to resolve this exception :(
>
> Unable to start bundle 402: The bundle "Test_0.0.1.SNAPSHOT [402]" could not
> be resolved. Reason: Missing Constraint: Import-Package:
> com.sun.jersey.api.client; version="[1.18.0,2.0.0)"
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033565.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Rajbir Saini <ra...@yahoo.com.INVALID>.
Try removing the version numbers from imported packages. It may be 
version in your development environment are not the same in Karaf.

On Tuesday 17 June 2014 12:39 PM, SapnaB wrote:
> Did that too.. Uninstalled all the jersey jars I had deployed earlier on
> Karaf, and re-deployed using the wrap command. Also re-installed my bundle..
> but the problem still exists.
>
> I wish Karaf gave more explanatory error messages. I really cant find
> anything to resolve this exception :(
>
> Unable to start bundle 402: The bundle "Test_0.0.1.SNAPSHOT [402]" could not
> be resolved. Reason: Missing Constraint: Import-Package:
> com.sun.jersey.api.client; version="[1.18.0,2.0.0)"
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033565.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>


Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by SapnaB <sa...@gmail.com>.
Did that too.. Uninstalled all the jersey jars I had deployed earlier on
Karaf, and re-deployed using the wrap command. Also re-installed my bundle..
but the problem still exists.

I wish Karaf gave more explanatory error messages. I really cant find
anything to resolve this exception :(

Unable to start bundle 402: The bundle "Test_0.0.1.SNAPSHOT [402]" could not
be resolved. Reason: Missing Constraint: Import-Package:
com.sun.jersey.api.client; version="[1.18.0,2.0.0)"



--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033565.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Rajbir Saini <ra...@yahoo.com.INVALID>.
If Jersey jars are OSGi bundle you can install them using bundle:install 
command. Syntax is:
bundle:install mvn:<groupid>/<bundleid>/version no

If Jersey jars are not OSGi bundles you can use wrap protocol to convert 
a plain jar into OSGi bundle
bundle:install wrap:mvn:<groupid>/<bundleid>/version.

Thanks,

Raj

On Tuesday 17 June 2014 12:24 PM, SapnaB wrote:
> Is there a way I can add jersey jars as bundles in Karaf libs. That way when
> I start Karaf, these bundles will be loaded at startup and all the classes
> will be available at runtime.
>
> >From the error message, I understand that Karaf is unable to resolve this
> dependency:
> Reason: Missing Constraint: Import-Package: com.sun.jersey.api.client;
> version="[1.18.0,2.0.0)"
>
> -Sapna
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033562.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>


Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by SapnaB <sa...@gmail.com>.
Is there a way I can add jersey jars as bundles in Karaf libs. That way when
I start Karaf, these bundles will be loaded at startup and all the classes
will be available at runtime.

>From the error message, I understand that Karaf is unable to resolve this
dependency:
Reason: Missing Constraint: Import-Package: com.sun.jersey.api.client;
version="[1.18.0,2.0.0)"

-Sapna




--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033562.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Matt Sicker <bo...@gmail.com>.
Well, if they show up in red, that means they're unsatisfied. Check the
headers for the dependencies as well to make sure they're exporting
everything properly. Sometimes you need to install artifacts with wrap:
before the mvn: to add OSGi metadata.


On 16 June 2014 23:10, SapnaB <sa...@gmail.com> wrote:

> Hi Matt,
>
> I get manifest headers as well as the import/export packages with
> dependencies, when I run osgi:headers on the above Bundle ids. The command
> run on my bundle gives:
>
> Apache Karaf :: Shell test/test-mcds Commands (370)
> -------------------------------------------------------
> Manifest-Version = 1.0
> Bnd-LastModified = 1402976384349
> Tool = Bnd-1.50.0
> Built-By = sapbharg
> Build-Jdk = 1.6.0_24
> Created-By = Apache Maven Bundle Plugin
>
> Bundle-Name = Apache Karaf :: Shell test/test-mcds Commands
> Bundle-Description = Provides the test custom command
> Bundle-SymbolicName = Test
> Bundle-Version = 0.0.1.SNAPSHOT
> Bundle-ManifestVersion = 2
>
> Import-Package =
>         com.sun.jersey.api.client;version="[1.18,2)",
>         com.sun.jersey.api.client.config;version="[1.18,2)",
>         javax.ws.rs.core;version="[1.1,2)",
>         org.apache.felix.gogo.commands;version="[0.10,1)",
>
> org.apache.felix.service.command;status=provisional;version="[0.10,1)",
>         org.apache.karaf.shell.console;version="[2.2,3)",
>         org.osgi.service.blueprint;version="[1.0.0,2.0.0)"
> Export-Package =
>         test.command;
>                 uses:="org.apache.karaf.shell.console,
>                         com.sun.jersey.api.client.config,
>                         org.apache.felix.gogo.commands,
>                         com.sun.jersey.api.client,
>                         javax.ws.rs.core";
>                 version=0.0.1.SNAPSHOT
>
> Is there anything specific ur looking at?
>
> -Sapna
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033556.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by SapnaB <sa...@gmail.com>.
Hi Matt,

I get manifest headers as well as the import/export packages with
dependencies, when I run osgi:headers on the above Bundle ids. The command
run on my bundle gives:

Apache Karaf :: Shell test/test-mcds Commands (370)
-------------------------------------------------------
Manifest-Version = 1.0
Bnd-LastModified = 1402976384349
Tool = Bnd-1.50.0
Built-By = sapbharg
Build-Jdk = 1.6.0_24
Created-By = Apache Maven Bundle Plugin

Bundle-Name = Apache Karaf :: Shell test/test-mcds Commands
Bundle-Description = Provides the test custom command
Bundle-SymbolicName = Test
Bundle-Version = 0.0.1.SNAPSHOT
Bundle-ManifestVersion = 2

Import-Package = 
	com.sun.jersey.api.client;version="[1.18,2)",
	com.sun.jersey.api.client.config;version="[1.18,2)",
	javax.ws.rs.core;version="[1.1,2)",
	org.apache.felix.gogo.commands;version="[0.10,1)",
	org.apache.felix.service.command;status=provisional;version="[0.10,1)",
	org.apache.karaf.shell.console;version="[2.2,3)",
	org.osgi.service.blueprint;version="[1.0.0,2.0.0)"
Export-Package = 
	test.command;
		uses:="org.apache.karaf.shell.console,
			com.sun.jersey.api.client.config,
			org.apache.felix.gogo.commands,
			com.sun.jersey.api.client,
			javax.ws.rs.core";
		version=0.0.1.SNAPSHOT

Is there anything specific ur looking at?

-Sapna




--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033556.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Matt Sicker <bo...@gmail.com>.
What do you get when you run headers on those bundle IDs? Or running diag?


On 16 June 2014 22:45, SapnaB <sa...@gmail.com> wrote:

> Hi Matt,
>
> I installed all the required jersey jars in karaf and started them too as
> below:
>
> install mvn:com.sun.jersey/jersey-core/1.18.1
> install mvn:com.sun.jersey/jersey-server/1.18.1
> install mvn:javax.ws.rs/jsr311-api/1.1.1
> install mvn:com.sun.jersey/jersey-json/1.18.1
> install mvn:org.codehaus.jackson/jackson-core-asl/1.9.2
> install mvn:org.codehaus.jackson/jackson-jaxrs/1.9.2
> install mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.2
> install mvn:org.codehaus.jettison/jettison/1.1
> start 362 363 364 365 366 367 368 369
>
> But I still get the same error on starting my bundle:
> Unable to start bundle 370: The bundle "Test_0.0.1.SNAPSHOT [370]" could
> not
> be resolved. Reason: Missing Constraint: Import-Package:
> com.sun.jersey.api.client; version="[1.18.0,2.0.0)"
>
> -Sapna
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033554.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by SapnaB <sa...@gmail.com>.
Hi Matt,

I installed all the required jersey jars in karaf and started them too as
below:

install mvn:com.sun.jersey/jersey-core/1.18.1
install mvn:com.sun.jersey/jersey-server/1.18.1
install mvn:javax.ws.rs/jsr311-api/1.1.1
install mvn:com.sun.jersey/jersey-json/1.18.1
install mvn:org.codehaus.jackson/jackson-core-asl/1.9.2
install mvn:org.codehaus.jackson/jackson-jaxrs/1.9.2
install mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.2
install mvn:org.codehaus.jettison/jettison/1.1
start 362 363 364 365 366 367 368 369

But I still get the same error on starting my bundle:
Unable to start bundle 370: The bundle "Test_0.0.1.SNAPSHOT [370]" could not
be resolved. Reason: Missing Constraint: Import-Package:
com.sun.jersey.api.client; version="[1.18.0,2.0.0)"

-Sapna




--
View this message in context: http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550p4033554.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Missing Constraint: Import-Package: com.sun.jersey.api.client

Posted by Matt Sicker <bo...@gmail.com>.
Do you have the jersey client installed in karaf, too?


On 16 June 2014 19:54, SapnaB <sa...@gmail.com> wrote:

> Hi All,
>
> I have added some client code in my osgi bundle using jersey. I have added
> jersey-bundle dependency in my pom.xml as below:
>  <dependency>
>         <groupId>com.sun.jersey</groupId>
>         <artifactId>jersey-bundle</artifactId>
>         <version>1.18.1</version>
> </dependency>
>
> The imported packages in my class are: com.sun.jersey.api.client.* and
> thats
> why the Import Package section of pom.xml looks like:
>  <Import-Package>
>             com.sun.jersey.api.client,
>             org.apache.felix.service.command,
>             org.apache.felix.gogo.commands,
>             org.apache.karaf.shell.console,
>               *
>  </Import-Package>
>
> problem is after installation, once I start the bundle, I get the following
> error:
> Reason: Missing Constraint: Import-Package: com.sun.jersey.api.client;
> version="[1.18.0,2.0.0)"
>
> Im really not able to figure out what karaf is trying to say, since I can
> see the following imports in my manifest:
> Import-Package: com.sun.jersey.api.client;version="[1.18,2)",com.sun.jer
>  sey.api.client.config;version="[1.18,2)",javax.ws.rs.core;version="[1.1
>  ,2)",org.apache.felix.gogo.commands;version="[0.10,1)",org.apache.felix
>  .service.command;version="[0.10,1)";status=provisional,org.apache.karaf
>  .shell.console;version="[2.2,3)",org.osgi.service.blueprint;version="[1
>  .0.0,2.0.0)"
>
> Any help is greatly appreciated.
>
> Thanks,
> Sapna
>
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Missing-Constraint-Import-Package-com-sun-jersey-api-client-tp4033550.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>