question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.reflect.InaccessibleObjectException when starting application

See original GitHub issue

Spring Boot mongodb version: 2.5.3 flapdoodle version: 3.0.0 JDK 16

I noticed the following exception on application startup when running my unit tests with the embedded mongodb:

java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.lang.ProcessImpl.handle accessible: module java.base does not "opens java.lang" to unnamed module @71a794e5
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
	at de.flapdoodle.embed.process.runtime.Processes.windowsProcessId(Processes.java:114)
	at de.flapdoodle.embed.process.runtime.Processes.access$200(Processes.java:51)
	at de.flapdoodle.embed.process.runtime.Processes$PidHelper$3.getPid(Processes.java:215)
	at de.flapdoodle.embed.process.runtime.Processes.processId(Processes.java:82)
	at de.flapdoodle.embed.process.runtime.ProcessControl.<init>(ProcessControl.java:65)
	at de.flapdoodle.embed.process.runtime.ProcessControl.start(ProcessControl.java:165)
	at de.flapdoodle.embed.process.runtime.AbstractProcess.<init>(AbstractProcess.java:96)
	at de.flapdoodle.embed.mongo.AbstractMongoProcess.<init>(AbstractMongoProcess.java:53)
	at de.flapdoodle.embed.mongo.MongodProcess.<init>(MongodProcess.java:50)
	at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:44)
	at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:34)
	at de.flapdoodle.embed.process.runtime.Executable.start(Executable.java:109)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1912)
...

This exception does not seem to have any significant impact since the application continues to start and the tests run fine, but I am wondering where it comes from and how I can get rid of it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Saljackcommented, Oct 18, 2021

@thomaschampagne try this:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>
            --add-opens java.base/java.lang=ALL-UNNAMED
        </argLine>
    </configuration>
</plugin>
3reactions
thomaschampagnecommented, Oct 4, 2021

I’m experiencing the same exception using JDK 17 LTS

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot application startup exception: java.lang.reflect ...
Spring Boot application startup exception: java.lang.reflect.InaccessibleObjectException ... The reason for the error is that the JVM's java.base ...
Read more >
module {A} does not 'opens {package}' to {B}") on Java 9 ...
A library or framework uses reflection to call into a JDK module. ... java.base does not "opens java.lang" to unnamed module @1941a8ff.
Read more >
Build fails with JDK-16 RC2 (InaccessibleObjectException)
Internal error (java.lang.reflect.InaccessibleObjectException): Unable to make protected void java.util.ResourceBundle.setParent(java.util.
Read more >
Messages in the error logs
Jul 28 14:22:58 l<HOST> start-consul-ext.sh: java.lang.reflect.InaccessibleObjectException: Unable to make field private ...
Read more >
InaccessibleObjectException (Java SE 9 & JDK 9 )
java.lang.Exception · java.lang.RuntimeException. java.lang.reflect.InaccessibleObjectException. All Implemented Interfaces: Serializable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found