1

I'm new to neo4j and trying to import an .osm data to my embeddedDatabase but it doesn't work. I searched for some example code and finally I ended up with this code which I got by trying to understand the TestOSMImport.java

private void importOSM(){


    OSMImporter importer = new OSMImporter("map2.osm");
    importer.setCharset(Charset.forName("UTF-8"));

    try{
        System.out.println("Bis hier");
        GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

        importer.importFile(db, "map2.osm",false,5000,true);

        System.out.println("start____ReIndex!");
        importer.reIndex(db,10000);
        db.shutdown();


    }catch(Exception e){
        System.out.println("__________Import Error!! "+e.getMessage());
        e.printStackTrace();
    }
}

The code is starting the reIndex method and then comes up with this error

Re-indexing with GraphDatabaseService: EmbeddedGraphDatabase [neo4j-community-1.9.4\data\graph.db] (class: class org.neo4j.kernel.EmbeddedGraphDatabase)
Exception in thread "main" java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
    at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateRootFrom(SpatialDatabaseService.java:75)
    at org.neo4j.gis.spatial.SpatialDatabaseService.getSpatialRoot(SpatialDatabaseService.java:80)
    at org.neo4j.gis.spatial.SpatialDatabaseService.getLayer(SpatialDatabaseService.java:102)
    at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:196)
    at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:208)
    at org.neo4j.gis.spatial.osm.OSMImporter.reIndex(OSMImporter.java:264)
    at foo.App.importOSM(App.java:67)
    at foo.App.main(App.java:82)
    Suppressed: java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
        at org.neo4j.gis.spatial.SpatialDatabaseService.getLayer(SpatialDatabaseService.java:113)
        ... 5 more
    Suppressed: java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
        at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:204)
        ... 4 more

Can someone help me please find the solution??

I used maven for neo4j and -spatial


thank you for the response you're right im using neo4j 1.9.4 here is my pom.xml

<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>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>1</version>
<!-- Inferring Ranking On Networks by Inquiry Distance -->

<name>neo4j</name>
<url>http://maven.apache.org</url>




<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

    <dependency>
        <groupId>com.tinkerpop.blueprints</groupId>
        <artifactId>blueprints-core</artifactId>
        <version>2.4.0</version>
    </dependency>

  <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
  </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency> 
        <groupId>org.neo4j</groupId> 
        <artifactId>neo4j-spatial</artifactId>
        <version>0.12-neo4j-2.0.0-SNAPSHOT</version> 
    </dependency>

    <dependency>
        <groupId>stax</groupId>
        <artifactId>stax-api</artifactId>
        <version>1.0.1</version>
    </dependency>

    <dependency>
        <groupId>com.vividsolutions</groupId>
        <artifactId>jts</artifactId>
        <version>1.13</version>
    </dependency>

    <dependency>
        <groupId>com.tinkerpop.gremlin</groupId>
        <artifactId>gremlin-groovy</artifactId>
        <version>2.4.0</version>
        <type>jar</type> 
    </dependency>


    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j</artifactId>
        <version>1.9.4</version>
    </dependency>

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-kernel</artifactId>
        <version>1.7</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>   
</dependencies>

<repositories>
    <repository>
        <id>mvn</id>
        <url>http://repo.maven.apache.org</url>
    </repository>

    <repository>
        <id>mvnrepository</id>
        <url>http://repo1.maven.org/maven2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>

    <repository>
        <id>neo4j-release-repository</id>
        <name>Neo4j Maven 2 release repository</name>
        <url>http://m2.neo4j.org/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>neo4j-snapshot-repository</id>
        <name>Neo4j Maven 2 snapshot repository</name>
        <url>http://m2.neo4j.org/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>


<build>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>


</build>

user3042984
  • 61
  • 1
  • 8
  • Could you post your pom.xml? I think you have a version mismatch: neo4j-spatial version expects neo4j 2.0, but you use 1.9. It's trying to call .close() on the transaction, which I think is part of neo4j 2.0 making transactions autocloseable to work with try-with-resources in java 7. – jjaderberg Nov 27 '13 at 19:44
  • thank you for the response you are right im using 1.9.4 i posted my pom.xml – user3042984 Nov 27 '13 at 23:28

1 Answers1

1

You have to use a version of neo4-spatial that's built for the version of Neo4j you are using. Try changing

<version>0.12-neo4j-2.0.0-SNAPSHOT</version>

to

<version>0.11-neo4j-1.9</version>
jjaderberg
  • 9,844
  • 34
  • 34