cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Issues configuring embedded instance on the same machine as Neo4j-Desktop installation

JD202
Node Link

Hello.

I've been trying to configure an embedded instance of Neo4J-4.0.1 using Kotlin via Gradle. Below, I have attached my code:

package ai.glue.me.trace

import org.neo4j.configuration.GraphDatabaseSettings
import org.neo4j.configuration.connectors.BoltConnector
import org.neo4j.configuration.helpers.SocketAddress
import org.neo4j.dbms.DatabaseManagementSystemSettings
import org.neo4j.dbms.api.DatabaseManagementService
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder
import java.io.File
import java.nio.file.Paths
import java.util.*

object DBUtil {
    private var runInit = false
    private val queue = PriorityQueue<String>()
    var dbService:DatabaseManagementService? = null


    fun init(): DBUtil {
        if (runInit) return this

        val dbService = DatabaseManagementServiceBuilder(File("db/Trace"))
                .setConfig(BoltConnector.enabled, true)
//                .setConfig(DatabaseManagementSystemSettings.auth_store_directory, Paths.get("db/Trace/auth/"))
//                .setConfig(GraphDatabaseSettings.data_directory, Paths.get("db/Trace/datadir/"))
                .setConfig(GraphDatabaseSettings.neo4j_home, Paths.get("/"))
                .setConfig(BoltConnector.listen_address, SocketAddress("localhost", 7687))
                .build()
        val graphDb = dbService.database("Trace")
        this.dbService = dbService

        runInit = true
        return this //TODO change
        //TODO load database, prepare queue for intake, print progress to console
    }

    /**
     * Flush all queued transactions to the database, without closing the connection
     *
     * @return Boolean - If the flush was successful
     */
    fun flush():Boolean {
        return true
    }
}

The init() function is called from the main thread (not shown). The issue occurs when building the DatabaseManagementService instance with .build(), as the console returns this stack trace:

Error occurred while enabling Trace v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Can not resolve setting dependencies. ['unsupported.dbms.directories.auth'->'dbms.directories.data'] depend on settings not present in config, or are in a circular dependency
        at org.neo4j.configuration.Config.evaluateSettingValues(Config.java:396) ~[?:?]
        at org.neo4j.configuration.Config.<init>(Config.java:357) ~[?:?]
        at org.neo4j.configuration.Config$Builder.build(Config.java:260) ~[?:?]
        at org.neo4j.dbms.api.DatabaseManagementServiceBuilder.build(DatabaseManagementServiceBuilder.java:78) ~[?:?]
        at ai.glue.me.trace.DBUtil.init(DBUtil.kt:28) ~[?:?]

I've searched the community as well as Google meticulously and haven't yet found anyone with this issue. From what I understand, it's an issue with the mentioned config settings not being set, although I have tried setting them. I've also tried copying the neo4j.conf file shipped with the Neo4J-desktop zip (which is also installed to the same system) and copying it to a resources directory, then pointing to that, with no success. I have also repeated the same steps but with a /data/ directory, which is stated as being the default directory for config files.

I don't understand what I'm missing. I've tried many combinations of settings, directories, etc. I can only assume that I'm missing some settings that are marked as dependencies, but the stack trace isn't very clear on what is missing, or that there is indeed, somehow, a cyclic dependency.

I appreciate any help that I can be offered.

1 ACCEPTED SOLUTION

JD202
Node Link

I have come to a solution!

I am no longer using Neo4J!

Thanks, OrientDB.

P.S., this does seem to be an issue presented by packing Neo4J into a fat jar. I was using Gradle's shadowJar plugin. By using the mergeServiceFiles() setting, I was able to rid my console of the given error message, only to receive a brand new error stating that scala/Serializable could not be found (despite being present in the fat jar...). I tried specifically shading it into the jar using Gradle, with no difference in results.

So... I believe I've tried everything I can. I really was hoping to be able to use Neo4J, because I've only ever had great experiences with it before, especially with the Cypher query language. It's a shame I have to move on, but with no response from the community, I am left with no other options.

View solution in original post

3 REPLIES 3

JD202
Node Link

Following up, I've managed to create a database instance in a blank project, but I am unable to do so when running this code inside of a Spigot plugin. I have tried directly copying the working code over to no avail. I have also tried directly setting the apparently-missing configuration settings using setConfigRaw(...) with no success.

JD202
Node Link

A further follow-up.

I have re-checked every approach I have tried thus far, with no differences in success. I also attempted to load a neo4j.conf instance directly in to the DatabaseManagementServiceBuilder instance, using blank config files, files with only the aforementioned settings included, and even pre-written files I found online. None of these worked, I still receive the exact same error message.

I am stuck for what to do. I don't understand how this can work so seamlessly in a standalone application, yet struggle to work when launched via the onEnable() method of a Spigot plugin. The code execution is surely the same, so unless Spigot is running some peculiar back-end logic, I see no reason for these errors to exist.

I also cannot find reference to these errors anywhere in any documentation, sourcecode, etc. so understanding what internal Neo4J workings are responsible is difficult.

I really do appreciate any help that can be offered to this challenge and I am certain it will help any other future developers also encountering this same situation.

EDIT: All of the aforementioned steps were taken with Neo4J-Desktop fully uninstalled (including configuration files).

JD202
Node Link

I have come to a solution!

I am no longer using Neo4J!

Thanks, OrientDB.

P.S., this does seem to be an issue presented by packing Neo4J into a fat jar. I was using Gradle's shadowJar plugin. By using the mergeServiceFiles() setting, I was able to rid my console of the given error message, only to receive a brand new error stating that scala/Serializable could not be found (despite being present in the fat jar...). I tried specifically shading it into the jar using Gradle, with no difference in results.

So... I believe I've tried everything I can. I really was hoping to be able to use Neo4J, because I've only ever had great experiences with it before, especially with the Cypher query language. It's a shame I have to move on, but with no response from the community, I am left with no other options.