1 Reply Latest reply on Feb 24, 2004 5:55 AM by Adrian Brock

    java.security.AccessControlException

    hdeng Newbie

      Hi,
      I tried to migrate our app from Weblogic to JBOSS. There is a part where we bind our RMI server to JNDI inside weblogic as the server starts up.
      In JBOSS, I got following error (see the detail below):
      java.security.AccessControlException: access denied

      We set securitymanager as System.setSecurityManager(new RMISecurityManager());

      It failed to bind, but works in weblogic. Any idea?

      BTW, If take out the setSecuirtymanager line, it works fine.

      -Hui


      public class Test {

      public static void main(String[] args) {
      Test t = new Test();

      try{
      if(System.getSecurityManager() == null) System.setSecurityManager(new RMISecurityManager());
      InitialContext ctx = t.getInitialContext();
      ctx.bind("blah", new String("hello"));

      System.out.println(ctx.lookup("blah"));
      }catch(Exception e){
      e.printStackTrace();
      }

      }

      public InitialContext getInitialContext() {
      String meth = "getInitialContext";

      InitialContext ctx = null;


      Properties p = new Properties();
      p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.setProperty(Context.PROVIDER_URL, "localhost");
      //p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      //p.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      //p.setProperty("java.naming.provider.url", "localhost");


      try {
      if(p.isEmpty())
      ctx = new InitialContext();
      else
      ctx = new InitialContext(p);
      }
      catch(Exception e) {

      e.printStackTrace();
      }

      return ctx;
      }// getInitialContext()
      }




      java.security.AccessControlException: access denied (java.net.SocketPermission 230.0.0.4 connect,accept,resolve)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
      at java.security.AccessController.checkPermission(AccessController.java:401)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
      at java.lang.SecurityManager.checkMulticast(SecurityManager.java:1198)
      at java.net.MulticastSocket.joinGroup(MulticastSocket.java:267)
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1069)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1192)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:466)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:459)
      at javax.naming.InitialContext.bind(InitialContext.java:355)
      at com.bechtel.epcjobs.common.util.Test.main(Test.java:27)