jsevellec / cassandra-unit-examples

Various examples of using cassandra-unit
45 stars 63 forks source link

Error executing test: #5

Closed jschappet closed 10 years ago

jschappet commented 10 years ago

I am trying to run the following test: @Rule public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("tcgadata.cql","tcgadata"));

@Test
public void should_have_started_and_execute_cql_script() throws Exception {
    ResultSet result = cassandraCQLUnit.session.execute("select * from mytable WHERE id='myKey01'");
    assertThat(result.iterator().next().getString("value"), is("myValue01"));

  }

Using: cassandra-unit-spring 2.0.2.1-SNAPSHOT

And I get the following exception, looking at this yaml file, I do see the cas timeout setting.

09:55:16,556  INFO DatabaseDescriptor:132 - Loading settings from file: target/embeddedCassandra/cu-cassandra.yaml
09:55:16,956 ERROR DatabaseDescriptor:506 - Fatal configuration error error
Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=cas_contention_timeout_in_ms for JavaBean=org.apache.cassandra.config.Config@76a9b9c; Unable to find property 'cas_contention_timeout_in_ms' on class: org.apache.cassandra.config.Config

in "", line 10, column 1: cluster_name: 'Test Cluster' ^

at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136)
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122)
at org.yaml.snakeyaml.Loader.load(Loader.java:52)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:166)
at org.apache.cassandra.config.DatabaseDescriptor.loadYaml(DatabaseDescriptor.java:148)
at org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:123)
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)
at org.cassandraunit.BaseCassandraUnit.before(BaseCassandraUnit.java:18)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:41)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create property=cas_contention_timeout_in_ms for JavaBean=org.apache.cassandra.config.Config@76a9b9c; Unable to find property 'cas_contention_timeout_in_ms' on class: org.apache.cassandra.config.Config
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:305)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:184)
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370)
... 30 more
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'cas_contention_timeout_in_ms' on class: org.apache.cassandra.config.Config
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:342)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:240)
... 32 more

null; Can't construct a java object for tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create property=cas_contention_timeout_in_ms for JavaBean=org.apache.cassandra.config.Config@76a9b9c; Unable to find property 'cas_contention_timeout_in_ms' on class: org.apache.cassandra.config.Config Invalid yaml; unable to start server. See log for stacktrace.

jsevellec commented 10 years ago

Hi,

It looks like a classpath problem

Could you check the version of cassandra you're using in your classpath?

Jérémy

jschappet commented 10 years ago

Yep, still had cassandra-all 1.2.8 in my POM File. Thanks

yukevinchen commented 10 years ago

I have this exactly same error. Can you shed some light on how to fix it? These are the dependencies in my pom file:

    <dependency>
        <groupId>org.apache.cassandra</groupId>
        <artifactId>cassandra-clientutil</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency> 
        <groupId>org.apache.cassandra</groupId>
        <artifactId>cassandra-all</artifactId> 
        <version>2.1.0</version> 
    </dependency>
    <dependency>
        <groupId>org.apache.thrift</groupId> 
        <artifactId>libthrift</artifactId>
        <version>0.9.1</version> 
    </dependency>
    <dependency>
        <groupId>org.apache-extras.cassandra-jdbc</groupId>
        <artifactId>cassandra-jdbc</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit-dep</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit</artifactId>
        <version>2.0.2.1</version>
    </dependency>

Thanks!

JoanneZhuo commented 9 years ago

I met same problem. Can anyone enlighten me on this? Thanks!

swathiselv commented 9 years ago

Yes, please what is the solution here?

looser990 commented 9 years ago

I'm getting the same error here. We are trying to switch to cassandra driver 2.1.6. and newest version of cassandra-unit. Am I right if I think the problem is in cassandra-all version missmatch between driver and cassandra-unit or is there other problem involved here?

jsevellec commented 9 years ago

Hi,

I think this pull request is about to solve your classpath problem : https://github.com/jsevellec/cassandra-unit/pull/120

looser990 commented 9 years ago

Tested with versions: 2.1.3.2-SNAPSHOT and '2.1.3.1'. Others had some more luck? pom:

           <dependency>
                <groupId>org.apache.cassandra</groupId>
                <artifactId>cassandra-all</artifactId>
                <version>2.1.6</version>
            </dependency>
            <dependency>
                <groupId>com.datastax.cassandra</groupId>
                <artifactId>cassandra-driver-core</artifactId>
                <version>2.1.6</version>
            </dependency>
            <dependency>
                <groupId>com.datastax.cassandra</groupId>
                <artifactId>cassandra-driver-mapping</artifactId>
                <version>2.1.6</version>
            </dependency>
            <dependency>
                <groupId>org.cassandraunit</groupId>
                <artifactId>cassandra-unit</artifactId>
                <version>2.1.3.2-SNAPSHOT</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.cassandraunit</groupId>
                        <artifactId>cassandra-unit</artifactId>
                    </exclusion>                   
                </exclusions>
            </dependency>
jsevellec commented 9 years ago

the pull request i mentioned is about a new artifact : "cassandra-unit-shaded". It would be great if you could give a try using it instead of the cassandra-unit dependency to see if it solves your issue

looser990 commented 9 years ago

Working with shaded artifact like a charm! Thanks! When we can expect release version of it?

jsevellec commented 9 years ago

I'm waiting a bit for feedback and will perhaps just apply the shaded stuff into the same artifact id instead of having a dedicated one. It might be for this month.

looser990 commented 9 years ago

Neat. I support this to go in the same artifact id. Keep up the good work.