我无法在Karaf(版本3.0.1)中启动捆绑包.
捆绑包是使用maven构建的,它导入gson.
我根据需要在maven中包含了gson:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
构建顺利.但是,在部署捆绑包时,我收到了来自Karaf的警告:
2015-05-27 12:45:07,371 | WARN | 49-19-bin/deploy | fileinstall | 11 - org.apache.felix.fileinstall - 3.2.8 | Error while starting bundle: file:/Users/user/Documents/tools/MyBundle-1.0.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Unresolved constraint in bundle MyBundle [121]: Unable to resolve 121.13: missing requirement [121.13] osgi.wiring.package; (&(osgi.wiring.package=com.google.gson)(version>=2.3.0)(!(version>=3.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1263)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1235)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1224)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:519)[11:org.apache.felix.fileinstall:3.2.8]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:308)[11:org.apache.felix.fileinstall:3.2.8]
Run Code Online (Sandbox Code Playgroud)
捆绑包未安装.
在Import-Package中MANIFEST.MF开头:
Import-Package: com.google.gson;version="[2.3,3)"
Run Code Online (Sandbox Code Playgroud)
我试着改变它:
Import-Package: com.google.code.gson;version="[2.3,3)"
Run Code Online (Sandbox Code Playgroud)
但它给了我一个类似的错误:
missing requirement [121.13] osgi.wiring.package; (&(osgi.wiring.package=com.google.code.gson) …Run Code Online (Sandbox Code Playgroud)