Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml file not in root directory prevents startup #135

Closed
szetheli opened this issue Jul 30, 2015 · 10 comments
Closed

yaml file not in root directory prevents startup #135

szetheli opened this issue Jul 30, 2015 · 10 comments
Labels
Milestone

Comments

@szetheli
Copy link

testCompile('org.cassandraunit:cassandra-unit:2.1.3.1')
testCompile('org.apache.cassandra:cassandra-all:2.1.8')
testCompile 'com.google.guava:guava:18.0'

EmbeddedCassandraServerHelper.startEmbeddedCassandra("config/cassandra.yaml");

Results in exception:
2015-07-30 14:37:45,098 EventType=ERROR LogName=org.apache.cassandra.config.DatabaseDescriptor [main,{}]:
Fatal configuration error
org.apache.cassandra.exceptions.ConfigurationException: Expecting URI in variable: [cassandra.config]. Please prefix the file with file:/// for local files or file:/// for remote files. Aborting. 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:73)
at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:84)
at org.apache.cassandra.config.DatabaseDescriptor.loadConfig(DatabaseDescriptor.java:161)
at org.apache.cassandra.config.DatabaseDescriptor.(DatabaseDescriptor.java:136)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.mkdirs(EmbeddedCassandraServerHelper.java:244)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.cleanupAndLeaveDirs(EmbeddedCassandraServerHelper.java:216)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:107)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:77)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:57)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:53)
at com.expedia.www.optimus.storage.SessionManagerUnitTests.testSessionFromNewCluster(SessionManagerUnitTests.java:239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Expecting URI in variable: [cassandra.config]. Please prefix the file with file:/// for local files or file:/// for remote files. Aborting. If you are executing this from an external tool, it needs to set Config.setClientMode(true) to avoid loading configuration.
Fatal configuration error; unable to start. See log for stacktrace.

What went wrong:
org.cassandraunit.utils.EmbeddedCassandraServerHelper.copy(String, String) copies the file to target/embeddedCassandra/cassandra.yaml because copy strips off all the path information from the from string.

org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(String, String, long) appends the string as is to build the property to send to cassandra.

Either the copy task needs to be preserve the path passed in, or startEmbeddedCassandra is the one that needs to strip path information.

@dariodariodario
Copy link

I've the same issue here

@JosephKiranBabu
Copy link

@szetheli @dariodariodario Did you guys find any workaround for this issue?

@prakapenka
Copy link

Have same issue by the way.
Seems there is no workaround on it.
When cassandra starts it uses class 'org.apache.cassandra.config.YamlConfigurationLoader' to load yaml file.
Take a look here:
https://github.com/apache/cassandra/blob/4a0d1caa262af3b6f2b6d329e45766b4df845a88/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java#L68

It is reads the

System.getProperty("cassandra.config") 

value that we did previously set when did preparing embedded cassandra.
The issue that we have "cassandra.config" value set as:

file:D:/github/cassandra-unit/cassandra-unit/target/embeddedCassandra/another-cassandra.yaml

cassnadra checks for correct url doing

url.openStream().close(); // catches well-formed but bogus URLs

And sometimes it is treated as correct url sometimes not. If you have a pom-based project and a /target folder will be on classpath - like in cassandra-unit tests in file
https://github.com/jsevellec/cassandra-unit/blob/master/cassandra-unit/src/test/java/org/cassandraunit/CassandraAbstractTestCaseCustomYamlTest.java#L17
that will works. If you have not-maven project that inherits eclipse structure - using test-src forder, doing compilation not in target - this will fail.

To fix this behaviour we just need to set correct "cassandra.config" value which should be like:

file://D:/some/folder/...

That the issue for cassandra-unit.

In general to validate url better to use

UrlValidator urlValidator = new UrlValidator();
Assert.assertTrue( urlValidator.isValid(corectUrlFilePath));

...and only after that attempt to open/close to have final check - that a issue for cassandra.

Since even strictly says incorrect url can be resolved under some circumstances.
I'll try to open pull request on it shortly.

@jsevellec
Copy link
Owner

hi @prakapenka,

thanks for the investigation. I'm looking forward to the PR ;-)

@yackoa
Copy link

yackoa commented Nov 15, 2018

Hi @prakapenka do you know if the issue is resolved or if the PR was accepted after the fix ? I am still getting the issue in now

@javadba
Copy link

javadba commented Mar 11, 2019

I think i am also seeing this problem but am a new user to cassandra so it may be something else.

@pyjaime
Copy link

pyjaime commented Oct 15, 2019

hey @jsevellec, the problem is still there :)

@jsevellec jsevellec added this to the 3.7.1.1 milestone Oct 15, 2019
@jsevellec jsevellec added the bug label Oct 15, 2019
@jsevellec
Copy link
Owner

Sorry for the latency...

That should be solved.

While waiting for the next release, snapshot is already available with the fix if you want to give it a try (3.7.1.1-SNAPSHOT : https://oss.sonatype.org/content/repositories/snapshots/)

@jelmerk
Copy link

jelmerk commented Dec 4, 2019

When is this being released?

@samanthakem
Copy link

Yeah, when is it going to be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants