Unresolved constraint when trying to export a simple interface - java

I'm trying to take the first steps in familiarizing myself to OSGI framework.
However, I'm not even able to start the bundle which only exports one package, nothing more.
The error the framework shows sounds ridiculous to me as I read it as 'In order to start your bundle I need to resolve openjsip.service.locationservice package.
But this package comes from my bundle !
Anyway, I think I'm wrong, but I can't grasp the problem, could somebody help me ?
ERROR: Bundle openjsip.locationservice [6] Error starting file:////tmp/locationservice-1.0.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle openjsip.locationservice [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (&(osgi.wiring.package=openjsip.service.locationservice)(version>=1.0.0)))
org.osgi.framework.BundleException: Unresolved constraint in bundle openjsip.locationservice [6]: Unable to resolve 6.0: missing requirement [6.0] osgi.wiring.package; (&(osgi.wiring.package=openjsip.service.locationservice)(version>=1.0.0))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
at java.lang.Thread.run(Thread.java:722)
Here is my MANIFEST.MF:
Manifest-Version: 1.0
Bnd-LastModified: 1348338100498
Build-Jdk: 1.7.0_05
Built-By: devel
Bundle-ManifestVersion: 2
Bundle-Name: locationservice
Bundle-SymbolicName: openjsip.locationservice
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: openjsip.service.locationservice;uses:="javax.sip.header
,javax.sip";version="1.0.0.SNAPSHOT"
Import-Package: javax.sip;version="[1.2,2)",javax.sip.header;version="[1
.2,2)"
Tool: Bnd-1.50.0

The error message doesn't seem to match the MANIFEST.MF you have posted. Is it possible that you have rebuilt it in-between?
The error message says that your bundle imports the package openjsip.service.locationservice, and that import could not be resolved. However according to the manifest you only import javax.sip and javax.sip.header. Therefore this error message could not have come from the bundle manifest posted.

Thanks everybody for help, the issue was really with IDEA configuration, where it creates MANIFEST.MF by itself using facet configuration (which I left empty relying on apache maven plugin). For some reason it ignores this plugin or can't work in pair with it yet.
The resolution was to tell it 'Use predefined MANIFEST.MF from target/classes/META-INF'.
Thanks again.

Related

Eclipse RCP: Missing required plug-in during export

When I try to export my Eclipse RCP product, I received the following error:
Processing inclusion from feature org.eclipse.pde.container.feature: Bundle org.apache.batik.dom.svg_1.6.0.v200805290154 failed to resolve.:
Missing required plug-in org.apache.batik.css_0.0.0.
Missing required plug-in org.apache.batik.dom_0.0.0.
Missing required plug-in org.apache.batik.parser_0.0.0.
Missing required plug-in org.apache.batik.util_0.0.0.
Missing required plug-in org.w3c.css.sac_0.0.0.
Missing required plug-in org.w3c.dom.smil_0.0.0.
Missing required plug-in org.w3c.dom.svg_0.0.0.
I already tried to follow the answer from this question; but it didn't work.
The required bundle inside MANIFEST.MF of the plugin org.apache.batik.dom.svg which cause the error are:
Bundle-SymbolicName: org.apache.batik.dom.svg
Require-Bundle: org.apache.batik.css;version="[1.6.0,1.7.0)",
org.apache.batik.dom;version="[1.6.0,1.7.0)",
org.apache.batik.parser;version=" [1.6.0,1.7.0)",
org.apache.batik.util;version="[1.6.0,1.7.0)",
org.w3c.css.sac;version="[1.3.0,1.4.0)",
org.w3c.dom.smil;version="[1.0.0,1.1.0)",
org.w3c.dom.svg;version="[1.1.0,1.3.0)"
Export-Package: org.apache.batik.dom.svg;version="1.6.0",
org.apache.ba tik.dom.svg12;version="1.6.0"
Bundle-Version: 1.6.0.v200805290154
Can someone help me with this error?

Integrating external library into OSGI

I have been trying to fix this issue for several days now, but i seem stuck somehow. I want to develop a OSGi bundle, and my implementation requires an external library (that has some more dependencies). The situation is as follows: My project is using gradle and i got a simple code snippet to compile, but it crashes at runtime when the bundle is launched ( i am using apache felix), giving me an exception complaining about unmet dependencies. But all libraries are present in the jar bundle, and i added them into the classpath. The missing package org.ethereum.facade is listed within Private-Packages.
I read a lot of questions with similar problems, but none of the silutions proposed seems to solve my problem.
I am posting my gradle.build files
// ETHEREUM NODE
configurations.create('embed')
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://dl.bintray.com/ethereum/maven"
}
}
dependencies {
// This will compile the openMuc Framework and place the result into the build classpath:
compile project(':openmuc-core-api')
// This will place the etherum libraries into the classpath
compile ("org.ethereum:ethereumj-core:latest.release")
embed ("org.ethereum:ethereumj-core:latest.release")
}
jar {
manifest {
name = 'OpenMUC App - EthereumNode'
instruction 'Bundle-ClassPath', 'lib/ethereumj-core-1.4.2-RELEASE.jar,.'
}
into('lib') {
from configurations.embed
}
}
The resulting jar:
[MANIFEST openmuc-app-ethereumNode-0.16.0.jar]
Bnd-LastModified 1490003658351
Bundle-ClassPath lib/ethereumj-core-1.4.2-RELEASE.jar,.
Bundle-ManifestVersion 2
Bundle-Name OpenMUC App - EthereumNode
Bundle-SymbolicName org.openmuc.framework.openmuc-app-ethereumNode
Bundle-Version 0.16.0
Created-By 1.8.0_25 (Oracle Corporation)
Export-Package org.openmuc.framework.app.ethereumNode;version="0.16.0";uses:="javax.xml.bind,org.osgi.service.component"
Import-Package javax.xml.bind,org.osgi.service.component;version="[1.2,2)",org.slf4j;version="[1.7,2)",org.ethereum.facade
Manifest-Version 1.0
Private-Package genesis,org.ethereum,org.ethereum.cli,org.ethereum.config,org.ethereum.config.blockchain,org.ethereum.config.net,org.ethereum.core,org.ethereum.core.genesis,org.ethereum.crypto,org.ethereum.crypto.cryptohash,org.ethereum.crypto.jce,org.ethereum.datasource,org.ethereum.datasource.inmem,org.ethereum.datasource.leveldb,org.ethereum.datasource.mapdb,org.ethereum.db,org.ethereum.db.index,org.ethereum.facade,org.ethereum.json,org.ethereum.jsonrpc,org.ethereum.listener,org.ethereum.manager,org.ethereum.mine,org.ethereum.net,org.ethereum.net.client,org.ethereum.net.dht,org.ethereum.net.eth,org.ethereum.net.eth.handler,org.ethereum.net.eth.message,org.ethereum.net.message,org.ethereum.net.p2p,org.ethereum.net.rlpx,org.ethereum.net.rlpx.discover,org.ethereum.net.rlpx.discover.table,org.ethereum.net.server,org.ethereum.net.shh,org.ethereum.net.submit,org.ethereum.net.swarm,org.ethereum.net.swarm.bzz,org.ethereum.samples,org.ethereum.solidity,org.ethereum.solidity.compiler,org.ethereum.sync,org.ethereum.trie,org.ethereum.util,org.ethereum.util.blockchain,org.ethereum.validator,org.ethereum.vm,org.ethereum.vm.program,org.ethereum.vm.program.invoke,org.ethereum.vm.program.listener,org.ethereum.vm.trace,lib
Require-Capability osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Service-Component OSGI-INF/org.openmuc.framework.app.ethereumNode.EthereumNode.xml
Tool Bnd-3.0.0.201509101326
[IMPEXP]
Import-Package
javax.xml.bind
org.ethereum.facade
org.osgi.service.component {version=[1.2,2)}
org.slf4j {version=[1.7,2)}
Export-Package
org.openmuc.framework.app.ethereumNode {version=0.16.0}
[USES]
org.openmuc.framework.app.ethereumNode java.lang
javax.xml.bind
org.ethereum.facade
org.osgi.service.component
org.slf4j
[USEDBY]
java.lang org.openmuc.framework.app.ethereumNode
javax.xml.bind org.openmuc.framework.app.ethereumNode
org.ethereum.facade org.openmuc.framework.app.ethereumNode
org.osgi.service.component org.openmuc.framework.app.ethereumNode
org.slf4j org.openmuc.framework.app.ethereumNode
[COMPONENTS]
OSGI-INF/org.openmuc.framework.app.ethereumNode.EthereumNode.xml
<?xml version="1.0" encoding="UTF-8"?>
<component name="org.openmuc.framework.app.ethereumNode.EthereumNode">
<implementation class="org.openmuc.framework.app.ethereumNode.EthereumNode"/>
</component>
[LIST]
META-INF
MANIFEST.MF extra='\uFFFD\uFFFD\u0000\u0000'
OSGI-INF
org.openmuc.framework.app.ethereumNode.EthereumNode.xml
lib
aopalliance-1.0.jar
commons-codec-1.10.jar
commons-collections4-4.0.jar
commons-lang3-3.4.jar
commons-logging-1.2.jar
config-1.2.1.jar
core-1.53.0.0.jar
ethereumj-core-1.4.2-RELEASE.jar
guava-16.0.1.jar
jackson-annotations-2.5.0.jar
jackson-core-2.5.1.jar
jackson-core-asl-1.9.13.jar
jackson-databind-2.5.1.jar
jackson-mapper-asl-1.9.13.jar
java-util-1.8.0.jar
javassist-3.15.0-GA.jar
json-io-2.4.1.jar
json-simple-1.1.1.jar
jsr305-3.0.0.jar
leveldb-0.7.jar
leveldb-api-0.7.jar
leveldbjni-all-1.18.3.jar
logback-classic-1.1.7.jar
logback-core-1.1.7.jar
mapdb-2.0-beta12.jar
netty-all-4.0.30.Final.jar
prov-1.53.0.0.jar
slf4j-api-1.7.20.jar
solcJ-all-0.4.8.jar
spring-aop-4.2.0.RELEASE.jar
spring-beans-4.2.0.RELEASE.jar
spring-context-4.2.0.RELEASE.jar
spring-core-4.2.0.RELEASE.jar
spring-expression-4.2.0.RELEASE.jar
spring-jdbc-4.2.0.RELEASE.jar
spring-orm-4.2.0.RELEASE.jar
spring-tx-4.2.0.RELEASE.jar
org
org/openmuc
org/openmuc/framework
org/openmuc/framework/app
org/openmuc/framework/app/ethereumNode
EthereumNode.class
The exception i encounter when the bundle is loaded:
ERROR: Bundle org.openmuc.framework.openmuc-app-ethereumNode [3] Error starting file:/Volumes/UserData/Documents/FH/MasterThesis_MatthiasPosch/java/openmuc/framework/bundle/openmuc-app-ethereumNode-0.16.0.jar (org.osgi.framework.BundleException: Unable to resolve org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0): missing requirement [org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0)] osgi.wiring.package; (osgi.wiring.package=org.ethereum.facade) Unresolved requirements: [[org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0)] osgi.wiring.package; (osgi.wiring.package=org.ethereum.facade)])
org.osgi.framework.BundleException: Unable to resolve org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0): missing requirement [org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0)] osgi.wiring.package; (osgi.wiring.package=org.ethereum.facade) Unresolved requirements: [[org.openmuc.framework.openmuc-app-ethereumNode [3](R 3.0)] osgi.wiring.package; (osgi.wiring.package=org.ethereum.facade)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4112)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:745)
So it seems all libraries are in place in the lib folder, but still the bundle does not work. I tried to play with the code, but any reference to the included libraries (eg. spring) will lead to a similar exception. Why?
My solution was to use the osgi-run plugin for gradle instead of the original osgi plugin. Declaring my dependencies as SystemLibrary systemLib ("org.ethereum:ethereumj-core:1.2.0-RELEASE") resolved the issues and i am able to use the library without exceptions and errors.
In your Manifest you import the package org.ethereum.facade. This can only work if there is also a bundle that exports this package. If the package is purely internal then you should set it as private package and not import it.
If the package might be needed from the outside then make sure you have an import and an export for it in your bundle. If you have not configured the import manually then for some reason the build seems to think you need it and it is not present locally in your bundle.
How do you create the Manifest? Do you use bnd for this? If yes then maybe the manual change in bundle classpath is not recognized by it.

OSGI bundle dependencies

I have created an bundle which relies on SLF4J and as such am using Logback for the OSGI implementation. This all bundles up and installs OK but when I come to start the bundle I get the following exception:
org.osgi.framework.BundleException: Unable to resolve com.felix.test
[20](R 20.0): missing requirement [com.felix.test [20](R 20.0)]
osgi.wiring.package; (osgi.wiring.package=groovy.lang) Unresolved
requirements: [[com.felix.test [20](R 20.0)] osgi.wiring.package;
(osgi.wiring.package=groovy.lang)]
I can see in my manifest file groovy.lang is listed in Import-Package and I'm pretty sure the problem is that Logback is being embedded but none of it's references are.
I'm using to create the bundle, here's the config:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>
*
</Import-Package>
<Embed-Dependency>
*
</Embed-Dependency>
<Embed-Directory>
osgi-inf/libs
</Embed-Directory>
<Embed-Transitive>
true
</Embed-Transitive>
</instructions>
</configuration>
</plugin>
Here's my manifest:
Manifest-Version: 1.0
Bnd-LastModified: 1436982944102
Build-Jdk: 1.8.0_45
Built-By: tim.clifford
Bundle-ClassPath: .,osgi-inf/libs/org.osgi.core-1.0.0.jar,osgi-inf/libs/
servlet-api-2.5.jar,osgi-inf/libs/org.apache.felix.scr.annotations-1.9.
6.jar,osgi-inf/libs/httpclient-osgi-4.5.jar,osgi-inf/libs/httpclient-4.
5.jar,osgi-inf/libs/httpcore-4.4.1.jar,osgi-inf/libs/commons-logging-1.
2.jar,osgi-inf/libs/commons-codec-1.9.jar,osgi-inf/libs/httpmime-4.5.ja
r,osgi-inf/libs/httpclient-cache-4.5.jar,osgi-inf/libs/fluent-hc-4.5.ja
r,osgi-inf/libs/ehcache-2.10.0.jar,osgi-inf/libs/slf4j-api-1.7.7.jar,os
gi-inf/libs/commons-lang3-3.4.jar,osgi-inf/libs/logback-classic-1.1.3.j
ar,osgi-inf/libs/logback-core-1.1.3.jar
Bundle-ManifestVersion: 2
Bundle-Name: com.felix.test
Bundle-SymbolicName: com.felix.test
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: *
Embed-Directory: osgi-inf/libs
Embed-Transitive: true
Embedded-Artifacts: osgi-inf/libs/org.osgi.core-1.0.0.jar;g="org.apache.
felix";a="org.osgi.core";v="1.0.0",osgi-inf/libs/servlet-api-2.5.jar;g=
"javax.servlet";a="servlet-api";v="2.5",osgi-inf/libs/org.apache.felix.
scr.annotations-1.9.6.jar;g="org.apache.felix";a="org.apache.felix.scr.
annotations";v="1.9.6",osgi-inf/libs/httpclient-osgi-4.5.jar;g="org.apa
che.httpcomponents";a="httpclient-osgi";v="4.5",osgi-inf/libs/httpclien
t-4.5.jar;g="org.apache.httpcomponents";a="httpclient";v="4.5",osgi-inf
/libs/httpcore-4.4.1.jar;g="org.apache.httpcomponents";a="httpcore";v="
4.4.1",osgi-inf/libs/commons-logging-1.2.jar;g="commons-logging";a="com
mons-logging";v="1.2",osgi-inf/libs/commons-codec-1.9.jar;g="commons-co
dec";a="commons-codec";v="1.9",osgi-inf/libs/httpmime-4.5.jar;g="org.ap
ache.httpcomponents";a="httpmime";v="4.5",osgi-inf/libs/httpclient-cach
e-4.5.jar;g="org.apache.httpcomponents";a="httpclient-cache";v="4.5",os
gi-inf/libs/fluent-hc-4.5.jar;g="org.apache.httpcomponents";a="fluent-h
c";v="4.5",osgi-inf/libs/ehcache-2.10.0.jar;g="net.sf.ehcache";a="ehcac
he";v="2.10.0",osgi-inf/libs/slf4j-api-1.7.7.jar;g="org.slf4j";a="slf4j
-api";v="1.7.7",osgi-inf/libs/commons-lang3-3.4.jar;g="org.apache.commo
ns";a="commons-lang3";v="3.4",osgi-inf/libs/logback-classic-1.1.3.jar;g
="ch.qos.logback";a="logback-classic";v="1.1.3",osgi-inf/libs/logback-c
ore-1.1.3.jar;g="ch.qos.logback";a="logback-core";v="1.1.3"
Export-Package: com.felix.test;version="1.0.0"
Import-Package: groovy.lang,javax.crypto,javax.crypto.spec,javax.jms,jav
ax.mail,javax.mail.internet,javax.management,javax.management.openmbean
,javax.naming,javax.naming.directory,javax.naming.ldap,javax.net,javax.
net.ssl,javax.security.auth.x500,javax.sql,javax.swing.event,javax.tran
saction,javax.transaction.xa,javax.xml.datatype,javax.xml.namespace,jav
ax.xml.parsers,javax.xml.stream,javax.xml.stream.events,net.spy.memcach
ed,org.apache.avalon.framework.logger,org.apache.felix.scrplugin,org.ap
ache.felix.scrplugin.annotations,org.apache.felix.scrplugin.description
,org.apache.log,org.apache.log4j,org.codehaus.commons.compiler,org.code
haus.groovy.control,org.codehaus.groovy.control.customizers,org.codehau
s.groovy.reflection,org.codehaus.groovy.runtime,org.codehaus.groovy.run
time.callsite,org.codehaus.groovy.runtime.typehandling,org.codehaus.gro
ovy.runtime.wrappers,org.codehaus.groovy.transform,org.codehaus.janino,
org.hibernate,org.hibernate.cache,org.hibernate.cache.access,org.hibern
ate.cfg,org.hibernate.impl,org.hibernate.stat,org.hibernate.transaction
,org.ietf.jgss,org.osgi.service.cm,org.quartz,org.quartz.impl,org.quart
z.impl.jdbcjobstore,org.quartz.impl.matchers,org.quartz.simpl,org.terra
cotta.quartz,org.terracotta.toolkit,org.terracotta.toolkit.atomic,org.t
erracotta.toolkit.builder,org.terracotta.toolkit.cache,org.terracotta.t
oolkit.cluster,org.terracotta.toolkit.collections,org.terracotta.toolki
t.concurrent.locks,org.terracotta.toolkit.config,org.terracotta.toolkit
.events,org.terracotta.toolkit.feature,org.terracotta.toolkit.internal,
org.terracotta.toolkit.internal.cache,org.terracotta.toolkit.internal.c
luster,org.terracotta.toolkit.internal.collections,org.terracotta.toolk
it.internal.concurrent.locks,org.terracotta.toolkit.internal.feature,or
g.terracotta.toolkit.monitoring,org.terracotta.toolkit.nonstop,org.terr
acotta.toolkit.rejoin,org.terracotta.toolkit.search,org.terracotta.tool
kit.search.attribute,org.terracotta.toolkit.store,org.xml.sax,org.xml.s
ax.helpers,sun.misc,sun.reflect
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
Tool: Bnd-2.4.1.201501161923
Am I going about it the right way or is there a better method?
Thank you!
To your question "am I going about is the right way", the answer is "definitely not"!
Please, please don't use Embed-Dependency. This simply takes all of the transitive dependency graph (which in your case includes the Groovy language runtime, somehow) and sticks it inside your bundle.
This misses the point of OSGi entirely. Worse, when you develop your next bundle you will have to go through all this again! Eventually you will have tens of bundles, each carrying around a massive, dead weight of embedded dependencies.
As Christian said, stick to the defaults provided by the maven-bundle-plugin. You don't even need to specify <Import-Package>*</Import-Package> since this is already the default. As a result you will get a bundle that has package imports, which is a good thing! But you need to install bundles that provide exports that will match your imports.
You should not embed all dependencies into your bundle. Instead just run with maven bundle plugin defaults. It should create a bundle that you can then deploy into an OSGi container.
I am most experienced with Apache Karaf. There you can just install the bundle using:
install -s mvn:groupId/artifactId/version
In your case this might already work as Apache Karaf comes with pax-logging pre installed.
If you want to use plain felix it is a little more complicated as you will have to gather all dependencies and create a suitable start configuration. In that case bndtools might help.
From the exception you reported in your question I would say none of the bundles in your osgi environment is currently exporting the groovy.lang package.
I would suggest to install the felix gogo shell in your runtime and to issue the following command in the osgi console:
g! inspect cap osgi.wiring.package
This will give you the list of all exported packages in your osgi instance: in this way you can verify whether or not the groovy.lang package is indeed missing.
If this is the case, then you should wrap the groovy-all jar in a bundle as explained here and include it in your running osgi bundles. If you want, you can search a ready-to-use osgi bundle for groovy-all in jpm4j website.

Osgi java.lang.NoClassDefFoundError when trying to retrieve a service from another bundle

So, let's see, I have three bundles: Provider interface, Provider implementation and Client.
Everything is running smoothly on Eclipse, but when I export the bundles and run em, the following error appears when I try to retrieve the Provider Service:
java.lang.NoClassDefFoundError: provider/providerinterface/ProviderService
The interface is exporting his package, so there should be no errors with that. Alongside, Client is also importing the providerInterface package in its manifest.
The .jar of the Provider interface bundle does have the ProviderService class inside, so there are no error exporting either.
Provider Interface's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: IMA_Provider
Bundle-SymbolicName: IMA_Provider
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: provider.providerinterface
Client's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MAClient
Bundle-SymbolicName: MA_Client
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: provider.providerinterface,
org.osgi.framework;version="1.3.0",
org.osgi.util.tracker;version="1.4.2"
Provider and Client are just symbolic names, the "Client" bundle imports and uses a lot of other classes from many other bundles with no errors whatsoever. Anyway, I'm getting stuck with this one, and I can't find any reason.
Any help?
Usually there is something wrong with the build.properties file, causing the bundles to miss the actual class files. This does not matter when running directly from Eclipse, but it does matter when you export the bundles using PDE.
Things to check:
Are the classfiles really in the bundles? When checking the bundle, you should have at least at toplevel a provider/ folder and a META-INF/ folder
the build.properties file should look something like:
output.. = bin/
source.. = src/
bin.includes = META-INF/,.
Good luck, Frank
I was finally able to solve this.
There were no issues with the Manifest files or the build.properties, this was a constructor problem.
The MA_Provider implementation was lacking a void constructor; Once I added this
public ProviderImpl(){}
on the implementation class of the ProviderInterface, the OSGi bundles were able to retrieve the service.

The bundle XYZ could not resolved. Reason: Missing Constraint: Import-Package: ABC; version="1.0.0" error in headless RCP standalone

I'm working on standalone headless RCP. It works without problem when I execute the application and product in eclipse IDE, but when I export and execute it, I got this error in the log file.
!ENTRY org.eclipse.equinox.ds 4 0 2013-01-16 13:27:59.132
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.ds_1.4.0.v20120522-1841 [3]" could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.equinox.internal.util.event; version="1.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
...
!ENTRY org.eclipse.equinox.ds 4 0 2013-01-16 13:28:00.901
!MESSAGE [SCR] Exception while activating instance org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager#6b8d6157 of component org.eclipse.e4.ui.css.swt.theme
!STACK 0
java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
Referring from this post, I understand that I've got a newer version of a plug-in without its dependencies, and there is something wrong in the runtime path. However, I'm not sure exactly what might cause this error.
What might be wrong? Why I have this error only when I execute it as standalone?
ADDED
I have build.properties file
output.. = bin/
bin.includes = META-INF/,\
plugin.xml,\
.
source.. = src/
This is MANIFEST.MF file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Refactorer
Bundle-SymbolicName: edu.utexas.seal.refactorer;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: edu.utexas.seal.refactorer.Activator
Bundle-Vendor: PROSSEEK
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.jdt;bundle-version="3.8.0",
org.eclipse.jdt.core;bundle-version="3.8.2",
org.eclipse.core.resources;bundle-version="3.8.1",
org.eclipse.text;bundle-version="3.5.200",
org.eclipse.jdt.ui;bundle-version="3.8.1",
org.eclipse.jdt.core.manipulation;bundle-version="1.5.0",
org.eclipse.ltk.ui.refactoring;bundle-version="3.7.0",
org.eclipse.jdt.core.manipulation;bundle-version="1.5.0",
org.eclipse.ltk.core.refactoring;bundle-version="3.6.0",
org.eclipse.jface.text;bundle-version="3.8.1",
org.eclipse.core.expressions;bundle-version="3.4.401",
org.eclipse.core.externaltools;bundle-version="1.0.100",
org.eclipse.jface;bundle-version="3.8.101",
edu.utexas.seal.utilities;bundle-version="1.0.0",
org.eclipse.core.filebuffers;bundle-version="3.5.200"
Bundle-ClassPath: .
Export-Package: edu.utexas.seal.refactorer
I have only one item: "." in Bundle-ClassPath.
Missing org.eclipse.equinox.util
I recompiled the project first, and then checked I have all the required plugins from the complaints in the log file, and then I found that I was missing the org.eclipse.equinox.util, I guess it should have been included automatically. After the including, some of the errors are just gone and I found that I have two more errors.
The execution environment issue
I setup the "Execution Environment" as JavaSE-1.5, and this was an issue as the Java couldn't recognize #Override to cause the 'Must Override a Superclass Method' errors.
I got a hint from this site.
'Must Override a Superclass Method' Errors after importing a project into Eclipse
Runtime level
I also had to change the /ECLIPSE/configuration/config.ini file.
osgi.bundles=org.eclipse.equinox.common#2:start,org.eclipse.update.configurator#3:
start,org.eclipse.equinox.ds#3 <-- (From 2 to 3)
:start,org.eclipse.core.runtime#start
I don't know whether it's eclipse bug or not, I got a hint from this site.
Some tips that I found useful
-consoleLog was really useful, as I didn't have to open the log file all the time.
This article gave me some direction how to solve the issue.
I guess once the eclipse RCP is working on eclipse IDE as a product, we should get working standalone RCP. If not, the issues should be configuration issues that make difference between IDE and standalone.
You need to add the same to your feature.xml file.
Once you have added the same, clean the project and try re-build.
I am sure that this will resolve this issue.

Categories