2013-08-18 52 views
0

我嘗試訪問與卡桑德拉後端泰坦圖形數據庫和一切工作正常用下面的代碼:無法實例化實現: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 

正如你所看到的類ConnectionOkDriverConnectionFailsDriver僅在包中定義的不同。但是,這兩個類包含在不同的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); 
      . 
      . 
      . 
    } 

你有一個想法,爲什麼我得到這個錯誤

+0

能否請您附上依賴於每一個項目,'MVN的可能結果依賴關係:tree -Dverbose'? – lpiepiora

+0

Thx爲依賴提示。 – Faber

回答

1

的問題涉及到分佈於多行家模塊的依賴要解決它,我感動了所有的「外部」之類的依賴。 titan-all到核心(或者我們應該怎麼稱呼它?)maven模塊2whc。所有其他模塊現在只依賴於我自己的模塊。例如2whc-clustering-impl僅取決於2whc-cluster-hierarchy-impl2whc-cluster-hierarchy-impl根本就沒有任何依賴關係。然而,eclipse Maven POM Editor的選項卡有效pom顯示了所有模塊的模塊自身的依賴關係和核心模塊2whc dependecies。

POM的2whc-clustering-impl

POM的 2whc-cluster-hierarchy-impl POM 2whc

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <artifactId>2whc</artifactId> 
     <groupId>ch.uzh.ifi.ddis.dm</groupId> 
     <version>0.0.1-SNAPSHOT</version> 
     <relativePath>..</relativePath> 
    </parent> 

    <artifactId>2whc-cluster-hierarchy-impl</artifactId> 

    ... 

    <dependencies> 

    </dependencies> 
</project> 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <artifactId>2whc</artifactId> 
     <groupId>ch.uzh.ifi.ddis.dm</groupId> 
     <version>0.0.1-SNAPSHOT</version> 
     <relativePath>..</relativePath> 
    </parent> 

    <artifactId>2whc-clustering-impl</artifactId> 

    ... 

    <dependencies>  
     <dependency> 
      <groupId>ch.uzh.ifi.ddis.dm</groupId> 
      <artifactId>2whc-cluster-hierarchy-impl</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
     </dependency> 
    </dependencies> 
</project> 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>ch.uzh.ifi.ddis.dm</groupId> 
    <artifactId>2whc</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <name>Two-Way Hierarchical Clustering</name> 

    ... 

    <modules> 
     <module>2whc-clustering-api</module> 
     <module>2whc-clustering-impl</module> 
     <module>2whc-cluster-hierarchy-impl</module> 
     <module>2whc-recommendations-impl</module> 
    </modules> 

    ... 

    <dependencies> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${slf4j.version}</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>${slf4j.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>${testng.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>net.sf.supercsv</groupId> 
      <artifactId>super-csv</artifactId> 
      <version>2.1.0</version> 
     </dependency>  
     <dependency> 
      <groupId>org.apache.xmlbeans</groupId> 
      <artifactId>xmlbeans</artifactId> 
      <version>2.6.0</version> 
     </dependency>  
     <dependency> 
      <groupId>net.sf.trove4j</groupId> 
      <artifactId>trove4j</artifactId> 
      <version>3.0.3</version> 
     </dependency>  
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-math3</artifactId> 
      <version>3.2</version> 
     </dependency>   
     <dependency> 
      <groupId>ch.uzh.agglorecommender</groupId> 
      <artifactId>inputbeans</artifactId> 
      <version>0.01</version> 
     </dependency>   
     <dependency> 
      <groupId>com.thinkaurelius.titan</groupId> 
      <artifactId>titan-all</artifactId> 
      <version>0.3.2</version> 
     </dependency>   
    </dependencies> 
    <properties> 
     <testng.version>6.8.5</testng.version> 
     <slf4j.version>1.6.6</slf4j.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    </properties> 
</project>