aspose file tools*
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
Author

JNDI error while executing client

arun venkatesh
Greenhorn

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

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(
"/com/cognizant/radbeta/sessionbean/HelloWorld");
HelloWorldHome h = (HelloWorldHome) PortableRemoteObject.narrow(o,
HelloWorldHome.class);
HelloWorld hello = (HelloWorld) h.create();
System.out.println(hello.sayHello("arun"));

hello.remove();
} catch (Exception e) {
e.printStackTrace();
}
}
}



ERROR

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

Joined: Sep 03, 2004
Posts: 127
Arun,

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: http://aspose.com/file-tools
 
subject: JNDI error while executing client