module java.base does not "opens java.lang" error in buildService using Java 21
Written By
Cristina Rodriguez
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- The following exception is thrown when trying to build a service with Service Builder:
Failed to initialize ClearThreadLocalUtil
java.lang.ExceptionInInitializerError
at com.liferay.petra.reflect.ReflectionUtil.<clinit>(ReflectionUtil.java:160)
at com.liferay.portal.kernel.util.ClearThreadLocalUtil.<clinit>(ClearThreadLocalUtil.java:149)
at com.liferay.portal.tools.service.builder.ServiceBuilder.main(ServiceBuilder.java:367)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @282f3878
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:197)
at com.liferay.petra.reflect.ReflectionUtil.<clinit>(ReflectionUtil.java:153)
... 2 more
Resolution
- This is solved in version 11.0.2 of workspace. So updating your settings.gradle with this value, the exception should be gone and the classes generated:
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "11.0.2"
}
Did this article resolve your issue ?