javaconfigurationtitantinkerpop-blueprint

Titan's IllegalArgumentException on Graph creation


I'm getting an initialization error when I try to instantiate my graph in blueprints. Here's the code that I'm using to create a new graph:

String path = "conf/titan-cassandra-" + System.getProperty("env") + ".properties";
Graph graph = TitanFactory.open(path);

The system property is being set and the file exists. The error is being thrown in TitanFactory:

final Pattern p = Pattern.compile("(" + 
Pattern.quote(GraphDatabaseConfiguration.STORAGE_NS.getName()) + "\\..*" + "(" + 
Pattern.quote(GraphDatabaseConfiguration.STORAGE_DIRECTORY.getName()) + "|" + 
Pattern.quote(GraphDatabaseConfiguration.STORAGE_CONF_FILE.getName()) + ")" + "|" + 
Pattern.quote(GraphDatabaseConfiguration.INDEX_NS.getName()) + "\\..*" + "(" + 
Pattern.quote(GraphDatabaseConfiguration.INDEX_DIRECTORY.getName()) + "|" + 
Pattern.quote(GraphDatabaseConfiguration.INDEX_CONF_FILE.getName()) + ")" + ")");

Evaluating the expression GraphDatabaseConfiguration.STORAGE_NS yields 'null'. Why might this be?

Edit:

I'm including the stack trace as well

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.containsAny(Ljava/lang/String;[C)Z
    at com.thinkaurelius.titan.diskstorage.configuration.ConfigElement.<init>(ConfigElement.java:26)
    at com.thinkaurelius.titan.diskstorage.configuration.ConfigNamespace.<init>(ConfigNamespace.java:19)
    at com.thinkaurelius.titan.diskstorage.configuration.ConfigNamespace.<init>(ConfigNamespace.java:24)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<clinit>(GraphDatabaseConfiguration.java:81)
    at com.thinkaurelius.titan.core.TitanFactory.getLocalConfiguration(TitanFactory.java:240)
    at com.thinkaurelius.titan.core.TitanFactory.getLocalConfiguration(TitanFactory.java:170)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:61)
    at io.fama.api.service.GraphHolder.populateGraph(GraphHolder.java:28)
    at io.fama.api.service.GraphHolder.graph(GraphHolder.java:21)
    at io.fama.api.DebugTests.main(DebugTests.java:7)

When maven runs the test it throws a different error. This one looks like it's related to dependencies.


Solution

  • You didn't include the stack trace, but it is easily reproducible from the Gremlin shell. When running gremlin.sh, it is usually best to run it from the $TITAN_HOME directory, not $TITAN_HOME/bin.

    gremlin> graph = TitanFactory.open('conf/titan-cassandra-test.properties')
    Backend shorthand unknown: conf/titan-cassandra-test.properties
    Display stack trace? [yN] y
    java.lang.IllegalArgumentException: Backend shorthand unknown: conf/titan-cassandra-test.properties
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
        at com.thinkaurelius.titan.core.TitanFactory.getLocalConfiguration(TitanFactory.java:175)
        at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:61)
    

    You need to watch out for the relative path. Most likely you are running the program from a different directory such that the relative path to the properties file does not resolve. Either run the program from the correct parent directory or use an absolute path.