问题
I'm building a .kar-file, but when I run mvn package
I'm getting this error:
[INFO] --- maven-bundle-plugin:2.4.0:bundle (default-bundle) @ common ---
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/model/impl
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/marshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/runtime/unmarshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/util
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/unmarshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack/logging
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/api
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/util
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/runtime
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack/localization
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/model/annotation
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
My pom .xml:
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.common</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<!-- TODO: Insert your needed exports here -->
<Export-Package>*,se.eman.path.to.my.package.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
I just can't figure out what's causing these errors. When I read up on split package I get the very helpful advice that split package should be avoided. Yeah... I have no control what so ever over jaxb-impl, jaxb-core or com/sun/*.
Any ideas on how to troubleshoot this?
回答1:
The default value for Export-Package is {local-packages}
and not *
With the directive Export-Package: *
, you are asking bnd to export all the dependencies of your project.
Remove the * or use {local-packages}
Edit :
Note that you should only export public API from a Bundle. Everything else should be keep private. By default, maven-bundle-plugin export all packages, except package containing impl
or internal
. If you can, you should stick with this convention and omit the Export-Package
directive, or explicitly export your public packages.
回答2:
Please check http://mail-archives.apache.org/mod_mbox/felix-users/200709.mbox/%3CF034315F398DE24C9A76FB51DAFAB709FC9638@nets13ga.ww300.siemens.net%3E
Sample worked for me :
<Export-Package>
org.hibernate.*;version=${pkgVersion};-split-package:=merge-last
</Export-Package>
same answer at ; Use third party artifacts with split packages in Maven and Java 9
来源:https://stackoverflow.com/questions/35412390/why-am-i-getting-this-split-package-warning