0 Replies Latest reply on Jun 4, 2012 7:51 AM by sumitsu

    IllegalAccessError on access (from EJB) to protected field of superclass (in EAR/lib)

    sumitsu

      I'm encountering an IllegalAccessError when an object of a class packaged in the EJB module of my EAR file tries to access a protected field of its superclass, packaged in the EAR/lib folder:

       

      javax.ejb.EJBException: Unexpected Error

      ...

      Caused by: java.lang.IllegalAccessError: tried to access field com.example.MessageFileLoader.config from class com.example.Subclass

              at com.example.Subclass.createFile(Subclass.java:46)

       

      This problem is similar to the one reported in this thread: https://community.jboss.org/message/729640, and also this JIRA case: https://issues.jboss.org/browse/AS7-3305, except that the superclass is in the EAR/lib, which (to my understanding) should be available to the EJB module; the Class Loading in AS7 document says: "subdeployments (wars and ejb-jars) always have a dependency on the parent module, which gives them access to classes in EAR/lib".

       

      I have some logging statements at the beginning of my SLSB invocation which confirm that the EJB and thread ClassLoaders are indeed distinct from the one used by the EAR/lib superclass:

       

      10:31:34,852 INFO  [com.example.Subclass] thread classloader = ModuleClassLoader for Module "deployment.EARFILE-12.6.0.ear.application-ejb-12.6.0.jar:main" from Service Module Loader

      10:31:34,853 INFO  [com.example.Subclass] this classloader = ModuleClassLoader for Module "deployment.EARFILE-12.6.0.ear.application-ejb-12.6.0.jar:main" from Service Module Loader

      10:31:34,854 INFO  [com.example.Subclass] MessageFileLoader classloader = ModuleClassLoader for Module "deployment.EARFILE-12.6.0.ear:main" from Service Module Loader

       

      I have tried:

       

      • setting <ear-subdeployments-isolated>false</ear-subdeployments-isolated> in jboss-deployment-structure.xml
      • making my EJB jar module a deployment resource-root in jboss-deployment-structure.xml

       

      ...both to no avail.

       

      Is there any way to force JBoss to use the same ClassLoader for the EJB and EAR/lib jars?  If not, does anyone have any other suggestions as to how to resolve this problem?