javajakarta-eescope

Java method scope issue


I have two distinct archives within in the same .ear deployed on an application server. One is a .war and one is a .jar. I have the same package names in both archives

in .jar archive>> com.me.dummy.MyClass
in .war archive>> com.me.dummy.CLientClass

In com.me.dummy.MyClass I have a protected method called proctectedMethod() . In com.me.dummy.CLientClass i invoke com.me.dummy.MyClass.proctectedMethod().

This does not cause any compile time issues, but at runtime it throws accessError

java.lang.IllegalAccessError

Why does this only throw the IllegalAccessError at runtime?

Thanks


Solution

  • I believe that this happens because your application server loads web application using separate class loader. You should consult your app server documentation how to make it to use the same class loader for whole enterprise application.