我嘗試訪問與卡桑德拉後端泰坦圖形數據庫和一切工作正常用下面的代碼:無法實例化實現:AstyanaxStoreManager
package ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy;
import ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.ITreeSerializer;
import ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.TitanSerializer;
public class ConnectionOkDriver {
public static void main(String[] args) {
ITreeSerializer serializer = TitanSerializer.getInstance();
if (serializer.dbConnected()) {
System.out.print("connection ok");
} else {
System.out.print("connection NOT ok");
}
}
}
輸出(忽略SLF4J錯誤):
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
connection ok
現在,如果我啓動以下主要方法,我得到一個Could not instantiate implementation
錯誤:
package ch.uzh.ifi.ddis.dm.twhc.input;
import ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.ITreeSerializer;
import ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.TitanSerializer;
public class ConnectionFailsDriver {
public static void main(String[] args) {
ITreeSerializer serializer = TitanSerializer.getInstance();
if (serializer.dbConnected()) {
System.out.print("connection ok");
} else {
System.out.print("connection NOT ok");
}
}
}
輸出(再次忽略SLF4J錯誤):
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.ExceptionInInitializerError
at ch.uzh.ifi.ddis.dm.twhc.input.ConnectionFailsDriver.main(ConnectionFailsDriver.java:9)
Caused by: java.lang.IllegalArgumentException: Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager
at com.thinkaurelius.titan.diskstorage.Backend.getImplementationClass(Backend.java:274)
at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:227)
at com.thinkaurelius.titan.diskstorage.Backend.<init>(Backend.java:97)
at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:440)
at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.<init>(StandardTitanGraph.java:67)
at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:40)
at ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.TitanSerializer.<init>(TitanSerializer.java:88)
at ch.uzh.ifi.ddis.dm.twhc.clusterhierarchy.persistence.TitanSerializer.<clinit>(TitanSerializer.java:78)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.thinkaurelius.titan.diskstorage.Backend.getImplementationClass(Backend.java:263)
... 8 more
Caused by: java.lang.NoSuchMethodError: com.netflix.astyanax.AstyanaxContext.getClient()Ljava/lang/Object;
at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager.<init>(AstyanaxStoreManager.java:166)
... 13 more
正如你所看到的類ConnectionOkDriver
和ConnectionFailsDriver
僅在包中定義的不同。但是,這兩個類包含在不同的Maven模塊中(2whc-clustering-impl依賴於2whc-cluster-hierarchy-impl)。我想後我的項目結構的圖像,但我不能這樣做:(這裏是將圖像的鏈接:https://dl.dropboxusercontent.com/u/48169775/project-structure.png
在我TitanSerializer
對象在TitanFactory.open(conf)
構造出現的錯誤。這是代碼:
private static final String DB_TYPE = "cassandra";
private static final String DB_IP = "127.0.0.1";
private TitanSerializer() {
Configuration conf = new BaseConfiguration();
conf.setProperty("storage.backend", DB_TYPE);
conf.setProperty("storage.hostname", DB_IP);
this.graph = TitanFactory.open(conf);
.
.
.
}
你有一個想法,爲什麼我得到這個錯誤
能否請您附上依賴於每一個項目,'MVN的可能結果依賴關係:tree -Dverbose'? – lpiepiora
Thx爲依賴提示。 – Faber