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

A small EJB problem in the NamingContextFactory

 
Narendran Nair
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Every one

I started to use JBoss from last week onwards and i was successful enough to deploy my first Session Bean in the JBoss4 Server with out any errors. But when i tried to write the client application, i was not successful as the deployment. the file compiles correctly withone any warnings and errors but when i try to run the application it gives a small error.

First let me tell abt the bean i wrote . it is a small bean that returns a string value and it is similar to the normal HelloWorld applications. The deployed jar has got the 3 needed class files and the ejb-jar.xml file.

The client program compiles fine and here it is ....

--------------------------------------------------------------
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;

public class HelloWorldClient {
public static void main(String args[]){
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"localhost:1099");
//env.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
env.put("java.naming.factory.url.pkgs","org.jboss.naming");
try{
Context ctx = new InitialContext(env);
Object obj = ctx.lookup("HelloWorld");
HelloWorldHome home = (HelloWorldHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloWorldHome.class);
HelloWorld helloWorld = home.create();
System.out.println(helloWorld.hello());
helloWorld.remove();
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}
-------------------------------------------------------------------

when i tried to run the above program it gives this message and exits

Cannot instantiate class: org.jnp.interfaces.NamingContextFactory

Can any one help me in this ...
i am using Jboss4 and J2SE1.4

thanking you in advance..

Regards
Narendran
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic