I am currently developing a java application (with maven) with an embedded neo4j database. I followed the official guide and also looked at the examples on github.
My code looks like this now:
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
import org.neo4j.graphdb.*;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
public class GraphDatabase {
private DatabaseManagementService managementService;
private GraphDatabaseService databaseService;
public void start(String dir) {
managementService = new DatabaseManagementServiceBuilder(new File(dir)).build();
databaseService = managementService.database(DEFAULT_DATABASE_NAME);
}
...
}
In the pom.xml i included:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>4.0.0</version>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>{myPackageHere}.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
When running in Intellij IDE there are no problems, but when i compile with mvn package
and execute with java -jar <name>.jar
I get the following exception:
java.lang.IllegalArgumentException: Config has no association with setting: 'unsupported.dbms.lucene.ephemeral'
at org.neo4j.configuration.Config.getObserver(Config.java:635)
at org.neo4j.configuration.Config.set(Config.java:653)
at org.neo4j.dbms.api.DatabaseManagementServiceBuilder.newDatabaseManagementService(DatabaseManagementServiceBuilder.java:83)
at org.neo4j.dbms.api.DatabaseManagementServiceBuilder.build(DatabaseManagementServiceBuilder.java:78)
I tried this on both linux and windows with the same exception.
Anyone has an idea what my problem might be?
Update:
I removed the maven-assembly-plugin. If I compile and run the projekt like this, it works:
mvn compile
mvn exec:java -Dexec.mainClass={myPackageHere}.App
But I would still prefere a jar...