Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apoc extended on 5.2 throws errors for missing config values #3358

Closed
jexp opened this issue Dec 7, 2022 · 8 comments · Fixed by #3374
Closed

apoc extended on 5.2 throws errors for missing config values #3358

jexp opened this issue Dec 7, 2022 · 8 comments · Fixed by #3374
Assignees

Comments

@jexp
Copy link
Member

jexp commented Dec 7, 2022

we should probably not throw on non-existing for getBoolean in commons-config but give it a default value of false

2022-12-07 13:13:48.611+0000 ERROR [neo4j/cdae02f5] failed to start service ttl
java.util.NoSuchElementException: Key 'apoc.ttl.enabled' does not map to an existing object!
	at org.apache.commons.configuration2.AbstractConfiguration.throwMissingPropertyException(AbstractConfiguration.java:1531) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at org.apache.commons.configuration2.AbstractConfiguration.checkNonNullValue(AbstractConfiguration.java:1520) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at org.apache.commons.configuration2.AbstractConfiguration.getBoolean(AbstractConfiguration.java:940) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at apoc.ApocConfig.getBoolean(ApocConfig.java:287) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.TTLConfig.configFor(TTLConfig.java:26) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.ttl.TTLLifeCycle.start(TTLLifeCycle.java:44) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.ApocExtensionFactory$ApocLifecycle.lambda$start$2(ApocExtensionFactory.java:107) ~[apoc-5.2.0-extended.jar:5.2.0]
	at java.util.HashMap.forEach(HashMap.java:1420) ~[?:?]
	at apoc.ApocExtensionFactory$ApocLifecycle.lambda$start$3(ApocExtensionFactory.java:105) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.ApocExtensionFactory$ApocLifecycle.withNonSystemDatabase(ApocExtensionFactory.java:82) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.ApocExtensionFactory$ApocLifecycle.start(ApocExtensionFactory.java:104) ~[apoc-5.2.0-extended.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:353) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:92) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.extension.AbstractExtensions.start(AbstractExtensions.java:78) ~[neo4j-kernel-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:353) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:92) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:353) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:92) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.database.AbstractDatabase.start(AbstractDatabase.java:158) ~[neo4j-kernel-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:353) ~[neo4j-common-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:92) ~[neo4j-common-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.database.EnterpriseDatabase.start(EnterpriseDatabase.java:47) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.database.DatabaseManager.startDatabase(DatabaseManager.java:179) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.database.DatabaseManager.forSingleDatabase(DatabaseManager.java:242) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.database.DatabaseManager.startDatabase(DatabaseManager.java:140) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.Transition$Prepared.doTransitionAction(Transition.java:94) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.Transition$Prepared.doTransition(Transition.java:83) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:257) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:258) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.doTransitionStep(DbmsReconciler.java:258) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.doTransitionSteps(DbmsReconciler.java:245) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.executeJob(DbmsReconciler.java:203) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.DbmsReconciler.lambda$scheduleReconciliationJob$2(DbmsReconciler.java:187) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.ReconcilerJob.executeJob(ReconcilerJob.java:49) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at com.neo4j.dbms.ReconcilerJobManager$ReconciliationWorker.run(ReconcilerJobManager.java:192) ~[neo4j-dbms-enterprise-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.impl.scheduler.ThreadPool.lambda$asCallable$1(ThreadPool.java:136) ~[neo4j-kernel-5.2.0.jar:5.2.0]
	at org.neo4j.kernel.impl.scheduler.ThreadPool.lambda$submit$0(ThreadPool.java:108) ~[neo4j-kernel-5.2.0.jar:5.2.0]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
2022-12-07 13:13:48.623+0000 ERROR [neo4j/cdae02f5] failed to start service uuid
java.util.NoSuchElementException: Key 'apoc.uuid.enabled' does not map to an existing object!
	at org.apache.commons.configuration2.AbstractConfiguration.throwMissingPropertyException(AbstractConfiguration.java:1531) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at org.apache.commons.configuration2.AbstractConfiguration.checkNonNullValue(AbstractConfiguration.java:1520) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at org.apache.commons.configuration2.AbstractConfiguration.getBoolean(AbstractConfiguration.java:940) ~[commons-configuration2-2.8.0.jar:2.8.0]
	at apoc.ApocConfig.getBoolean(ApocConfig.java:287) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.uuid.UuidHandler.isEnabled(UuidHandler.java:70) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.uuid.UuidHandler.start(UuidHandler.java:62) ~[apoc-5.2.0-extended.jar:5.2.0]
	at apoc.ApocExtensionFactory$ApocLifecycle.lambda$start$2(ApocExtensionFactory.java:107) ~[apoc-5.2.0-extended.jar:5.2.0]
	at java.util.HashMap.forEach(HashMap.java:1420) ~[?:?]
@Nordalf
Copy link

Nordalf commented Dec 7, 2022

@jexp - We got this exact problem and have been trying the whole week to figure this out. Still no luck to bypass the error

How do we get pass this for now? We can get the cluster up and running but the error messages are misleading 👍

Note: also occurs for the config apoc.ttl.enabled

@jexp
Copy link
Member Author

jexp commented Dec 7, 2022

@conker84 this should hopefully address it.

diff --git a/extended/src/main/java/apoc/TTLConfig.java b/extended/src/main/java/apoc/TTLConfig.java
index 71f6ee8e4..f3c34790a 100644
--- a/extended/src/main/java/apoc/TTLConfig.java
+++ b/extended/src/main/java/apoc/TTLConfig.java
@@ -23,7 +23,7 @@ public class TTLConfig extends LifecycleAdapter {
         String apocTTLEnabledDb = String.format(ExtendedApocConfig.APOC_TTL_ENABLED_DB, db.databaseName());
         String apocTTLScheduleDb = String.format(ExtendedApocConfig.APOC_TTL_SCHEDULE_DB, db.databaseName());
         String apocTTLLimitDb = String.format(ExtendedApocConfig.APOC_TTL_LIMIT_DB, db.databaseName());
-        boolean enabled = apocConfig.getBoolean(ExtendedApocConfig.APOC_TTL_ENABLED);
+        boolean enabled = apocConfig.getBoolean(ExtendedApocConfig.APOC_TTL_ENABLED, false);
         boolean dbEnabled = apocConfig.getBoolean(apocTTLEnabledDb, enabled);
 
         if (dbEnabled) {
diff --git a/extended/src/main/java/apoc/uuid/UuidHandler.java b/extended/src/main/java/apoc/uuid/UuidHandler.java
index 91c590e4f..fbf8af4b1 100644
--- a/extended/src/main/java/apoc/uuid/UuidHandler.java
+++ b/extended/src/main/java/apoc/uuid/UuidHandler.java
@@ -67,7 +67,8 @@ public class UuidHandler extends LifecycleAdapter implements TransactionEventLis
 
     private boolean isEnabled() {
         String apocUUIDEnabledDb = String.format(APOC_UUID_ENABLED_DB, this.db.databaseName());
-        return apocConfig.getConfig().getBoolean(apocUUIDEnabledDb, apocConfig.getBoolean(APOC_UUID_ENABLED));
+        boolean enabled = apocConfig.getBoolean(APOC_UUID_ENABLED, false);
+        return apocConfig.getConfig().getBoolean(apocUUIDEnabledDb, enabled);
     }

@cramatt
Copy link

cramatt commented Dec 8, 2022

Had to set both these values to avoid errors on startup:

apoc.ttl.enabled=false
apoc.uuid.enabled=false

@RedFour
Copy link

RedFour commented Dec 14, 2022

Had to set both these values to avoid errors on startup:

apoc.ttl.enabled=false
apoc.uuid.enabled=false

@cramatt Where do I set these values? neo4j.conf?

I see in your other post #3359, you have it in a separate apoc.conf file.

Are you able to get any apoc functions working? I have a similar docker setup.

When I run RETURN apoc.version() AS output;

I get the error

Unknown function 'apoc.version' (line 1, column 8 (offset: 7))
"RETURN apoc.version() AS output;"

@cramatt
Copy link

cramatt commented Dec 15, 2022

@RedFour yes I have two config files in the config directory:

neo4j.conf
apoc.conf

I think this might be a change in 5.x where there are 2 different files. In the past I recall configuring things in a single files. I'm also not sure in the docs where I discovered this.

Also I did notice apoc.version() is NOT in both core and extended... I guess to the thread #3359 this is only in core.

I'm wondering if they should consider namespacing Core vs. Extended functions to clear some of this up.

@cramatt
Copy link

cramatt commented Dec 15, 2022

I was able to get it running via docker following this

# docker-compose.yml
version: '3.3'
services:
  neo4j:
    image: neo4j:5.2.0
    ports:
      - "7474:7474" # neo4j browser
      - "7687:7687" # neo4j bolt
    volumes:
        - ./docker-volumes/neo4j/plugins-core:/plugins
        - ./docker-volumes/neo4j/data:/data
        - ./docker-volumes/neo4j/import:/import
        - ./docker-volumes/neo4j/conf:/conf
        - ./docker-volumes/neo4j/logs:/logs
    environment:
      - NEO4J_AUTH=neo4j/password

image

# apoc.conf
apoc.import.file.enabled=true
apoc.ttl.enabled=false
apoc.uuid.enabled=false
# neo4j.conf
dbms.security.procedures.unrestricted=apoc.*,algo.*
dbms.security.procedures.allowlist=apoc.*,algo.*

db.tx_log.rotation.retention_policy=100M size

server.memory.heap.initial_size=4GB
server.memory.heap.max_size=4GB
server.memory.pagecache.size=512M
server.directories.plugins=/plugins
server.directories.logs=/logs
server.directories.import=/import

image

Notice I'm just loading APOC Core in my docker-compose file. The docs suggest you DON'T need to download this but I found it only worked if I did download and map to volume like shown above.

@RedFour
Copy link

RedFour commented Dec 15, 2022

Thanks, I'm able to get my apocs to work with your apoc core link in the other thread.

@ebarault
Copy link

ebarault commented Oct 11, 2023

In reply to this comment in #3358 (comment):

The docs suggest you DON'T need to download this but I found it only worked if I did download and map to volume like shown above.

In fact, the doc is incomplete, but based on your findings, I tried installing automatically the core plugin with the following env var and it works:
NEO4J_PLUGINS: "[\"apoc-extended\",\"apoc\"]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants