1 Reply Latest reply on Sep 30, 2002 10:30 AM by adrian.brock

    java.lang.IllegalAccessError during new InitialContext probl

    arnt

      I have run into the following problem:
      In my code, which is executed from an MBean, I call:

      new InitialContext( props );

      Then I get an exception with a callstack that looks like this:

      java.lang.IllegalAccessError: try to access field org.jnp.interfaces.NamingParser.syntax from class org.jnp.interfaces.NamingContextFactory
      at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:37)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:660)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
      at javax.naming.InitialContext.init(InitialContext.java:217)
      at javax.naming.InitialContext.<init>(InitialContext.java:193)

      ...
      ...
      ...

      It seems to me that the follwing is happening :
      org.jnp.interfaces.NamingParser is loaded with one classloader. org.jnp.interfaces.NamingContextFactory isloaded with another classloder. NamingParser.syntax is a package scope member field. Java then 'thinks' that NamingContextFactory is not allowed to access NamingParser.syntax - even though the classes are in the same package - because the two classes is loaded with different classloaders.

      I urgently need to get around this problem !
      I have been considering to change the declaration for
      NamingParser.syntax to public and then recompile jboss, hovewer, it does not seem reasonable to assume I should have to do that.

      Have anyone experienced similar problems ?
      What should I do to get around it ?

      - arnt