• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI error while executing client

arun venkatesh
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.cognizant.radbeta.client.Teclio.main(Teclio.java:15)

what is the reason for the error?
[ January 18, 2008: Message edited by: arun venkatesh ]
Henrique Ordine
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic