Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI error while executing client

 
arun venkatesh
Greenhorn
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).
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
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic