Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InaccessibleObjectException error with Java 16 #1099

Closed
pioneerAlone opened this issue Sep 27, 2021 · 10 comments
Closed

InaccessibleObjectException error with Java 16 #1099

pioneerAlone opened this issue Sep 27, 2021 · 10 comments
Labels
question Any question about leshan

Comments

@pioneerAlone
Copy link

I just want to run leshan-client-demo on localhost, but leshan server report below error:

mode: factory mode ,no psk ,no bs , default port: 5683

image

image

@sbernard31 sbernard31 added the question Any question about leshan label Sep 27, 2021
@sbernard31
Copy link
Contributor

Which version are you using ? (do you download jar somewhere or you build it locally from source ?)

I need that to try to reproduce the issue.

@pioneerAlone
Copy link
Author

Hi,
I am using the following version of the jar test. Basically, I will report this problem every time in the local area network. In addition, the problem will also be reported through the mapped public network, but the connection to the Leshan public server is normal, which is very strange. I have checked it. The port used is not occupied.

Any suggestions would be greatly appreciated.

image

@sbernard31
Copy link
Contributor

Just tested locally with those jars and it works for me.

I try to search about this error :

InaccessibleObjectException: Unable to make private java.util.Collections$EmptyMap accessible:
 module java.base does not "opens java.util' to unamed module

(Please when you share text, do not use image ... there are no benefits at all : larger, unable to copy/paste, not indexed)

This seems to be an issue between GSON and java 16 : google/gson#1875
It is not fixed for now but there is a workaround, see : google/gson#1875 (comment)

The problem seems to come from Gson. We use it only for demo and we plan to remove it at short/mid term (see #1045)

Which java version are you using, I guess java 16 ?
You can use java -version or java -jar leshan-client-demo.jar -V to know that.

On my side I tested with :

JVM: 1.8.0_212 (Oracle Corporation OpenJDK 64-Bit Server VM 25.212-b03)
OS: Linux 5.10.0-8-amd64 amd64

and

JVM: 11.0.12 (Debian OpenJDK 64-Bit Server VM 11.0.12+7-post-Debian-2)
OS: Linux 5.10.0-8-amd64 amd64

and

JVM: 15.0.2 (AdoptOpenJDK OpenJDK 64-Bit Server VM 15.0.2+7)
OS: Linux 5.10.0-8-amd64 amd64

All works for me. (even if with JVM 15 I get a warning)

I didn't check with JVM 16, I haven't this version installed on my machine.

@pioneerAlone
Copy link
Author

java version "16.0.2" 2021-07-20 Java(TM) SE Runtime Environment (build 16.0.2+7-67) Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

Thanks for your investigation
Yes, I am using java version --16.0.2, I will replace it and do some verification. thanks

@sbernard31
Copy link
Contributor

Following the google/gson#1875 (comment) you should be able to launch it with java 16 but you need to pass some args to the JVM at launch.

@pioneerAlone
Copy link
Author

Got it, I will try it. thanks!

@sbernard31 sbernard31 changed the title client-demo run fail with master 2.0 version InaccessibleObjectException error with Java 16 Sep 28, 2021
@pioneerAlone
Copy link
Author

good ,the issue has resolved. Thanks

java --add-opens java.base/java.util=ALL-UNNAMED -jar leshan-server-demo.jar -lp 5959 -slp 5685 -wp 5059

@sbernard31
Copy link
Contributor

With recently remove gson dependency from master (commit 3d2b1f9) , so this should not be an issue anymore.

@wahidKhan74
Copy link

Hi All , I am facing the same issue InaccessibleObjectException: Unable to make protected final java.lang.Class

while running the application against OpenJDK 16 I tried possible solutions such as

added following plugins to my code.

                      <plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>2.19.1</version>
			<configuration>
				<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
			</configuration>
		</plugin>

		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-failsafe-plugin</artifactId>
			<configuration>
				<systemPropertyVariables />
				<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
			</configuration>
		</plugin>

		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>exec-maven-plugin</artifactId>
			<version>1.2.1</version>
			<configuration>
				<mainClass>org.test.int1.Main</mainClass>
				<arguments>
					<argument>--add-opens java.base/java.lang=ALL-UNNAMED</argument>
				</arguments>
			</configuration>
		</plugin>

Please let me know if I am missing something.

@sbernard31
Copy link
Contributor

This should not happened anymore with master. (as we remove gson dependency)

This should affect demos only.

I look at your pom.xml code and I'm not sure to see how this is relative to Leshan ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Any question about leshan
Projects
None yet
Development

No branches or pull requests

3 participants