Cassandra source code ConfigurationException expection URI in cassandra.config found cassandra.yaml

白昼怎懂夜的黑 提交于 2020-01-14 15:55:14

问题


For my master thesis, I have to modify the source code of Cassandra. So, as suggested by https://wiki.apache.org/cassandra/HowToBuild, I git clone, then run ant, and everything seems nice (I managed to build the project without any error), but when I run the unitTests (cassandra/test), I have this strange error:

org.apache.cassandra.exceptions.ConfigurationException: 
   Expecting URI in variable: [cassandra.config]. 
   Found[cassandra.yaml]. 
   Please prefix the file with [file:\\\] for local files and 
      [file:\\<server>\] for remote files. 
   If you are executing this from an external tool, it needs 
   to set Config.setClientMode(true) to avoid loading configuration.

at org.apache.cassandra.config.YamlConfigurationLoader.getStorageConfigURL(YamlConfigurationLoader.java:80)
    at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:100)
    at org.apache.cassandra.config.DatabaseDescriptor.loadConfig(DatabaseDescriptor.java:252)
    at org.apache.cassandra.config.DatabaseDescriptor.daemonInitialization(DatabaseDescriptor.java:131)
    at org.apache.cassandra.auth.jmx.AuthorizationProxyTest.setup(AuthorizationProxyTest.java:48)"

I would like to test my modifications on the source code with the unitTests (because I didn't find any tutorial of how to set up cassandra from the source code on Windows, so if you have one, I would like to have the link ^^) but I didn't manage to find any solution for this bug :(. Anyone know a solution to this problem?

I am working on Windows 10 with IntelliJ and I have updated my Jdk and ant to the latest version.


回答1:


I was facing the same issue. Those variables ("cassandra.config", "cassandra.storagedir", etc...) are System variables.

You can either set them in your code by doing something like:

System.setProperty("cassandra.config", "file:///<PATH>/cassandra.yaml");

You can also set them whilst running the jar file:

java -Dcassandra.config=file:///<PATH>/cassandra.yaml -jar <JAR>

Best,

Shabir




回答2:


Start a new process in jdk 1.8 and start embedded cassandra in it. and run your junit in your java version. I faced similar isue which jdk11 upgrade. Now i fixed this.

import org.cassandraunit.utils.EmbeddedCassandraServerHelper;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class EmbeddedCassandraApplication {
    public static void main(String[] args) throws Exception {
        EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra-test.yaml");
    }
}


来源:https://stackoverflow.com/questions/42305113/cassandra-source-code-configurationexception-expection-uri-in-cassandra-config-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!