Virgo server plugin resolver conflict - osgi

I have two bundles, A export two packages, and then B use these two packages(org.dom4j , org.dom4j.io) , and B still uses spring packages exported by other bundles. If I load bundle A then load bundle B in the osgi console, there is no resolver issue.
But, if I put these two packages into a par, if would fail in the synthetic.context bundle, saying "Uses violation:
A's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: device-openapi
Bundle-SymbolicName: device-openapi
Bundle-Version: 1.0.0
Export-Package: com.google.gson,
com.google.gson.annotations,
com.google.gson.internal,
com.google.gson.internal.bind,
com.google.gson.reflect,
com.google.gson.stream,
org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
org.apache.commons.codec.language,
org.apache.commons.codec.language.bm,
org.apache.commons.codec.net,
org.apache.commons.io,
org.apache.commons.io.comparator,
org.apache.commons.io.filefilter,
org.apache.commons.io.input,
org.apache.commons.io.monitor,
org.apache.commons.io.output,
org.apache.commons.lang3,
org.apache.commons.lang3.builder,
org.apache.commons.lang3.concurrent,
org.apache.commons.lang3.event,
org.apache.commons.lang3.exception,
org.apache.commons.lang3.math,
org.apache.commons.lang3.mutable,
org.apache.commons.lang3.reflect,
org.apache.commons.lang3.text,
org.apache.commons.lang3.text.translate,
org.apache.commons.lang3.time,
org.apache.commons.lang3.tuple,
org.apache.commons.logging,
org.apache.commons.logging.impl,
org.apache.http,
org.apache.http.annotation,
org.apache.http.auth,
org.apache.http.auth.params,
org.apache.http.client,
org.apache.http.client.config,
org.apache.http.client.entity,
org.apache.http.client.methods,
org.apache.http.client.params,
org.apache.http.client.protocol,
org.apache.http.client.utils,
org.apache.http.concurrent,
org.apache.http.config,
org.apache.http.conn,
org.apache.http.conn.params,
org.apache.http.conn.routing,
org.apache.http.conn.scheme,
org.apache.http.conn.socket,
org.apache.http.conn.ssl,
org.apache.http.conn.util,
org.apache.http.cookie,
org.apache.http.cookie.params,
org.apache.http.entity,
org.apache.http.entity.mime,
org.apache.http.entity.mime.content,
org.apache.http.impl,
org.apache.http.impl.auth,
org.apache.http.impl.client,
org.apache.http.impl.conn,
org.apache.http.impl.conn.tsccm,
org.apache.http.impl.cookie,
org.apache.http.impl.entity,
org.apache.http.impl.execchain,
org.apache.http.impl.io,
org.apache.http.impl.pool,
org.apache.http.io,
org.apache.http.message,
org.apache.http.params,
org.apache.http.pool,
org.apache.http.protocol,
org.apache.http.util,
org.apache.log4j,
org.apache.log4j.chainsaw,
org.apache.log4j.config,
org.apache.log4j.helpers,
org.apache.log4j.jdbc,
org.apache.log4j.jmx,
org.apache.log4j.lf5,
org.apache.log4j.lf5.util,
org.apache.log4j.lf5.viewer,
org.apache.log4j.lf5.viewer.categoryexplorer,
org.apache.log4j.lf5.viewer.configure,
org.apache.log4j.net,
org.apache.log4j.nt,
org.apache.log4j.or,
org.apache.log4j.or.jms,
org.apache.log4j.or.sax,
org.apache.log4j.pattern,
org.apache.log4j.rewrite,
org.apache.log4j.spi,
org.apache.log4j.varia,
org.apache.log4j.xml,
org.dom4j,
org.dom4j.bean,
org.dom4j.datatype,
org.dom4j.dom,
org.dom4j.dtd,
org.dom4j.io,
org.dom4j.jaxb,
org.dom4j.rule,
org.dom4j.rule.pattern,
org.dom4j.swing,
org.dom4j.tree,
org.dom4j.util,
org.dom4j.xpath,
org.dom4j.xpp,
org.json,
org.wcc.crypt,
org.wcc.framework
Import-Package: javax.crypto,javax.crypto.spec,javax.naming,javax.nami
ng.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,ja
vax.net,javax.net.ssl,javax.security.auth.x500
B's manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NGCPlugin-service
Bundle-SymbolicName: com.myplugin.esdk.storage.service
Bundle-Version: 1.5.50
Bundle-Vendor: myplugin
Bundle-ClassPath: .
Tool: Bundlor 1.1.0.RELEASE
Export-Package: com.myplugin.esdk.storage.mvc,
com.myplugin.esdk.storage.service.datastore,
com.myplugin.esdk.storage.service.device,
com.myplugin.esdk.storage.service.host,
com.myplugin.esdk.storage.service.mount,
com.myplugin.esdk.storage.service.resource,
com.myplugin.esdk.storage.service.snapshot,
com.myplugin.esdk.storage.service.vm
Import-Package: org.apache.commons.logging,
org.dom4j,
org.dom4j.io,
org.json,org.w3c.dom,
org.xml.sax,
org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
org.apache.commons.codec.language,
org.apache.commons.codec.language.bm,
org.apache.commons.codec.net,
org.apache.commons.io,
org.slf4j,
org.springframework.beans.factory.annotation
Error log:
Resolver report:
Uses violation: <Import-Package: org.springframework.beans.factory.annotation; version="0.0.0"> in bundle <com.myplugin.esdk.storage.ngc-2.1.7-com.myplugin.esdk.storage.service_1.5.50[1520387337960]>
Resolver reported uses conflict for import
An Import-Package could not be resolved. Resolver error data <Import-Package: com.myplugin.esdk.storage.service.snapshot; version="0.0.0">. Caused by missing constraint in bundle <com.myplugin.esdk.storage.ngc-2.1.7-synthetic.context_2.1.7>
constraint: <Import-Package: com.myplugin.esdk.storage.service.snapshot; version="0.0.0"> constrained to bundle <com.myplugin.esdk.storage.ngc-2.1.7-com.myplugin.esdk.storage.service> constrained bundle version range "[1.5.50,1.5.50]"
with attributes {module_scope=com.myplugin.esdk.storage.ngc-2.1.7}
Anyone knows how to fix this? I tried to make a dummy bundle which uses Import-Bundle to import the two bundle's all exported packages, after I manually loaed the A and B bundle, these is no resolver error......

