Problem running cassandra unit test example

3,242 views
Skip to first unread message

mettleurgist

unread,
Jul 2, 2014, 4:58:42 PM7/2/14
to cassandra-...@googlegroups.com
Hi -

I'm new to cassandra-unit and am trying to run one of the examples. I copy/pasted the CassandraCQLUnit example's code into my own java file and built it with maven (using cassandra 2.0.7 and snakeyaml 1.13, cassandra-unit 2.0.2.1). When I run it I get the following error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.288 sec <<< FAILURE!
test(com.lmco.test.CassandraUnitTest)  Time elapsed: 3.24 sec  <<< ERROR!
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9142 (com.datastax.driver.core.TransportException: [/127.0.0.1:9142] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:196)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1104)
at com.datastax.driver.core.Cluster.init(Cluster.java:121)
at com.datastax.driver.core.Cluster.connect(Cluster.java:198)
at org.cassandraunit.CassandraCQLUnit.load(CassandraCQLUnit.java:41)

Shouldn't cassandra-unit have started a cassandra server on localhost and on the default port 9142, so it should be able to connect. I am on Windows 7 and using Java 7

BTW, I am trying to run this example because I had issues with using the EmbeddedCassandraServerHelper.startEmbeddedCassandra(); in my existing unit tests. I was getting this error in case anyone may be able to help with this error (which is ultimately my real issue since it is in the "real" unit tests that i want to use cassandra-unit with).

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.697 sec <<< FAILURE!
ddf.catalog.source.solr.TestSolrProvider  Time elapsed: 0 sec  <<< ERROR!
java.lang.NoSuchFieldError: EOF_TOKEN
at org.apache.cassandra.cql3.CqlLexer.nextToken(CqlLexer.java:177)
at org.antlr.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:143)
at org.antlr.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:137)
at org.antlr.runtime.CommonTokenStream.consume(CommonTokenStream.java:68)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:106)
at org.apache.cassandra.cql3.CqlParser.constant(CqlParser.java:5227)
at org.apache.cassandra.cql3.CqlParser.propertyValue(CqlParser.java:6659)
at org.apache.cassandra.cql3.CqlParser.property(CqlParser.java:6589)
at org.apache.cassandra.cql3.CqlParser.cfamProperty(CqlParser.java:3178)
at org.apache.cassandra.cql3.CqlParser.cfamDefinition(CqlParser.java:2817)
at org.apache.cassandra.cql3.CqlParser.createTableStatement(CqlParser.java:2703)
at org.apache.cassandra.cql3.CqlParser.cqlStatement(CqlParser.java:513)
at org.apache.cassandra.cql3.CqlParser.query(CqlParser.java:308)
at org.apache.cassandra.cql3.QueryProcessor.parseStatement(QueryProcessor.java:417)
at org.apache.cassandra.config.CFMetaData.compile(CFMetaData.java:484)
at org.apache.cassandra.config.CFMetaData.compile(CFMetaData.java:476)
at org.apache.cassandra.config.CFMetaData.<clinit>(CFMetaData.java:93)
at org.apache.cassandra.config.KSMetaData.systemKeyspace(KSMetaData.java:80)
at org.apache.cassandra.config.DatabaseDescriptor.applyConfig(DatabaseDescriptor.java:474)
at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:110)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.mkdirs(EmbeddedCassandraServerHelper.java:227)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.cleanupAndLeaveDirs(EmbeddedCassandraServerHelper.java:199)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:95)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:65)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:49)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:45)

Thanks -

Hugh

Jérémy SEVELLEC

unread,
Jul 2, 2014, 5:36:01 PM7/2/14
to cassandra-...@googlegroups.com
Hi Hugh,

By default cassandra-unit is starting cassandra on the port 9142 with this config : https://github.com/jsevellec/cassandra-unit/blob/master/cassandra-unit/src/main/resources/cu-cassandra.yaml

Your error is a bit weird, could you provide me more infos or perhaps publishing a project where i can have a look to reproduce this error?

About the second error, it looks like a classpath issue.

Regards,

Jérémy


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "cassandra-unit-users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse cassandra-unit-u...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Jérémy

mettleurgist

unread,
Jul 2, 2014, 7:27:26 PM7/2/14
to cassandra-...@googlegroups.com
Thanks for the quick reply. I actually got the example to work when I modified the my cassandra.yaml file to use port 9042 and start native transport to true. I also figured out how to start the Embedded Cassandra Server and directly use its Session to execute CQL (which is better for our project since we dynamically create all tables at runtime).

Here is what I'm using in my unit test now and it works:

        EmbeddedCassandraServerHelper.startEmbeddedCassandra("/cassandra.yaml");
        Cluster cluster = new Cluster.Builder().addContactPoints("localhost").withPort(9042).build();
        Session session = cluster.connect();
        session.execute("CREATE KEYSPACE ddf WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}");
        session.execute("USE ddf");
        session.execute("CREATE TABLE myTable(id varchar, value varchar, PRIMARY KEY(id));");
        session.execute("INSERT INTO myTable(id, value) values('myKey01','myValue01');");
        ResultSet result = session.execute("select * from mytable WHERE id='myKey01'");
        assertThat(result.iterator().next().getString("value"), is("myValue01"));



My bigger issue is the NoSuchFieldError on EOF_TOKEN. When I put the above code in my "real" unit test I still get the NoSuchFieldError on EOF_TOKEN. I'm confused why this might be a classpath issue - looks like Cassandra Embedded Server is just starting up and trying to read metadata from the keyspace.

Again, thanks for your help.

Hugh

Jen M

unread,
Jul 17, 2014, 4:00:14 PM7/17/14
to cassandra-...@googlegroups.com
Hey there,

Just chiming in to let you know that I'm having the exact same issue. I'm using the same yaml provided in cassandra-unit-example, and have cassandra-unit 2.0.2.1 included in my build. I'm not quite sure how I should go about fixing the problem.

Jérémy SEVELLEC

unread,
Jul 20, 2014, 11:19:40 AM7/20/14
to cassandra-...@googlegroups.com
Hi,

Could you push a project to github where i can reproduce your issue?


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "cassandra-unit-users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse cassandra-unit-u...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Jérémy

Jen M

unread,
Jul 21, 2014, 9:40:32 AM7/21/14
to cassandra-...@googlegroups.com
Hey there,

I did figure out the issue. I was importing a newer version of antlr-runtime from another portion of the project.

Thanks!
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse cassandra-unit-users+unsub...@googlegroups.com.

Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Jérémy

Dan Kan

unread,
Nov 5, 2014, 10:17:45 PM11/5/14
to cassandra-...@googlegroups.com
I'm also getting the EOF_TOKEN error. Were you able to resolve this issue? 

Gagandeep Singh

unread,
Feb 25, 2015, 4:17:50 PM2/25/15
to cassandra-...@googlegroups.com
I get an EOFError when i try to connect to cassandraCQLUnit using cqlsh. I am guessing its the same issue:

$ cqlsh 127.0.0.1 9142
Traceback (most recent call last):
  File "/usr/local/bin/cqlsh", line 2044, in <module>
    main(*read_options(sys.argv[1:], os.environ))
  File "/usr/local/bin/cqlsh", line 2030, in main
    display_float_precision=options.float_precision)
  File "/usr/local/bin/cqlsh", line 480, in __init__
    cql_version=cqlver, transport=transport)
  File "/Library/Python/2.7/site-packages/cql/connection.py", line 143, in connect
    consistency_level=consistency_level, transport=transport)
  File "/Library/Python/2.7/site-packages/cql/connection.py", line 59, in __init__
    self.establish_connection()
  File "/Library/Python/2.7/site-packages/cql/thrifteries.py", line 159, in establish_connection
    self.remote_thrift_version = tuple(map(int, self.client.describe_version().split('.')))
  File "/Library/Python/2.7/site-packages/cql/cassandra/Cassandra.py", line 1255, in describe_version
    return self.recv_describe_version()
  File "/Library/Python/2.7/site-packages/cql/cassandra/Cassandra.py", line 1265, in recv_describe_version
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  File "/Library/Python/2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 126, in readMessageBegin
    sz = self.readI32()
  File "/Library/Python/2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
    buff = self.trans.readAll(4)
  File "/Library/Python/2.7/site-packages/thrift/transport/TTransport.py", line 63, in readAll
    raise EOFError()
EOFError
Reply all
Reply to author
Forward
0 new messages