我开始使用gatling和maven依赖
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>2.2.5</version>
<scope>test</scope>
</dependency>
但是我的Cassandra组件遇到了使用此依赖项的问题
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.2.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
当我看到日志时,我可以看到此异常
INFO 2017-04-25T14:31:43,119 [] [com.datastax.driver.core.GuavaCompatibility] Detected Guava < 19 in the classpath, using legacy compatibility layer
INFO 2017-04-25T14:31:44,000 [] [com.datastax.driver.core.Native] Could not load JNR C Library, native system calls through this library will not be available (set this logger level to DEBUG to see the full stack trace).
INFO 2017-04-25T14:31:44,000 [] [com.datastax.driver.core.ClockFactory] Using java.lang.System clock to generate timestamps.
WARN 2017-04-25T14:31:44,789 [] [com.datastax.driver.core.NettyUtil] Found Netty's native epoll transport, but not running on linux-based operating system. Using NIO instead.
WARN 2017-04-25T14:31:46,457 [] [io.netty.util.concurrent.DefaultPromise] An exception was thrown by com.datastax.driver.core.Connection$1.operationComplete()
java.lang.NullPointerException
at io.netty.channel.group.DefaultChannelGroup.add(DefaultChannelGroup.java:146) ~[netty-transport-4.1.5.Final.jar:4.1.5.Final]
at io.netty.channel.group.DefaultChannelGroup.add(DefaultChannelGroup.java:42) ~[netty-transport-4.1.5.Final.jar:4.1.5.Final]
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:161) ~[cassandra-driver-core-3.2.0.jar:?]
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:148) ~[cassandra-driver-core-3.2.0.jar:?]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) [netty-common-4.1.5.Final.jar:4.1.5.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:488) [netty-common-4.1.5.Final.jar:4.1.5.Final]
at io.netty.util.concurrent.DefaultPromise.access$000(DefaultPromise.java:34) [netty-common-4.1.5.Final.jar:4.1.5.Final]
at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:438) [netty-common-4.1.5.Final.jar:4.1.5.Final]
at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:233) [netty-common-4.1.5.Final.jar:4.1.5.Final]
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) [netty-common-4.1.5.Final.jar:4.1.5.Final]
知道如何解决这个冲突吗?
问候。
答案 0 :(得分:2)
我们的项目前一段时间遇到了同样的问题。经过调查,我们发现了相互冲突的netty版本。
将着色的netty jar添加到datastax驱动程序dependecny会导致Linux系统出现问题,因为在这种情况下,着色的netty jar不会在Linux系统上使用Native epoll传输。
我们刚刚从datastax驱动程序依赖项中删除了shaded
分类器,但为netty添加了排除:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.2</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
它适用于Linux和Windows系统。但我们很幸运,我们的netty版本与datastax驱动程序版本兼容。
答案 1 :(得分:1)
看起来冲突是gatling需要netty 4.1而驱动程序需要netty 4.0。您可以使用驱动程序的着色版本并从驱动程序中明确排除netty依赖项来解决此问题。来自docs page:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.2.0</version>
<classifier>shaded</classifier>
<!-- Because the shaded JAR uses the original POM, you still need
to exclude this dependency explicitly: -->
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>