0 Replies Latest reply on Nov 26, 2002 3:50 AM by ebox99

    IllegalAccessError with package private methods

    ebox99

      Hi all,

      I have a servlet that calls a class derived from JUnit Testcase which again calls class A and class B in the same package. The testclass, class A and class B are packaged in the same jar, the servlet is in a war-file and jar and war are together in an ear-file.
      When class A calls a package private method in class B I often get an IllegalAccessError but not always. Sometimes when I build and deploy the classes again it is ok.
      I found that when the error occurs class A and class B are loaded by different classloaders.
      Both classes are not referenced from any classes in the war-file.

      From what I read in the newsgroups this can occur when classes reside in different jars which is not the case.
      My questions:
      1. Why is this happening? I found the error only when accessing the classes via serlvet and Testcase which uses Reflection.
      2. Is there a way to prevent this? Can I tell JBoss to load all classes inside a jar with the same classloader?

      I am using JBoss 3.0.2 with jetty.

      Thanks for any help,

      Anna