0

Recently while merging in some new unit tests into my working branch, I started seeing this error:

Exception (java.lang.NoSuchMethodError) encountered during startup: com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService()Lcom/google/common/util/concurrent/ListeningExecutorService;
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService()Lcom/google/common/util/concurrent/ListeningExecutorService;
    at org.apache.cassandra.index.SecondaryIndexManager.<clinit>(SecondaryIndexManager.java:125)
    at org.apache.cassandra.db.ColumnFamilyStore.<init>(ColumnFamilyStore.java:405)
    at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:623)
    at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:597)
    at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:588)
    at org.apache.cassandra.db.Keyspace.initCf(Keyspace.java:417)
    at org.apache.cassandra.db.Keyspace.<init>(Keyspace.java:324)
    at org.apache.cassandra.db.Keyspace.open(Keyspace.java:129)
    at org.apache.cassandra.db.Keyspace.open(Keyspace.java:106)
    at org.apache.cassandra.db.SystemKeyspace.checkHealth(SystemKeyspace.java:935)
    at org.apache.cassandra.service.StartupChecks$10.execute(StartupChecks.java:422)
    at org.apache.cassandra.service.StartupChecks.verify(StartupChecks.java:125)
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:200)
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:602)
    at org.cassandraunit.utils.EmbeddedCassandraServerHelper.lambda$startEmbeddedCassandra$1(EmbeddedCassandraServerHelper.java:150)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Here's the offending test class:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = { MyApplication.class })
@TestExecutionListeners(listeners = { CassandraUnitDependencyInjectionTestExecutionListener.class, DependencyInjectionTestExecutionListener.class })
@EmbeddedCassandra(timeout = 100000)
@CassandraDataSet("indexer.cql")
@ActiveProfiles("test")
public class MyDaoTest {

    @Autowired
    MyDao myDao;


    @Test ...
}

I was able to verify that the unit tests pass as written by running mvn test -DskipMutation, so this appears to be an issue when using embedded Cassandra in conjunction with mutation tests, but I'm not very familiar with either of these technologies.

Has anyone ever run into this issue before, and could you provide some pointers on resolving this issue (without simply disabling mutation tests)?

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331

1 Answers1

0

The most probable cause of this error is that you have Guava version below 18.0 where the MoreExecutors.newDirectExecutor method was added - it's required for Cassandra. Run the mvn dependency:tree on your project and check for versions of Guava that you have in your project. If any of the dependencies are dependent on older version of Guava, try to exclude Guava from that dependency (although this may break your code - in this case, try to find dependency that doesn't use that old version of Guava).

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • Thanks for the reply but sadly I don't think this is it. `mvn dependency:tree -Dincludes=com.google.guava` returns only one dependency, `\- com.google.guava:guava:jar:18.0:compile`. – p.s.w.g Dec 26 '19 at 17:10
  • then maybe it isn't included into test classpath? Because it's really strange to see the `NoSuchMethod` then – Alex Ott Dec 26 '19 at 17:15