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.
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.
I am trying to run a cxf bundle in karaf. It says that the package org.apache.ws.commons.schema is missing but the appropiate bundle is already installed (servicemix bundle)
I dont know why the dependency is not solved if the bundle 785 (xmlschema) is activated. Do I need to include something else or do I have some sort of configuration problem?
OSGi>features:install idb
Refreshing bundles org.springframework.jms (104)
Error executing command: Could not start bundle
mvn:org.apache.cxf/cxf-bundle-minimal/2.2.9 in feature(s)
cxf-bundle-minimal-2.6.0: Unresolved constraint in bundle
org.apache.cxf.bundle-minimal [832]: Unable to resolve 832.0:
missing requirement [832.0] package;
(&(package=org.apache.ws.commons.schema)(version>=1.4.0)(!(version>=2.0.0)))
OSGi>osgi:info 785
Apache ServiceMix Bundles: xmlschema-1.4.3 (785)
------------------------------------------------
OSGi>osgi:headers 785
Apache ServiceMix Bundles: xmlschema-1.4.3 (785)
------------------------------------------------
Manifest-Version = 1.0
Bnd-LastModified = 1237594240914
Tool = Bnd-0.0.255
Built-By = gnodet
Build-Jdk = 1.5.0_16
Created-By = Apache Maven Bundle Plugin
Bundle-Vendor = The Apache Software Foundation
Bundle-Name = Apache ServiceMix Bundles: xmlschema-1.4.3
Bundle-DocURL = http://www.apache.org/
Bundle-Description = This bundle simply wraps xmlschema-1.4.3.jar.
Bundle-SymbolicName = org.apache.servicemix.bundles.xmlschema
Bundle-Version = 1.4.3.1
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2
Import-Package =
javax.xml.namespace,
javax.xml.parsers,
javax.xml.transform,
javax.xml.transform.dom,
javax.xml.transform.sax,
javax.xml.transform.stream,
org.apache.ws.commons.schema;version=1.4.3,
org.apache.ws.commons.schema.constants;version=1.4.3,
org.apache.ws.commons.schema.extensions;version=1.4.3,
org.apache.ws.commons.schema.resolver;version=1.4.3,
org.apache.ws.commons.schema.utils;version=1.4.3,
org.w3c.dom,
org.xml.sax
Export-Package =
org.apache.ws.commons.schema.resolver;uses:=org.xml.sax;version=1.4.3,
org.apache.ws.commons.schema.utils;
uses:="org.apache.ws.commons.schema,
javax.xml.namespace,
org.w3c.dom";
version=1.4.3,
org.apache.ws.commons.schema;
uses:="org.xml.sax,
javax.xml.namespace,
org.w3c.dom,
javax.xml.transform,
org.apache.ws.commons.schema.extensions,
javax.xml.transform.dom,
javax.xml.transform.sax,
org.apache.ws.commons.schema.resolver,
org.apache.ws.commons.schema.utils,
javax.xml.parsers,
org.apache.ws.commons.schema.constants,
javax.xml.transform.stream";
version=1.4.3,
org.apache.ws.commons.schema.constants;
uses:=javax.xml.namespace;
version=1.4.3,
org.apache.ws.commons.schema.extensions;
uses:="org.apache.ws.commons.schema,
javax.xml.namespace,
org.w3c.dom";
version=1.4.3
The CXF version you use seems to be quite old. Can you test this with the most recent CXF version? Btw. What Karaf version are you using?
First of all, what is the state of bundle 785 (xmlschema-1.4.3) ?
If the state is resolved or active, it is ok; if it is only "installed", then there is a problem with it and the packages it exports are not available in the system.
Second, check who provides the packages imported by bundle 785. (org.w3c.dom etc)
You could have the following situation:
If bundle idb imports e.g. org.w3c.dom from one source, and xmlschema-1.4.3 imports them from another (e.g. different versions are available at the same time, or both the framework itself and some additional bundle provide it) then the framework won't resolve the idb bundle with the package from xmlschema-1.4.3, because this would lead to a ClassCastException later on.
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