File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes JNDI error while executing client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI error while executing client" Watch "JNDI error while executing client" New topic

JNDI error while executing client

arun venkatesh

Joined: Jan 17, 2008
Posts: 1
i'm trying to execute my first EJB 2.1(older version only- for a migration project).

package com.cognizant.radbeta.client;

import com.cognizant.radbeta.sessionbean.HelloWorld;
import com.cognizant.radbeta.sessionbean.HelloWorldHome;

import javax.naming.InitialContext;

import javax.rmi.PortableRemoteObject;

public class Teclio {
public static void main(String[] args) throws Exception {
try {
InitialContext ic = new InitialContext();
Object o = ic.lookup(
HelloWorldHome h = (HelloWorldHome) PortableRemoteObject.narrow(o,
HelloWorld hello = (HelloWorld) h.create();

} catch (Exception e) {


javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(
at javax.naming.InitialContext.lookup(
at com.cognizant.radbeta.client.Teclio.main(

what is the reason for the error?
[ January 18, 2008: Message edited by: arun venkatesh ]
Henrique Ordine
Ranch Hand

Joined: Sep 03, 2004
Posts: 127

The InitialContext class has a constructor with a Properties argument, which you could use to pass the name of that missing class, which seems to be the name of the initial context factory.
For example, I'm using JBoss and these properties to get an InitialContext:

[ January 22, 2008: Message edited by: Henrique Ordine ]

J2EE Architect/Developer
I agree. Here's the link:
subject: JNDI error while executing client
It's not a secret anymore!