Access EJB via HTTP in JBoss AS

If you are trying to acccess EJB through HTTP, you need to use org.jboss.naming.HttpNamingContextFactory for your context factory. However, there is only one small twitch in using that. You need to specify credentials accessing that invoker. This is what you need to add: env.put(Context.SECURITY_PRINCIPAL, “admin”);env.put(Context.SECURITY_CREDENTIALS, “admin”); This is complete code: Hashtable env = new Hashtable();env.put(Context.INITIAL_CONTEXT_FACTORY,”org.jboss.naming.HttpNamingContextFactory”);env.put(Context.PROVIDER_URL,…


The application component environment is referred to as the ENC, the enterprise naming context. It is the responsibility of the application component container to make an ENC available to the container components in the form of JNDI Context. // Obtain the application component’s ENCContext iniCtx = new InitialContext();Context compEnv = (Context) iniCtx.lookup(“java:comp/env”);


If you have used JNDI lookup in your services, JSPs or servlets, it was as easy as looking it up using some code like this: InitialContext ctx;ctx = new InitialContext();MyBean hello = (MyBean) ctx.lookup(“MyBean”); However, if you want to use this code in a POJO style, you won’t be successful, looking up that JNDI. In…