Neo4j Docker: Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)"

Viewed 281

I'm starting neo4j from Docker. What worked for months, no longer works. Coincidently I had storage issues with my Macbook pro, so I did some cleaning. Not too sure of the sequence of events what I did, however I am now getting this traceback:

Starting Neo4j.
2021-05-24 06:07:19.740+0000 INFO  ======== Neo4j 3.5.28 ========
2021-05-24 06:07:19.763+0000 INFO  Starting...
2021-05-24 06:07:39.645+0000 ERROR Failed to start Neo4j: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@394e0104' was successfully initialized, but failed to start. Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)". Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@394e0104' was successfully initialized, but failed to start. Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)".
org.neo4j.server.ServerStartupException: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@394e0104' was successfully initialized, but failed to start. Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)".
    at org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:45)
    at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:187)
    at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:124)
    at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:91)
    at org.neo4j.server.CommunityEntryPoint.main(CommunityEntryPoint.java:32)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.server.database.LifecycleManagingDatabase@394e0104' was successfully initialized, but failed to start. Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)".
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
    at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:180)
    ... 3 more
Caused by: java.lang.RuntimeException: Error starting org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory, /data/databases
    at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:232)
    at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:148)
    at org.neo4j.server.database.CommunityGraphFactory.newGraphDatabase(CommunityGraphFactory.java:41)
    at org.neo4j.server.database.LifecycleManagingDatabase.start(LifecycleManagingDatabase.java:90)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
    ... 5 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.bolt.BoltServer@7def08fc' was successfully initialized, but failed to start. Please see the attached cause exception "/var/lib/neo4j/certificates/neo4j.cert (No such file or directory)".
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
    at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:227)
    ... 9 more
Caused by: java.lang.RuntimeException: Failed to initialize SSL encryption support, which is required to start this connector. Error was: Failed to generate private key and certificate
    at org.neo4j.bolt.BoltServer.createSslContext(BoltServer.java:207)
    at org.neo4j.bolt.BoltServer.createProtocolInitializer(BoltServer.java:170)
    at org.neo4j.bolt.BoltServer.lambda$createConnectors$0(BoltServer.java:149)
    at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1321)
    at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
    at org.neo4j.bolt.BoltServer.createConnectors(BoltServer.java:149)
    at org.neo4j.bolt.BoltServer.start(BoltServer.java:124)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
    ... 11 more
Caused by: java.lang.RuntimeException: Failed to generate private key and certificate
    at org.neo4j.kernel.configuration.ssl.SslPolicyLoader.loadOrCreateLegacyPolicy(SslPolicyLoader.java:158)
    at org.neo4j.kernel.configuration.ssl.SslPolicyLoader.getOrCreateLegacyPolicy(SslPolicyLoader.java:139)
    at org.neo4j.kernel.configuration.ssl.SslPolicyLoader.getPolicy(SslPolicyLoader.java:120)
    at org.neo4j.bolt.BoltServer.createSslContext(BoltServer.java:202)
    ... 24 more
Caused by: java.io.FileNotFoundException: /var/lib/neo4j/certificates/neo4j.cert (No such file or directory)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at org.neo4j.ssl.PkiUtils.writePem(PkiUtils.java:233)
    at org.neo4j.ssl.PkiUtils.createSelfSignedCertificate(PkiUtils.java:120)
    at org.neo4j.kernel.configuration.ssl.SslPolicyLoader.loadOrCreateLegacyPolicy(SslPolicyLoader.java:154)
    ... 27 more
2021-05-24 06:07:39.663+0000 INFO  Neo4j Server shutdown initiated by request

How can I fix this?

1 Answers

This happens when you have not fix version of your docker image.

If you have somethin like that:

docker run \
    --name testneo4j \
    -p7474:7474 -p7687:7687 \
    -d \
    -v $HOME/neo4j/data:/data \
    -v $HOME/neo4j/logs:/logs \
    -v $HOME/neo4j/import:/var/lib/neo4j/import \
    -v $HOME/neo4j/plugins:/plugins \
    --env NEO4J_AUTH=neo4j/test \
    neo4j:latest

The issue is coming from the latest you should choose a specific version and stick to it otherwise every time there is a major update you could end up with this kind of issue. You can go to docker hub and select the version you use when you first download your image.

It only probably appears today because you cleanup your computer et remove your NEO4J image and when you run the image again it download the latest which is different than the one you use the first you download your initial image.

Related