I am not familiar with deployment of PAR files, when using Virgo I normally deploy PLAN files. This said, I suspect that the problem may be due to the fact that A exports a number of packages org.apache* which are probably already exported by other bundles included in Virgo and which are dependencies of Spring. So when your PAR is resolved, plan B finds itself in the situation in which the same package is being inherited from A and also from Spring via transitive dependencies.
I would try to remove from A manifest the export of all the packages that are already provided by Virgo.

Related

BitBucket Server Maven error: The default package '.' is not permitted by the Import-Package syntax

I am developing a plugin for BitBucket Server. Today, the Maven instance started throwing the following error after I changed the scope of one dependency:
[ERROR] Manifest com.my-plugin:integrationPlugin:atlassian-plugin:0.1-DEV : The default package '.' is not permitted by the Import-Package syntax.
This can be caused by compile errors in Eclipse because Eclipse creates
valid class files regardless of compile errors.
The following package(s) import from the default package null
[ERROR] Error(s) found in manifest configuration
After I reverted the change, the error did not go away.
I have tried solutions described in other StackOverflow posts, but they did not help me, since:
I am not using Eclipse
I have all packages declared in all my class files
The Bundle tool has this error fixed already
The manifest I got from the Maven debugging output is:
[DEBUG] Final Manifest:
#-----------------------------------------------------------------------
Manifest-Version: 1.0
Atlassian-Build-Date: 2019-04-04T11:44:27+0000
Atlassian-Plugin-Key: com.my-plugin.integrationPlugin
Bnd-LastModified: 1554378274635
Build-Jdk: 1.8.0_191
Built-By: egta136
Bundle-ClassPath: .,META-INF/lib/commons-logging-1.2.jar,META-INF/lib/pd
fbox-2.0.14.jar,META-INF/lib/fontbox-2.0.14.jar,META-INF/lib/ij-1.52n.j
ar
Bundle-Description: This is the com.my-plugin:integrationPlugin plu
gin for Atlassian Bitbucket Server.
Bundle-DocURL: https://example.com
Bundle-ManifestVersion: 2
Bundle-Name: integrationPlugin
Bundle-SymbolicName: com.my-plugin.integrationPlugin
Bundle-Vendor: Example
Bundle-Version: 0.1.0.DEV
Created-By: Apache Maven Bundle Plugin
Export-Package: com.my-plugin.integrationPlugin.api;version="0.1.0"
Import-Package:
com.apple.eawt;version=0;resolution:=optional,
com.atlassian.bitbucket.auth;version=0;resolution:=optional,
com.atlassian.bitbucket.commit;version=0;resolution:=optional,
com.atlassian.bitbucket.project;version=0;resolution:=optional,
com.atlassian.bitbucket.user;version=0;resolution:=optional,
com.atlassian.plugin.spring.scanner.annotation.export;version=0;resolut
ion:=optional,
com.atlassian.plugin.spring.scanner.annotation.imports;version=0;resolu
tion:=optional,
com.atlassian.sal.api;version=0;resolution:=optional,
com.atlassian.sal.api.pluginsettings;version=0;resolution:=optional,
com.atlassian.soy.renderer;version=0;resolution:=optional,
com.dizainsync.ddm.integrationPlugin.api;version=0;resolution:=optional
,
com.fasterxml.jackson.databind;version=0;resolution:=optional,
com.google.common.collect;version=0;resolution:=optional,
javax.crypto;version=0;resolution:=optional,
javax.crypto.spec;version=0;resolution:=optional,
javax.imageio;version=0;resolution:=optional,
javax.imageio.metadata;version=0;resolution:=optional,
javax.imageio.plugins.jpeg;version=0;resolution:=optional,
javax.imageio.stream;version=0;resolution:=optional,
javax.inject;version=0;resolution:=optional,
javax.script;version=0;resolution:=optional,
javax.servlet;version=0;resolution:=optional,
javax.servlet.http;version=0;resolution:=optional,
javax.swing;version=0;resolution:=optional,
javax.swing.event;version=0;resolution:=optional,
javax.swing.table;version=0;resolution:=optional,
javax.swing.text;version=0;resolution:=optional,
javax.swing.text.html;version=0;resolution:=optional,
javax.swing.tree;version=0;resolution:=optional,
javax.tools;version=0;resolution:=optional,
javax.xml.namespace;version=0;resolution:=optional,
javax.xml.parsers;version=0;resolution:=optional,
javax.xml.xpath;version=0;resolution:=optional,
org.apache.avalon.framework.logger;version=0;resolution:=optional,
org.apache.commons.fileupload;version=0;resolution:=optional,
org.apache.commons.fileupload.disk;version=0;resolution:=optional,
org.apache.commons.fileupload.servlet;version=0;resolution:=optional,
org.apache.commons.io;version=0;resolution:=optional,
org.apache.commons.lang3;version=0;resolution:=optional,
org.apache.log;version=0;resolution:=optional,
org.apache.log4j;version=0;resolution:=optional,
org.bouncycastle.asn1;version=0;resolution:=optional,
org.bouncycastle.asn1.cms;version=0;resolution:=optional,
org.bouncycastle.asn1.pkcs;version=0;resolution:=optional,
org.bouncycastle.asn1.x500;version=0;resolution:=optional,
org.bouncycastle.asn1.x509;version=0;resolution:=optional,
org.bouncycastle.cert;version=0;resolution:=optional,
org.bouncycastle.cms;version=0;resolution:=optional,
org.bouncycastle.cms.jcajce;version=0;resolution:=optional,
org.slf4j;version=0;resolution:=optional,
org.w3c.dom;version=0;resolution:=optional,
org.xml.sax;version=0;resolution:=optional,
com.atlassian.plugin.osgi.bridge.external
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Spring-Context: *
Tool: Bnd-3.5.0.201709291849
#-----------------------------------------------------------------------
What could be causing this? It is especially weird since reverting the changes to pom.xml did not get rid of the error.
The error was caused by the ImageJ dependency that I had. Apparently some of their classes use the default package which does not play well with maven. Removing the dependency fixes the issue.
I had a similar issue. To find out which dependency may prevent OSGi packaging to work, review error message like Classes found in the wrong directory: {META-INF/versions/9/module-info.class=module-info}
Using jcfind to identify its origin, as an example:
./target/classes/META-INF/lib/classgraph-4.8.43.jar META-INF/versions/9/module-info.class
I am contacting parent POM provider to get this fixed.

