java.lang.reflect.InaccessibleObjectException is thrown in standalone remote EJB client application with JDK17

Solution Verified - Updated -

Issue

A standalone EJB client application fails with the following exception:

$ java --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAME -cp jboss-client.jar:standalone-ejbclient.jar org.example.ejb.RemoteEjbClient
WARNING: Unknown module: ALL-UNNAME specified to --add-opens
Nov 18, 2022 2:02:45 PM org.wildfly.naming.client.Version <clinit>
INFO: WildFly Naming version 1.0.14.Final-redhat-00001
Nov 18, 2022 2:02:46 PM org.wildfly.security.Version <clinit>
INFO: ELY00001: WildFly Elytron version 1.15.5.Final-redhat-00001
Nov 18, 2022 2:02:46 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.8.4.Final-redhat-00001
Nov 18, 2022 2:02:46 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.4.Final-redhat-00001
Nov 18, 2022 2:02:46 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.4.0.Final-redhat-00001
Nov 18, 2022 2:02:46 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 5.0.23.SP1-redhat-00001
Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.reflect.Method jdk.proxy2.$Proxy2.m0 accessible: module jdk.proxy2 does not "opens jdk.proxy2" to unnamed module @4bb33f74
    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 org.jboss.ejb.client.EJBProxyInformation$1.doCompute(EJBProxyInformation.java:101)
    at org.jboss.ejb.client.EJBProxyInformation$1.computeValue(EJBProxyInformation.java:72)
    at org.jboss.ejb.client.EJBProxyInformation$1.computeValue(EJBProxyInformation.java:66)
    at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
    at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
    at java.base/java.lang.ClassValue.get(ClassValue.java:116)
    at org.jboss.ejb.client.EJBProxyInformation.forViewType(EJBProxyInformation.java:242)
    at org.jboss.ejb.client.EJBLocator.getProxyInformation(EJBLocator.java:375)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:115)
    at jdk.proxy2/jdk.proxy2.$Proxy2.echo(Unknown Source)
    at org.example.ejb.RemoteEjbClient.main(RemoteEjbClient.java:23)

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.4.0
    • 7.4.1
  • OpenJDK
    • 17

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content