使用嵌入式cassandra服务器(cassandra-unit)的单元测试在intellij中运行,但是当通过sbt在命令行上运行时崩溃

时间:2016-08-30 18:16:40

标签: unit-testing intellij-idea cassandra

我试图在命令行上通过sbt运行我的单元测试,但每次出现此错误。

java.lang.NoSuchMethodError: org.apache.cassandra.utils.FBUtilities.getNetworkInterface(Ljava/net/InetAddress;)Ljava/lang/String;
    at org.apache.cassandra.net.MessagingService.getServerSockets(MessagingService.java:556)
    at org.apache.cassandra.net.MessagingService.listen(MessagingService.java:488)
    at org.apache.cassandra.net.MessagingService.listen(MessagingService.java:472)
    at org.apache.cassandra.service.StorageService.prepareToJoin(StorageService.java:832)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:727)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:613)
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:349)
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:551)
    at org.cassandraunit.utils.EmbeddedCassandraServerHelper$1.run(EmbeddedCassandraServerHelper.java:125)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
3126 [pool-6-thread-1] ERROR org.apache.cassandra.service.CassandraDaemon  - Exception encountered during startup
java.lang.NoSuchMethodError: org.apache.cassandra.utils.FBUtilities.getNetworkInterface(Ljava/net/InetAddress;)Ljava/lang/String;
    at org.apache.cassandra.net.MessagingService.getServerSockets(MessagingService.java:556)
    at org.apache.cassandra.net.MessagingService.listen(MessagingService.java:488)
    at org.apache.cassandra.net.MessagingService.listen(MessagingService.java:472)
    at org.apache.cassandra.service.StorageService.prepareToJoin(StorageService.java:832)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:727)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:613)
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:349)
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:551)
    at org.cassandraunit.utils.EmbeddedCassandraServerHelper$1.run(EmbeddedCassandraServerHelper.java:125)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

当我在intellij中运行时,它运行得很好。

下面是我从命令行获得的相关lib的依赖树。无法在这里发布整棵树。方式太多了。有什么想法吗?

 +-org.cassandraunit:cassandra-unit:3.0.0.1
[info]   | +-com.google.guava:guava:18.0
[info]   | +-io.netty:netty-handler:4.0.27.Final (evicted by: 4.0.33.Final)
[info]   | +-io.netty:netty-handler:4.0.33.Final
[info]   | | +-io.netty:netty-buffer:4.0.33.Final
[info]   | | | +-io.netty:netty-common:4.0.33.Final
[info]   | | | 
[info]   | | +-io.netty:netty-codec:4.0.33.Final
[info]   | | | +-io.netty:netty-transport:4.0.33.Final
[info]   | | |   +-io.netty:netty-buffer:4.0.33.Final
[info]   | | |     +-io.netty:netty-common:4.0.33.Final
[info]   | | |     
[info]   | | +-io.netty:netty-transport:4.0.33.Final
[info]   | |   +-io.netty:netty-buffer:4.0.33.Final
[info]   | |     +-io.netty:netty-common:4.0.33.Final
[info]   | |     
[info]   | +-junit:junit:4.12 (evicted by: 4.6)
[info]   | | +-org.hamcrest:hamcrest-core:1.3
[info]   | | 
[info]   | +-junit:junit:4.6
[info]   | +-org.apache.cassandra:cassandra-all:3.4
[info]   | | +-com.addthis.metrics:reporter-config3:3.0.0
[info]   | | | +-com.addthis.metrics:reporter-config-base:3.0.0
[info]   | | | | +-org.apache.commons:commons-lang3:3.1 (evicted by: 3.4)
[info]   | | | | +-org.apache.commons:commons-lang3:3.4
[info]   | | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | | +-org.yaml:snakeyaml:1.11
[info]   | | | | 
[info]   | | | +-io.dropwizard.metrics:metrics-core:3.1.0 (evicted by: 3.1.2)
[info]   | | | +-io.dropwizard.metrics:metrics-core:3.1.2
[info]   | | | | +-org.slf4j:slf4j-api:1.6.4 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.10 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | | +-org.slf4j:slf4j-api:1.7.5 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | | 
[info]   | | | +-org.apache.commons:commons-lang3:3.1 (evicted by: 3.4)
[info]   | | | +-org.apache.commons:commons-lang3:3.4
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | +-org.yaml:snakeyaml:1.11
[info]   | | | 
[info]   | | +-com.boundary:high-scale-lib:1.0.6
[info]   | | +-com.clearspring.analytics:stream:2.5.2 (evicted by: 2.7.0)
[info]   | | +-com.clearspring.analytics:stream:2.7.0
[info]   | | +-com.github.jbellis:jamm:0.3.0
[info]   | | +-com.google.guava:guava:18.0
[info]   | | +-com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap..
[info]   | | +-com.googlecode.json-simple:json-simple:1.1
[info]   | | +-com.ning:compress-lzf:0.8.4 (evicted by: 1.0.3)
[info]   | | +-com.ning:compress-lzf:1.0.3
[info]   | | +-com.thinkaurelius.thrift:thrift-server:0.3.7
[info]   | | | +-com.lmax:disruptor:3.0.1
[info]   | | | +-junit:junit:4.6
[info]   | | | +-org.apache.thrift:libthrift:0.9.2
[info]   | | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | | 
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | 
[info]   | | +-commons-cli:commons-cli:1.1 (evicted by: 1.2)
[info]   | | +-commons-cli:commons-cli:1.2
[info]   | | +-commons-codec:commons-codec:1.10
[info]   | | +-commons-codec:commons-codec:1.2 (evicted by: 1.10)
[info]   | | +-io.dropwizard.metrics:metrics-core:3.1.0 (evicted by: 3.1.2)
[info]   | | +-io.dropwizard.metrics:metrics-core:3.1.2
[info]   | | | +-org.slf4j:slf4j-api:1.6.4 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.10 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.5 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | 
[info]   | | +-joda-time:joda-time:2.4 (evicted by: 2.9.4)
[info]   | | +-joda-time:joda-time:2.9.4
[info]   | | +-net.java.dev.jna:jna:4.0.0
[info]   | | +-net.jpountz.lz4:lz4:1.3.0
[info]   | | +-org.antlr:antlr-runtime:3.5.2
[info]   | | +-org.antlr:antlr:3.5.2
[info]   | | | +-org.antlr:ST4:4.0.8
[info]   | | | | +-org.antlr:antlr-runtime:3.5.2
[info]   | | | | 
[info]   | | | +-org.antlr:antlr-runtime:3.5.2
[info]   | | | 
[info]   | | +-org.apache.cassandra:cassandra-thrift:3.4
[info]   | | | +-com.carrotsearch:hppc:0.5.4
[info]   | | | +-com.github.rholder:snowball-stemmer:1.3.0.581.1
[info]   | | | +-com.googlecode.concurrent-trees:concurrent-trees:2.4.0
[info]   | | | +-de.jflex:jflex:1.6.0
[info]   | | | | +-org.apache.ant:ant:1.7.0
[info]   | | | |   +-org.apache.ant:ant-launcher:1.7.0
[info]   | | | |   
[info]   | | | +-net.mintern:primitive:1.0
[info]   | | | +-org.apache.commons:commons-lang3:3.1 (evicted by: 3.4)
[info]   | | | +-org.apache.commons:commons-lang3:3.4
[info]   | | | +-org.apache.thrift:libthrift:0.9.2
[info]   | | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | | 
[info]   | | | +-org.slf4j:jcl-over-slf4j:1.7.19
[info]   | | | | +-org.slf4j:slf4j-api:1.7.19 (evicted by: 1.7.21)
[info]   | | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | | 
[info]   | | | +-org.slf4j:jcl-over-slf4j:1.7.7 (evicted by: 1.7.19)
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | 
[info]   | | +-org.apache.commons:commons-lang3:3.1 (evicted by: 3.4)
[info]   | | +-org.apache.commons:commons-lang3:3.4
[info]   | | +-org.apache.commons:commons-math3:3.2 (evicted by: 3.4.1)
[info]   | | +-org.apache.commons:commons-math3:3.4.1
[info]   | | +-org.apache.thrift:libthrift:0.9.2
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | 
[info]   | | +-org.caffinitas.ohc:ohc-core:0.4.2
[info]   | | | +-com.google.guava:guava:18.0
[info]   | | | +-net.java.dev.jna:jna:4.0.0
[info]   | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | | 
[info]   | | +-org.codehaus.jackson:jackson-core-asl:1.9.13
[info]   | | +-org.codehaus.jackson:jackson-core-asl:1.9.2 (evicted by: 1.9.13)
[info]   | | +-org.codehaus.jackson:jackson-mapper-asl:1.9.13
[info]   | | | +-org.codehaus.jackson:jackson-core-asl:1.9.13
[info]   | | | 
[info]   | | +-org.codehaus.jackson:jackson-mapper-asl:1.9.2 (evicted by: 1.9..
[info]   | | +-org.eclipse.jdt.core.compiler:ecj:4.4.2
[info]   | | +-org.fusesource:sigar:1.6.4
[info]   | | +-org.mindrot:jbcrypt:0.3m
[info]   | | +-org.slf4j:jcl-over-slf4j:1.7.19
[info]   | | | +-org.slf4j:slf4j-api:1.7.19 (evicted by: 1.7.21)
[info]   | | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | | 
[info]   | | +-org.slf4j:jcl-over-slf4j:1.7.7 (evicted by: 1.7.19)
[info]   | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | | +-org.slf4j:slf4j-api:1.7.21
[info]   | | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | | +-org.xerial.snappy:snappy-java:1.1.1.7
[info]   | | +-org.yaml:snakeyaml:1.11
[info]   | | 
[info]   | +-org.apache.commons:commons-lang3:3.1 (evicted by: 3.4)
[info]   | +-org.apache.commons:commons-lang3:3.4
[info]   | +-org.hamcrest:hamcrest-core:1.3
[info]   | +-org.hamcrest:hamcrest-library:1.3
[info]   | | +-org.hamcrest:hamcrest-core:1.3
[info]   | | 
[info]   | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
[info]   | +-org.slf4j:slf4j-api:1.7.21
[info]   | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
[info]   | 
[info]   +-org.scalamock:scalamock-scalatest-support_2.11:3.2.2 [S]
[info]   | +-org.scalamock:scalamock-core_2.11:3.2.2 [S]
[info]   | | +-org.scala-lang:scala-reflect:2.11.5 (evicted by: 2.11.8)
[info]   | | +-org.scala-lang:scala-reflect:2.11.8 [S]
[info]   | | 
[info]   | +-org.scalatest:scalatest_2.11:2.2.4 (evicted by: 2.2.6)
[info]   | +-org.scalatest:scalatest_2.11:2.2.6 [S]
[info]   |   +-org.scala-lang.modules:scala-xml_2.11:1.0.2 (evicted by: 1.0.4)
[info]   |   +-org.scala-lang.modules:scala-xml_2.11:1.0.4 [S]
[info]   |   +-org.scala-lang:scala-reflect:2.11.7 (evicted by: 2.11.8)
[info]   |   +-org.scala-lang:scala-reflect:2.11.8 [S]

1 个答案:

答案 0 :(得分:0)

对我而言,它是嵌入式thrift-server强制junit 4.6,自从2.1以后Cassandra不再使用Thrift应该可以排除该库。 将此行添加到build.sbt修复了问题

"org.cassandraunit" % "cassandra-unit" % "3.0.0.1" % "test" exclude("com.thinkaurelius.thrift", "thrift-server")