1 Reply Latest reply on May 19, 2005 5:15 AM by deepc

    Access EJBs via Applet

    peterweik

      Hello,

      I have created one Session Bean with the Busines Logic and a Remote interface and three CMP - EntityBeans which are used by the SessionBean. Everything (Creating, Updating, EJB-QL..)works fine with a servlet or a normal Java Client. Now I have written an applet and the following error occurs:
      "access denied (java.lang.RuntimePermission org.jboss.security.SecurityAssociation.getPrincipalInfo)..."


      The Web Container is Tomcat 5.5, I have Created a Subdirectory which is called "applets", inside this dir are (hopefully)all the needed classes (the EJB Classes and Interfaces, the unpacked Jbossall-client.jar and a Class which is used by the applet class. The important Code looks like this.

      public void initJNDI() throws
      NamingException,RemoteException,CreateException{
      try{
      System.out.println("In initJNDI");
      java.util.Properties p = new java.util.Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL,
      "odyseus:1099");
      //p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      System.out.println("In initJNDI vor InitialContext(p)");
      Context ctx = new InitialContext(p);
      System.out.println("In initJNDI vor lookUp()");
      Object o = ctx.lookup("PMBusinessLogicHomeRemote");
      System.out.println("In initJNDI nach lookUp()");
      PMBusinessLogicHomeRemote home = (PMBusinessLogicHomeRemote)PortableRemoteObject.narrow(o, PMBusinessLogicHomeRemote.class);
      System.out.println("In initJNDI nach PMBusinessLogicHomeRemote home =..");//This output is show in the java console
      pmBusinessLogic = home.create();
      }catch(Exception e){
      System.out.println("Fehler: " + e.getMessage());
      }
      }

      This is the whole output in the console:
      In initJNDI
      In initJNDI vor InitialContext(p)
      In initJNDI vor lookUp()
      In initJNDI nach lookUp()
      In initJNDI nach PMBusinessLogicHomeRemote home =..
      Fehler: access denied (java.lang.RuntimePermission org.jboss.security.SecurityAssociation.getPrincipalInfo)
      null

      If I run this in teh appletviewer, then there is no problem.

      I would appreciate help very much.

      Thanks,
      Peter