neo4j / neo4j

Graphs for Everyone
http://neo4j.com
GNU General Public License v3.0
13.33k stars 2.38k forks source link

Impossible to start neo4j server with java 21 #13499

Open LaurentT opened 3 months ago

LaurentT commented 3 months ago

Hello,

I am getting the following stacktrace when trying to start neo4j community edition version 5.19.0

Neo4j Version: 5.19.0 Operating System: Debian bullseye API: Java 21.0.3

When starting neo4j server I'm getting the following error thrown by jersey-server v2.34 dependency:

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65                                                                                                                             
        at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:196) ~[jersey-server-2.34.jar:?]   

It is stated that java 21 is supported since Neo4j 5.14 but I also see that java 21 is supported since Jersey 2.40 https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/modules-and-dependencies.html

Is there a specific thing to make neo4j run under java 21?

Expected behavior

Neo4j is starting correctly

Actual behavior

2024-07-29 16:11:54.528+0000 ERROR [o.n.g.f.DatabaseManagementServiceFactory] Error starting Neo4j database server at /data/databases                                                                              
org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.server.CommunityNeoWebServer@1382a7d8' was successfully initialized, but failed to start. Please see the attached cause exception "Unsupported 
class file major version 65".                                                                                                                                                                                      
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:364) ~[neo4j-common-5.19.0.jar:5.19.0]                                                                                  
        at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.19.0.jar:5.19.0]                                                                                                     
        at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:269) [neo4j-5.19.0.jar:5.19.0]                                                      
        at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.build(DatabaseManagementServiceFactory.java:213) [neo4j-5.19.0.jar:5.19.0]                                                                    
        at org.neo4j.server.CommunityBootstrapper.createNeo(CommunityBootstrapper.java:38) [neo4j-5.19.0.jar:5.19.0]                                                                                               
        at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:184) [neo4j-5.19.0.jar:5.19.0]                                                                                                              
        at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:99) [neo4j-5.19.0.jar:5.19.0]                                                                                                               
        at org.neo4j.server.CommunityEntryPoint.main(CommunityEntryPoint.java:30) [neo4j-5.19.0.jar:5.19.0]                                                                                                        
Caused by: org.neo4j.server.ServerStartupException: Starting Neo4j failed: Unsupported class file major version 65                                                                                                 
        at org.neo4j.server.AbstractNeoWebServer.start(AbstractNeoWebServer.java:228) ~[neo4j-server-5.19.0.jar:5.19.0]                                                                                            
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:347) ~[neo4j-common-5.19.0.jar:5.19.0]                                                                                  
        ... 7 more                                                                                                                                                                                                 
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65                                                                                                                             
        at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:196) ~[jersey-server-2.34.jar:?]                                                                                                
        at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:177) ~[jersey-server-2.34.jar:?]                                                                                                
        at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:163) ~[jersey-server-2.34.jar:?]                                                                                                
        at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener$ClassReaderWrapper.accept(AnnotationAcceptingListener.java:321) ~[jersey-server-2.34.jar:?]                                   
        at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener$ClassReaderWrapper.access$200(AnnotationAcceptingListener.java:304) ~[jersey-server-2.34.jar:?]                               
        at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener.process(AnnotationAcceptingListener.java:151) ~[jersey-server-2.34.jar:?]                                                     
        at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:919) ~[jersey-server-2.34.jar:?]                                                                                             
        at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:863) ~[jersey-server-2.34.jar:?]                                                                                             
        at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:772) ~[jersey-server-2.34.jar:?]                                                                                              
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1213) ~[jersey-server-2.34.jar:?]                                                                                   
        at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1186) ~[jersey-server-2.34.jar:?]                                                                                   
        at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1182) ~[jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.ApplicationHandler$RuntimeConfigConfigurator.init(ApplicationHandler.java:182) ~[jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$0(ApplicationHandler.java:290) ~[jersey-server-2.34.jar:?]
        at java.util.Arrays$ArrayList.forEach(Arrays.java:4305) ~[?:?]                                                                                                                                             
        at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:290) ~[jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:259) ~[jersey-server-2.34.jar:?]
        at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) ~[jersey-container-servlet-core-2.34.jar:?]
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:154) ~[jersey-container-servlet-core-2.34.jar:?]
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:347) ~[jersey-container-servlet-core-2.34.jar:?]
        at javax.servlet.GenericServlet.init(GenericServlet.java:180) ~[jetty-servlet-api-4.0.6.jar:?]                                                                                                             
        at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:633) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:415) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$2(ServletHandler.java:725) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[?:?]                                                                                                                           
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[?:?]                                                                                                                            
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]                                                                                                                     
        at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310) ~[?:?]
        at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?]                                                                                                                    
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]                                                                                                                      
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:749) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:901) ~[jetty-server-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306) ~[jetty-servlet-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[jetty-util-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171) ~[jetty-util-10.0.20.jar:10.0.20]
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121) ~[jetty-util-10.0.20.jar:10.0.20]

Thanks

MishaDemianenko commented 3 months ago

Hi @LaurentT

Thank you for reaching out and reporting!

Neo4j 5.x should support JDK 21 as a runtime environment out-of-the-box, but only as a runtime. We still have the compilation target version set to 17 for various reasons.

And, exception message Unsupported class file major version 65 that AnnotationAcceptingListener from jetty found some class that was compiled with 21 as a target version. Is that so? And if that's the case that will need to be changed to 17 unfortunately.

baptistelebail commented 3 months ago

Hi @MishaDemianenko,

Colleague of OP here. Indeed we had our custom neo4j extension with a compile and target version as java 21. We did set the compile and target version to java 17 and it works fine now. So that was our code the culprit.

Thank you for your answer. (this issue can be closed, or OP will close it when he gets back from his holidays).

MishaDemianenko commented 3 months ago

Hi @baptistelebail

Thanks a lot for coming back to us with an update! It's good to hear that you were able to identify the problem and make progress.

Just in case, I will try to upgrade the used jersey as well, so some future 5.x should come with a more recent version. However, unfortunately, I can't say when exactly it will be released.