我正在尝试在Apache Karaf的OSGi捆绑包中使用datastax Java驱动程序。我已经解决了所有依赖关系,但现在遇到了一个问题,即驱动程序找不到必要的配置选项。
我更改了Thread类加载器,使其能够识别从https://github.com/datastax/java-driver/blob/4.3.0/examples/src/main/resources/application.conf复制的“ application.conf”,但仍缺少“ advanced.netty.daemon”键
public class CassandraAPIImpl implements CassandraAPI {
private CqlSession session;
public CassandraAPIImpl() {
ClassLoader regularClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(CassandraAPIImpl.class.getClassLoader());
try {
session = CqlSession.builder().build();
} finally {
Thread.currentThread().setContextClassLoader(regularClassLoader);
}
}
}
有问题的错误
ndraAPIImpl(13)] Error during instantiation of the implementation object
com.typesafe.config.ConfigException$Missing: application.conf @ bundle://211.3:1/application.conf: 16: No configuration setting found for key 'advanced.netty.daemon'
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:156) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:174) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:180) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:180) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:188) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:193) ~[?:?]
at com.typesafe.config.impl.SimpleConfig.getBoolean(SimpleConfig.java:218) ~[?:?]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[?:?]
at com.datastax.oss.driver.internal.core.config.typesafe.TypesafeDriverExecutionProfile.getCached(TypesafeDriverExecutionProfile.java:291) ~[?:?]
at com.datastax.oss.driver.internal.core.config.typesafe.TypesafeDriverExecutionProfile.getBoolean(TypesafeDriverExecutionProfile.java:64) ~[?:?]
at com.datastax.oss.driver.internal.core.context.DefaultNettyOptions.<init>(DefaultNettyOptions.java:64) ~[?:?]
at com.datastax.oss.driver.internal.core.context.DefaultDriverContext.buildNettyOptions(DefaultDriverContext.java:403) ~[?:?]
at com.datastax.oss.driver.internal.core.util.concurrent.LazyReference.get(LazyReference.java:55) ~[?:?]
at com.datastax.oss.driver.internal.core.context.DefaultDriverContext.getNettyOptions(DefaultDriverContext.java:654) ~[?:?]
at com.datastax.oss.driver.internal.core.session.DefaultSession.<init>(DefaultSession.java:100) ~[?:?]
at com.datastax.oss.driver.internal.core.session.DefaultSession.init(DefaultSession.java:85) ~[?:?]
at com.datastax.oss.driver.api.core.session.SessionBuilder.buildDefaultSessionAsync(SessionBuilder.java:548) ~[?:?]
at com.datastax.oss.driver.api.core.session.SessionBuilder.buildAsync(SessionBuilder.java:487) ~[?:?]
at com.datastax.oss.driver.api.core.session.SessionBuilder.build(SessionBuilder.java:501) ~[?:?]
at command.login.CassandraAPIImpl.<init>(CassandraAPIImpl.java:17) ~[?:?]