jQAssistant / Idea-Hub

Hub to propose and discuss new ideas, features, as well as general issues
0 stars 0 forks source link

CLI cannot run with Java 16 #20

Closed lostiniceland closed 1 year ago

lostiniceland commented 3 years ago

When trying to run jqassistant cli with Java 16 I get the following error

Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@2b916808' was successfully initialized, but failed to start. Please see the attached cause exception "class org.neo4j.io.pagecache.impl.SingleFilePageSwapper (in unnamed module @0x2a11e646) cannot access class sun.nio.ch.FileChannelImpl (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x2a11e646".
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
        at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
        at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:116)
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
        at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
        at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:227)
        ... 18 more
Caused by: java.lang.IllegalAccessError: class org.neo4j.io.pagecache.impl.SingleFilePageSwapper (in unnamed module @0x2a11e646) cannot access class sun.nio.ch.FileChannelImpl (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x2a11e646
        at org.neo4j.io.pagecache.impl.SingleFilePageSwapper.getPositionLockGetter(SingleFilePageSwapper.java:100)
        at org.neo4j.io.pagecache.impl.SingleFilePageSwapper.<clinit>(SingleFilePageSwapper.java:87)
        at org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory.createPageSwapper(SingleFilePageSwapperFactory.java:66)
        at org.neo4j.io.pagecache.impl.muninn.MuninnPagedFile.<init>(MuninnPagedFile.java:149)
        at org.neo4j.io.pagecache.impl.muninn.MuninnPageCache.map(MuninnPageCache.java:412)
        at org.neo4j.kernel.impl.store.MetaDataStore.getRecord(MetaDataStore.java:285)
        at org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForStore(RecordFormatSelector.java:150)
        at org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectNewestFormat(RecordFormatSelector.java:268)
        at org.neo4j.kernel.NeoStoreDataSource.selectStoreFormats(NeoStoreDataSource.java:488)
        at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:352)
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)

Solution: As a solution the script must add the following options to the java command --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED

lostiniceland commented 3 years ago

So the shell version should look like this (when running a newer Java) java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED $JQASSISTANT_OPTS -jar "$JQASSISTANT_HOME/lib/com.buschmais.jqassistant.cli-jqassistant-commandline-neo4jv3-1.10.0.jar" "$@"

lostiniceland commented 3 years ago

I've faced the same issue in the maven-plugin. Adding the above add-opens to the JVM args solved it.

odrotbohm commented 3 years ago

Bitten by this as well. I see this in a Maven run on a JDK 16:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @16d431b4
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:357)
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:297)
    at java.lang.reflect.Field.checkCanSetAccessible (Field.java:177)
    at java.lang.reflect.Field.setAccessible (Field.java:171)
    at org.neo4j.helpers.Exceptions.<clinit> (Exceptions.java:413)
    at org.neo4j.kernel.NeoStoreDataSource.start (NeoStoreDataSource.java:433)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start (LifeSupport.java:452)
    at org.neo4j.kernel.lifecycle.LifeSupport.start (LifeSupport.java:111)
    at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start (DataSourceManager.java:116)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start (LifeSupport.java:452)
    at org.neo4j.kernel.lifecycle.LifeSupport.start (LifeSupport.java:111)
    at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade (GraphDatabaseFacadeFactory.java:227)
    at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.newFacade (GraphDatabaseFacadeFactory.java:148)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase (GraphDatabaseFactory.java:133)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase (GraphDatabaseFactory.java:122)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$EmbeddedDatabaseCreator.newDatabase (GraphDatabaseFactory.java:178)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase (GraphDatabaseBuilder.java:210)

Looks like this is ultimately caused by Neo4j trying to make Throwable.detailMessage accessible, which looks a bit adventurous in the first place.

StephanPirnbaum commented 1 year ago

This is indeed caused by Neo4j. With the migration to jQAssistant 2.0, comes Neo4j v4, where you'll see similar issues e.g. in JDK 17. This is also documented: https://jqassistant.github.io/jqassistant/doc/2.0.0/manual/