我正在尝试使用JackRabbit 2.11.1连接到远程仓库(使用jackrabbit-jcr-rmi)。捆绑软件在JBoss Fuse 6.2中运行,该引擎具有Apache Karaf 2.4/Felix 4.4。在启动时,我得到下面的异常。
如果我尝试使用jackrabbit-bundle,我会得到
“缺少约束:导入包:com.ibm.db2.jcc; version =“0.0.0””
所以我很困惑,JackRabbit 2.x OSGi准备好了吗?还是我需要使用Sling或Oak或....?
Caused by: org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve bundle revision wrap_mvn_org.apache.jackrabbit_jackrabbit-core_2.11.1 [270.0] because it exports package 'org.apache.jackrabbit.core.config' and is also exposed to it from bundle revision org.apache.jackrabbit.jackrabbit-data [276.0] via the following dependency chain:
wrap_mvn_org.apache.jackrabbit_jackrabbit-core_2.11.1 [270.0]
import: (osgi.wiring.package=org.apache.jackrabbit.core.data.db)
export: osgi.wiring.package=org.apache.jackrabbit.core.data.db; uses:=org.apache.jackrabbit.core.config
export: osgi.wiring.package=org.apache.jackrabbit.core.config
org.apache.jackrabbit.jackrabbit-data [276.0]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4006)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeatures(FeaturesServiceImpl.java:546)[9:org.apache.karaf.features.core:2.4.0.redhat-620133]
另请参阅https://issues.apache.org/jira/browse/JCR-3917
最佳答案
我用一个可怕的骇客解决了它。
因此,在Maven-Bundle-plugin中,我做到了:
<Embed-Dependency>jackrabbit-jcr2dav*,jackrabbit-jcr2spi*,jackrabbit-jcr-commons*;scope=compile;inline=false</Embed-Dependency>
在我使用的代码中:
ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(Jcr2davRepositoryFactory.class.getClassLoader());
//
repository = JcrUtils.getRepository(uri);
session = getSession();
// restore original classloader
Thread.currentThread().setContextClassLoader(originalContextClassLoader);
关于在Karaf 2.4/Felix 4.x中运行jackrabbit 2.11时出现OSGi错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34017902/