Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-14668

InaccessibleObjectException on EJB proxy creation (JDK16)

    XMLWordPrintable

Details

    Description

      As soon as a deployment containing an EJB (in my case it is a @Remote interface) is deployed to the application server, I get the following exception:

      Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.reflect.Method jdk.proxy26.$Proxy153.m0 accessible: module jdk.proxy26 does not "opens jdk.proxy26" to unnamed module @652c95fd
      	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 org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBProxyInformation$1.doCompute(EJBProxyInformation.java:101)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBProxyInformation$1.computeValue(EJBProxyInformation.java:72)
      	at org.jboss.ejb-client@4.0.39.Final//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@4.0.39.Final//org.jboss.ejb.client.EJBProxyInformation.forViewType(EJBProxyInformation.java:242)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBLocator.getProxyInformation(EJBLocator.java:375)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBLocator.getProxyConstructor(EJBLocator.java:370)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBLocator.createProxyInstance(EJBLocator.java:387)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBClient.createProxy(EJBClient.java:161)
      	at org.jboss.ejb-client@4.0.39.Final//org.jboss.ejb.client.EJBClient.createProxy(EJBClient.java:156)
      	at org.jboss.as.ejb3@23.0.0.Final//org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory.createViewInstance(StatelessRemoteViewInstanceFactory.java:53)
      	at org.jboss.as.ee@23.0.0.Final//org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:184)
      	at org.jboss.as.ee@23.0.0.Final//org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:174)
      	at org.jboss.as.weld.ejb@23.0.0.Final//org.jboss.as.weld.services.bootstrap.WeldEjbInjectionServices$LazyResourceReferenceFactory.createResource(WeldEjbInjectionServices.java:290)
      

       

      Release notes of Java 16 lists the following change:

       

      Proxy Classes Are Not Open for Reflective Access (JDK-8159746)
      core-libs/java.lang:reflect
      
      All proxy classes are not open for reflective access in Java SE
      16.
      Prior to Java SE 16, if java.lang.reflect.Proxy was
      used to implement only public exported proxy interfaces, the proxy
      class was generated in an unnamed module which was open for
      reflective access. In Java SE 16, the proxy class is generated in
      an exported package in a named module. Programs that assume the
      private members of a proxy class can be made accessible via
      setAccessible(true) will fail with
      InaccessibleObjectException. Proxy classes are already
      defined in dynamic modules in other cases since Java SE 9. Such
      programs would already fail when it calls
      setAccessible(true) to those proxy classes prior to
      this change.
      

       

      I tried to debug that error, but as I'm pretty inexperienced related to Java modules, all I can say is:

      • The EJB Proxy class is generated in a dynamic module with a variable name (jdk.proxy*XXX*)
      • It is not possible to --add-opens to that dynamic module

       

      Attachments

        Issue Links

          Activity

            People

              cfang@redhat.com Cheng Fang
              ste_gr Stefan Gr (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: