2 Replies Latest reply on Jan 14, 2005 5:15 AM by Bernd Zeitler

    enc ejb context from a java application

    peake Newbie

      When running a java application outside of the container (non servlet) I am having trouble looking up ejb's using the enc naming structure of:
      Object obj = ctx.lookup("java:comp/env/ejb/WorkplaceSessionBean");

      But, if I change it to:
      Object obj = ctx.lookup("ejb/WorkplaceSessionBean");
      it works.
      I do not have control over this though as I am supplied a jar.
      I have tried the following VM parameters to overcome but without success.
      Can someone shed some light?

      -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      -Djava.naming.provider.url=jnp://JBOSS_HOST:1099/
      -Djava.security.auth.login.config=login.conf

      with login.conf being:
      jboss_client {
      org.jboss.security.ClientLoginModule required;
      };

      It still does not seem to work.

      thanks-
      chris

        • 1. Re: enc ejb context from a java application
          peake Newbie

          The question is better stated as the following:
          1- how to ENC lookups from a remote container.

          • 2. Re: enc ejb context from a java application
            Bernd Zeitler Expert

            JBoss guide:

            An application component environment is a local environment that is accessible only by the component when the application server container thread of control is interacting with the application component. This means that an EJB Bean1 cannot access the ENC elements of EJB Bean2, and vice versa. Similarly, Web application Web1 cannot access the ENC elements of Web application Web2 or Bean1 or Bean2 for that matter. Also, arbitrary client code, whether it is executing inside of the application server VM or externally cannot access a component's java:comp JNDI context. The purpose of the ENC is to provide an isolated, read-only namespace that the application component can rely on regardless of the type of environment in which the component is deployed. The ENC must be isolated from other components because each component defines its own ENC content. Components A and B, for example, may define the same name to refer to different objects. For example, EJB Bean1 may define an environment entry java:comp/env/red to refer to the hexadecimal value for the RGB color for red, while Web application Web1 may bind the same name to the deployment environment language locale representation of red.

            http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch3.chapter.html