OSGI : maven wrapped bundle throws java.lang.ClassNotFoundException if it tries to access another wrapped bundle

As below dependencies are not OSGI-ready I wrapped them as follows :
<bundle>wrap:mvn:com.google.maps/google-maps-services/0.9.2</bundle>
<bundle>wrap:mvn:com.squareup.okhttp3/okhttp/3.13.1</bundle>
Seems like my first bundle can't access second bundle, although I included it in my imports as follows:
<Import-Package>okhttp3,*</import-Package>
I am getting :
Caused by: java.lang.NoClassDefFoundError: okhttp3/Authenticator
at com.google.maps.GeoApiContext$Builder.<init>(GeoApiContext.java:318)
at com.elavon.nabsd.creditsafe.beans.GooglePlacesAPIContext.<clinit>(GooglePlacesAPIContext.java:11)
at com.elavon.nabsd.creditsafe.beans.AddressParser.getAddress(AddressParser.java:35)
at com.elavon.nabsd.creditsafe.beans.AddressParser.dummyResponse(AddressParser.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
... 13 more
Caused by: java.lang.ClassNotFoundException: okhttp3.Authenticator not found by wrap_mvn_com.google.maps_google-maps-services_0.9.2 [1180]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more
Manifest
Manifest-Version: 1.0
Bnd-LastModified: 1552097042208
Build-Jdk: 1.8.0_181
Built-By: c041356
Bundle-Blueprint: OSGI-INF/blueprint/address-parser-blueprint.xml
Bundle-Description: XXX
Bundle-DocURL: XXX
Bundle-ManifestVersion: 2
Bundle-Name: XXX
Bundle-SymbolicName: address-parser
Bundle-Vendor: XXX
Bundle-Version: 1.0.24
Created-By: Apache Maven Bundle Plugin
DynamicImport-Package: *
Export-package: com.squareup.okhttp3,okhttp3
Import-Package: okhttp3,com.fasterxml.jackson.annotation,com.google.maps
,com.google.maps.errors,com.google.maps.model,org.apache.camel.componen
t.jasypt,org.jasypt.encryption.pbe.config,org.osgi.service.blueprint;ve
rsion="[1.0.0,2.0.0)",org.slf4j,org.apache.camel.component.http4,org.ap
ache.camel.component.jackson,com.squareup.okhttp3
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.0.0.201509101326
wrap_mvn_com.squareup.okhttp3_okhttp_3.13.1 (1202)
--------------------------------------------------
Originally-Created-By = Apache Maven 3.6.0
Created-By = 1.8.0_181 (Oracle Corporation)
Manifest-Version = 1.0
Bnd-LastModified = 1552095323499
Generated-By-Ops4j-Pax-From = wrap:mvn:com.squareup.okhttp3/okhttp/3.13.1
Build-Jdk = 1.8.0_162
Built-By = jwilson
Automatic-Module-Name = okhttp3
Tool = Bnd-2.3.0.201405100607
Bundle-ManifestVersion = 2
Bundle-SymbolicName = wrap_mvn_com.squareup.okhttp3_okhttp_3.13.1
Bundle-Version = 0
Bundle-Name = wrap_mvn_com.squareup.okhttp3_okhttp_3.13.1
Require-Capability =
osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.8))
Export-Package =
okhttp3;uses:="javax.annotation,javax.net,javax.net.ssl,okio",
okhttp3.internal;uses:="javax.annotation,javax.net.ssl,okhttp3,okhttp3.internal.cache,okhttp3.internal.connection,okhttp3.internal.http,okhttp3.internal.http2,okio",
okhttp3.internal.annotations;uses:="javax.annotation,javax.annotation.meta",
okhttp3.internal.cache;uses:="javax.annotation,okhttp3,okhttp3.internal.io,okio",
okhttp3.internal.cache2,
okhttp3.internal.connection;uses:="javax.annotation,javax.net.ssl,okhttp3,okhttp3.internal.http,okhttp3.internal.http2,okhttp3.internal.ws",
okhttp3.internal.duplex,
okhttp3.internal.http;uses:="javax.annotation,okhttp3,okhttp3.internal.connection,okio",
okhttp3.internal.http1;uses:="okhttp3,okhttp3.internal.connection,okhttp3.internal.http,okio",
okhttp3.internal.http2;uses:="okhttp3,okhttp3.internal.connection,okhttp3.internal.http,okio",
okhttp3.internal.io;uses:=okio,
okhttp3.internal.platform;uses:="javax.annotation,javax.net.ssl,okhttp3,okhttp3.internal.tls",
okhttp3.internal.proxy,
okhttp3.internal.publicsuffix,
okhttp3.internal.tls;uses:=javax.net.ssl,
okhttp3.internal.ws;uses:="javax.annotation,okhttp3,okio"
Import-Package =
android.os;resolution:=optional,
android.util;resolution:=optional,
javax.annotation;resolution:=optional,
javax.annotation.meta;resolution:=optional,
javax.net;resolution:=optional,
javax.net.ssl;resolution:=optional,
javax.security.auth.x500;resolution:=optional,
okio;resolution:=optional,
wrap_mvn_com.google.maps_google-maps-services_0.9.2 (1180)
----------------------------------------------------------
Created-By = 1.8.0_181 (Oracle Corporation)
Manifest-Version = 1.0
Bnd-LastModified = 1552091296783
Generated-By-Ops4j-Pax-From = wrap:mvn:com.google.maps/google-maps-services/0.9.2
Tool = Bnd-2.3.0.201405100607
Bundle-ManifestVersion = 2
Bundle-SymbolicName = wrap_mvn_com.google.maps_google-maps-services_0.9.2
Bundle-Version = 0
Bundle-Name = wrap_mvn_com.google.maps_google-maps-services_0.9.2
Require-Capability =
osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.8))
Export-Package =
com.google.maps;uses:="com.google.gson,com.google.maps.errors,com.google.maps.internal,com.google.maps.model,okhttp3",
com.google.maps.errors,
com.google.maps.internal;uses:="com.google.appengine.api.urlfetch,com.google.gson,com.google.gson.stream,com.google.maps,com.google.maps.errors,com.google.maps.model,okhttp3",
com.google.maps.internal.ratelimiter,
com.google.maps.model;uses:=com.google.maps.internal
Import-Package =
com.google.appengine.api.urlfetch;resolution:=optional,
com.google.gson;resolution:=optional,
com.google.gson.stream;resolution:=optional,
javax.crypto;resolution:=optional,
javax.crypto.spec;resolution:=optional,
okhttp3;resolution:=optional,
okio;resolution:=optional,
org.slf4j;resolution:=optional
Wrapped bundles get the automatically discovered package dependencies as "optional", because there is no way to tell reliably whether some specific package will actually be required or not when using specific functionality provided by the bundle.
Hence, the existence of other bundles and their exported packages at the bundle resolving time determine, which packages are actually visible to the created class-loader of the resolved wrapped bundle.
In your case, the packages exported by bundle "okhttp3" where not available at the time the resolver searched for available package to import when resolving bundle "google-maps".
This in turn means that you need to make sure that either:
the bundle "okhttp3" is visible to the resolver at the time of resolving bundle "google-maps"
make sure that the required package imports are not "optional"
While the first option may seem easier, the second one is more reliable and flexible.
The wrap: protocol supports overwriting generated OSGi headers so that you can specify details to your needs. In our case, it would be:
<bundle>wrap:mvn:com.google.maps/google-maps-services/0.9.2$overwrite=merge&Import-Package=okhttp3,okio,*;resolution:=optional</bundle>
(untested and only based on docs, though)
Notice
Before using the wrap protocol, please have a look whether the desired library has already been OSGi-fied by some other project. One very good start is to have a look at the Bundles made available by the Apache ServiceMix project (which provides a okhttp3 Bundle):
https://repo1.maven.org/maven2/org/apache/servicemix/bundles/

