Skip to content

Errors due to inaccessible modules (reflections?) #1753

Closed

Description

@gramian

ArcadeDB Version:

24.10.1 & 24.11.1

OS and JDK Version:

OpenJDK 17 (Ubuntu and MacOS)

Expected behavior

No error

Actual behavior

Couldn't disable close on interrupt
java.lang.reflect.InaccessibleObjectException: Unable to make field private sun.nio.ch.Interruptible java.nio.channels.spi.AbstractInterruptibleChannel.interruptor accessible: module java.base does not "opens java.nio.channels.spi" to unnamed module @1c72da34
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
	at com.arcadedb.engine.PaginatedComponentFile.doNotCloseOnInterrupt(PaginatedComponentFile.java:216)
	at com.arcadedb.engine.PaginatedComponentFile.open(PaginatedComponentFile.java:208)
	at com.arcadedb.engine.ComponentFile.<init>(ComponentFile.java:50)
	at com.arcadedb.engine.PaginatedComponentFile.<init>(PaginatedComponentFile.java:49)
	at com.arcadedb.engine.FileManager.getOrCreateFile(FileManager.java:188)
	at com.arcadedb.engine.PaginatedComponent.<init>(PaginatedComponent.java:57)
	at com.arcadedb.engine.PaginatedComponent.<init>(PaginatedComponent.java:47)
	at com.arcadedb.engine.PaginatedComponent.<init>(PaginatedComponent.java:42)
	at com.arcadedb.engine.Dictionary.<init>(Dictionary.java:61)
	at com.arcadedb.schema.LocalSchema.create(LocalSchema.java:138)
	at com.arcadedb.database.LocalDatabase.openInternal(LocalDatabase.java:1782)
	at com.arcadedb.database.LocalDatabase.create(LocalDatabase.java:207)
	at com.arcadedb.database.DatabaseFactory.create(DatabaseFactory.java:90)
	at com.arcadedb.console.Console.executeCreateDatabase(Console.java:444)
	at com.arcadedb.console.Console.execute(Console.java:257)
	at com.arcadedb.console.Console.parse(Console.java:742)
	at com.arcadedb.console.Console.interactiveMode(Console.java:131)
	at com.arcadedb.console.Console.execute(Console.java:185)
	at com.arcadedb.console.Console.main(Console.java:148)

Steps to reproduce

Using the console:

CREATE DATABASE test

or just start the server.

Fix

Add --add-opens java.base/java.nio.channels.spi=ALL-UNNAMED to the JAVA_OPTS environment variable to prevent this behavior. Maybe this option should be added to the console.sh and server.sh scripts.

Notably, this very option is already in the root pom.xml.

Activity

  1. changed the title [-]Errors[/-] [+]Errors due to inaccessible modules (reflections?)[/+] on Oct 14, 2024
  2. added this to the 24.11.1 milestone on Oct 14, 2024
  3. self-assigned this
    on Oct 14, 2024
  4. added 2 commits that reference this issue on Oct 14, 2024
  5. robfrank commented on Oct 14, 2024

    @robfrank
    Collaborator

    @gramian I merged the fix. Any test is welcome :)

  6. gramian commented on Oct 14, 2024

    @gramian
    CollaboratorAuthor

    @robfrank I tested console.sh and server.sh with #1754 and the error is not there anymore, so works for me. Thank you!

  7. vic0824 commented on Oct 24, 2024

    @vic0824

    If I build a custom run-time image with jlink, I still get a lot of instances of the exception, even after adding the --add-opens and --add-exports JVM args:

    2024-10-24 14:44:48.160 INFO  [ArcadeDBServer] <ArcadeDB_0> Starting ArcadeDB Server in development mode with plugins [Orchestrator] ...Couldn't disable close on interrupt
    java.lang.reflect.InaccessibleObjectException: Unable to make field private sun.nio.ch.Interruptible java.nio.channels.spi.AbstractInterruptibleChannel.interruptor accessible: module java.base does not "opens java.nio.channels.spi" to unnamed module @6771beb3
            at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
            at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
            at java.base/java.lang.reflect.Field.checkCanSetAccessible(Unknown Source)
            at java.base/java.lang.reflect.Field.setAccessible(Unknown Source)
            at com.arcadedb.engine.PaginatedComponentFile.doNotCloseOnInterrupt(PaginatedComponentFile.java:216)
            at com.arcadedb.engine.PaginatedComponentFile.open(PaginatedComponentFile.java:208)
            at com.arcadedb.engine.ComponentFile.<init>(ComponentFile.java:50)
            at com.arcadedb.engine.PaginatedComponentFile.<init>(PaginatedComponentFile.java:49)
            at com.arcadedb.engine.FileManager.<init>(FileManager.java:90)
            at com.arcadedb.database.LocalDatabase.openInternal(LocalDatabase.java:1772)
            at com.arcadedb.database.LocalDatabase.open(LocalDatabase.java:195)
            at com.arcadedb.database.DatabaseFactory.open(DatabaseFactory.java:78)
            at com.arcadedb.server.ArcadeDBServer.getDatabase(ArcadeDBServer.java:473)
            at com.arcadedb.server.ArcadeDBServer.getDatabase(ArcadeDBServer.java:327)
            at com.arcadedb.server.ArcadeDBServer.loadDatabases(ArcadeDBServer.java:498)
            at com.arcadedb.server.ArcadeDBServer.start(ArcadeDBServer.java:145)
    

    These are the options that I use:

    JAVA_OPTS="--add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS --add-exports=java.management/sun.management=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
    JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
    JAVA_OPTS="$JAVA_OPTS -Dpolyglot.engine.WarnInterpreterOnly=false"
    JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=config/arcadedb-log.properties"
    

    and this is the Maven plugin jlink configuration:

    <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.4.1</version>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <executable>C:\Users\VTORRONI\Java\amazon-corretto-17.0.12.7.1-windows-x64\bin\jlink</executable>
                        <arguments>
                            <argument>--module-path=/Users/VTORRONI/Java/amazon-corretto-17.0.12.7.1-linux-x64/jmods</argument>
                            <argument>--add-modules</argument>
                            <argument>
                                java.base,java.logging,java.management,java.naming,java.security.jgss,java.security.sasl,java.sql,java.xml,java.rmi,java.net.http,jdk.management,jdk.unsupported,jdk.crypto.ec
                            </argument>
                            <argument>--output</argument>
                            <argument>./jre</argument>
                            <argument>--strip-debug</argument>
                            <argument>--no-header-files</argument>
                            <argument>--no-man-pages</argument>
                            <argument>--compress=2</argument>
                        </arguments>
                    </configuration>
                </plugin>
    

    At the very end of the start-up sequence, I also get this bonus exception:

    Exception in thread "Thread-7" java.lang.IllegalAccessError: class com.arcadedb.server.monitor.ServerMonitor (in unnamed module @0x4d5d943d) cannot access class sun.management.ManagementFactoryHelper (in module java.management) because module 
    java.management does not export sun.management to unnamed module @0x4d5d943d
            at com.arcadedb.server.monitor.ServerMonitor.checkJVMHotSpot(ServerMonitor.java:107)
            at com.arcadedb.server.monitor.ServerMonitor.monitor(ServerMonitor.java:61)
            at com.arcadedb.server.monitor.ServerMonitor.lambda$start$0(ServerMonitor.java:52)
            at java.base/java.lang.Thread.run(Unknown Source)
    
  8. lvca commented on Oct 24, 2024

    @lvca
    Member

    Did you add

    --add-opens java.base/java.nio.channels.spi=ALL-UNNAMED
    
  9. vic0824 commented on Oct 25, 2024

    @vic0824

    Yes, these are my JVM options (I have copied the --add-opens and --add-exports directives from the latest version of https://github.com/ArcadeData/arcadedb/blob/main/package/src/main/scripts/server.sh):

    JAVA_OPTS="--add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS --add-exports=java.management/sun.management=ALL-UNNAMED"
    JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
    JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
    JAVA_OPTS="$JAVA_OPTS -Dpolyglot.engine.WarnInterpreterOnly=false"
    JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=config/arcadedb-log.properties"
    

    Just to clarify: in my project I use ArcadeDB in embedded mode, and I use jlink to create a custom run-time image of my project (with ArcadeDB modules as dependencies).

    If now Java 17 is the default for arcadedb, maybe it would be possible to use MethodHandles.Lookup as a replacement for the standard reflective access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions