Reputation: 1021
I have a simple OSGi bundle written and here is the source file. When I install it in a equinox OSGi container it does not get resolved it automatically. Can someone explain what I'm doing wrong here??.
package org.sample.api;
/**
* Created on 3/11/14.
*/
public interface Hello {
void sayHello();
}
This is the pom.xml file of the bundle.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>osgi</artifactId>
<groupId>osgi</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sample-api</artifactId>
<version>1.0</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Vendor>Sample Inc</Bundle-Vendor>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
org.sample.api*;version=1.0.0
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
MANIFEST.MF
Manifest-Version: 1
Bnd-LastModified: 1396602001251
Build-Jdk: 1.6.0_45
Built-By: Zeus
Bundle-ManifestVersion: 2
Bundle-Name: sample-api
Bundle-SymbolicName: sample-api
Bundle-Vendor: Sample Inc
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: org.sample.api;version="1.0.0"
Tool: Bnd-1.43.0
This is the bundle installation console output
Bundle id is 7
RegisteredServices null
ServicesInUse null
LoaderProxy sample-api; bundle-version="1.0.0"
Fragments null
ClassLoader null
Version 1.0.0
LastModified 1396605985751
Headers Bnd-LastModified = 1396602001251
Build-Jdk = 1.6.0_45
Built-By = Zeus
Bundle-ManifestVersion = 2
Bundle-Name = sample-api
Bundle-SymbolicName = sample-api
Bundle-Vendor = Sample Inc
Bundle-Version = 1.0.0
Created-By = Apache Maven Bundle Plugin
Export-Package = org.sample.api;version="1.0.0"
Manifest-Version = 1
Tool = Bnd-1.43.0
BundleContext null
BundleId 7
StartLevel 1
SymbolicName sample-api
BundleData sample-api_1.0.0
KeyHashCode 7
StateChanging null
BundleDescription sample-api_1.0.0
Framework org.eclipse.osgi.framework.internal.core.Framework@65cb687f
ResolutionFailureException org.osgi.framework.BundleException: The bundle "sample-api_1.0.0 [7]" could not be resolved
Revisions [sample-api_1.0.0]
Key 7
ProtectionDomain null
Location file:/home/Zeus/idea-projects/osgi/sample-api/target/sample-api-1.0.jar
State 2
Bundle 7|Installed | 1|sample-api (1.0.0)
Upvotes: 0
Views: 2896
Reputation: 23958
INSTALLED state is not an error condition. It just means that the bundle has been installed, which is true.
If you do see an actual error message, please provide the details.
Upvotes: 0
Reputation: 5285
Looks like you don't have a Activator with your bundle, at least your given sample doesn't contain one and your output for the generated Manifest doesn't contain a Bundle-Activator part. At this point I'd say your bundle is just in resolved state since it can't be active.
Upvotes: 0
Reputation: 116
Please post the generated MANIFEST.MF from the jar. I cant see anything wrong with the pom.
If the bundle is not resolved, in what state is it then? Installed? One possible reason could be that some of the transitive dependencies of the bundle are not available on the container.
P.S: You may want to use the latest version 2.4.0 for the maven-bundle-plugin.
EDIT1 This is the manifest I got:
Manifest-Version: 1.0
Bnd-LastModified: 1396605817562
Build-Jdk: 1.7.0_45
Built-By: anshuman
Bundle-ManifestVersion: 2
Bundle-Name: sample-api
Bundle-SymbolicName: sample-api
Bundle-Vendor: Sample Inc
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: org.sample.api;version="1.0.0"
Tool: Bnd-2.1.0.20130426-122213
EDIT2
I hope you are refreshing and starting the bundle after you install it.
refresh 7
start 7
where 7 is your bundle id.
Upvotes: 1