curiousguy
curiousguy

Reputation: 3262

In Virgo-Server Import-Package could not be resolved.Caused by missing constraint in bundle constraint

I am very new in Java Spring framework. I have created a custom bundle and want to deploy the jar/bundle in virgo server.But I am not able to successfully do so.

Here is my template.mf file screen , where I have added the dependency

enter image description here

Here is my java file , where I have imported the packages

enter image description here

Here is the original jar file screen

enter image description here

Here is my pom.xml where I have added the dependency

enter image description here

But once deploying the jar file after maven build (which throws no error ) I am constantly getting the error

Caused by:  org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'com.xyz.costfromsap.application' at version '1.4.0.RELEASE': Cannot resolve: com.xyz.costfromsap.application
Resolver report:
    An Import-Package could not be resolved. Caused by missing constraint in bundle <com.xyz.costfromsap.application_1.4.0.RELEASE>
         constraint: <Import-Package: com.sap.conn.jco; version="[3.0.0,4.0.0)">

Here is my updated dependency jar file after converting it to OSGI bundler

enter image description here

I have also updated the template.mf and pom.xml

enter image description here enter image description here

But still the issue persists.

Upvotes: 0

Views: 1901

Answers (1)

shazin
shazin

Reputation: 21923

The issue is the sapjco3.jar is not an OSGi Bundle. It is just a plain old Jar file. You need convert it to an OSGi bundle. In Eclipse or any Eclipse variant follow the following steps. You can use Import-Package on only the packages which are listed in Export-Package in bundle MANIFEST.MF

New -> Project

enter image description here

Plugin from Existing Archive -> Add External and load your Jar and Click Next.

enter image description here

Give a name and Select an OSGi Framework radio button and Click finish.

enter image description here

Now you will have a new Project created. Go to MANIFEST.MF file and Runtime tab and Export Packages, Click Add button and select all the packages listed.

enter image description here

Finally your MANIFEST.MF should have Export-Package: with all the packages just as following.

enter image description here

And now Right Click on the project and Click Export and Select Java -> Jar File.

enter image description here

Select files to export. Ignore Eclipse specific files and pom files.

enter image description here

Click next until you see Manifest Selection and Select Use existing manifest option and select the MANIFEST.MF in META-INF in the project.

enter image description here

Click finish and Use that Jar in your Virgo server. Place it either in VIRGO_HOME/repository/usr.

Upvotes: 1

Related Questions