In bndtools, what causes a Require-Capability header for execution environment to be generated?

I have the following bnd file:
Bundle-Version: 1.0.12
Bundle-Activator: a.b.Activator
Private-Package: a.b
-buildpath: osgi.core;version=4.3.0,\
org.apache.felix.bundlerepository;version=1.6.6,\
osgi.cmpn;version=4.3.0.201111022214
-sources: false
In the generated MANIFEST.MF:
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
I don't want this there... there's no reason I can see that it should be. So how do I avoid it?
bnd 2.3 automatically adds this. You can disable with -noee=true in your bnd file.
Generally this is a good requirement to have since it expresses the base JRE requirement of your bundle. bnd determines the version based upon the class file versions in the bundle.

Why are uses constraints violated when both chains end in the same bundle?

I have four bundles, each containing only a manifest. The bundles are
app which imports com.example.foo.fragment and com.example.bar
foo which exports com.example.foo;uses:=com.example.foo.cfg
foo.fragment which is a fragment attached to foo that exports com.example.foo.fragment and com.example.foo.fragment.cfg;uses:=com.example.foo.fragment
bar which exports com.example.bar and imports com.example.foo
Bundle-level dependency graph:
app -> bar
| |
| v
| foo
| |
v v
foo.fragment
When I install these bundles all at once in JBoss AS 7.2, they work just fine. But if I install the app bundle after the others, either for the first time or after successfully starting and then uninstalling it, the following uses constraint violation occurs:
Caused by: org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.example.app [HostBundleRevision[com.example.app:0.0.
0]] because it is exposed to package 'com.example.foo.fragment' from resources com.example.foo [HostBundleRevision[com.example.foo:0.0.0]] and com.example.foo [HostBund
leRevision[com.example.foo:0.0.0]] via two dependency chains.
Chain 1:
com.example.app [HostBundleRevision[com.example.app:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.foo.fragment
com.example.foo [HostBundleRevision[com.example.foo:0.0.0]]
Chain 2:
com.example.app [HostBundleRevision[com.example.app:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.bar; uses:=com.example.foo
com.example.bar [HostBundleRevision[com.example.bar:0.0.0]]
import: null
|
export: osgi.wiring.package=com.example.foo; uses:=com.example.foo.fragment
export: osgi.wiring.package=com.example.foo.fragment
com.example.foo [HostBundleRevision[com.example.foo:0.0.0]]
at org.apache.felix.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1142)
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:197)
at org.jboss.osgi.resolver.felix.StatelessResolver.resolve(StatelessResolver.java:56)
at org.jboss.osgi.framework.internal.ResolverImpl.resolveAndApply(ResolverImpl.java:137)
at org.jboss.as.osgi.service.BundleLifecycleIntegration$BundleLifecycleImpl.activateDeferredPhase(BundleLifecycleIntegration.java:296)
... 31 more
The full manifests are:
app.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.app
Import-Package: com.example.foo.fragment,com.example.bar
----------------------------
foo.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.foo
Export-Package: com.example.foo;uses:="com.example.foo.cfg"
-------------------------------------
foo.fragment.jar/META-INF/MANIFEST.MF
-------------------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.foo.fragment
Fragment-Host: com.example.foo
Export-Package: com.example.foo.fragment,com.example.foo.cfg;uses:="co
m.example.foo.fragment"
----------------------------
bar.jar/META-INF/MANIFEST.MF
----------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.bar
Export-Package: com.example.bar;uses:="com.example.foo"
Import-Package: com.example.foo
I have not been able to reproduce the above error in standalone Apache Felix 4.2.1.
What is the cause of this behaviour? If I delete the Fragment-Host: com.example.foo row from the foo.fragment manifest, I can reinstall app just fine without errors. Is this a bug in JBoss AS 7.2?
You don't have to import foo.fragment in app your dependency will resolve from foo. so just remove that dependency and re-deploy that. This issue is because of cyclic dependency.

jar bundle and its classpath in ServiceMix-karaf

I am developing 2 jar files (jar1 and jar2 - the packaging type in pom.xml of 2 jars is jar) and installed them into serviceMix. Jar1 will use some packakes from jar2.
In the manifest.mf files, i used import and export for jar1 and jar2. After installing into serviceMix 4.3.0. Everything going almost fine. From jar 1, i can use packages in jar2 (i know that by debugging the code). But the problem is here:
The structure of Jar2:
jar2:/
.
com
abc
.......(classes)
META-INF
MANIFEST.MF
FactoryContext.xml
The short version of jar2's MANIFEST.MF is
Bundle-ClassPath: .
Bundle-Name: jar2
Bundle-SymbolicName: jar2
Bundle-Version: 1.0.0
Export-Package: com.abc
Import-Package: xyz
Tool: Bnd-1.50.0
Jar1 call a method of Jar2, that method is using bellow statement
context = new ClassPathXmlApplicationContext("FactoryContext.xml");
whenever it goes to this statement, it always throws exception say that FactoryContext.xml doesn not exist. (i guest this file is not in classpath)
Do you know how to make it work?
i also posted my question on ServiceMix forum and i have got the answer from Freeman-2.
Here is the answer
You can try to put FactoryContext.xml in a unique folder like META-
INF/MyFactoryContext/FactoryContext.xml, then jar2 also export package
META-INF.MyFactoryContext, and jar1 import package META-
INF.MyFactoryContext, and then should be able to use code like
context = new ClassPathXmlApplicationContext("META-INF/
MyFactoryContext/FactoryContext.xml");
in jar1.
Here is the link
http://servicemix.396122.n5.nabble.com/question-about-jar-bundle-and-classpath-td5602052.html

Resources