Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Client for Calling a Entity Bean  RSS feed

 
naveen babu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created a simple entity bean(Student) using jboss.
i have successfully deployed the files(Home,Remote,Bean,PrimaryKey).

Now i am trying to run the client.Now i got a exception

javax.Naming.NoInitialContextException : Cannot instantiate class : org.jnp.interfaces.NamingContextFactory [root exception is java.lang.ClassNotFoundException org.jnp.interfaces.NamingContextFactory

my client code is
------------------------------------------------------------
package student;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import java.util.*;

public class StudentClient
{
public static void main(String args[])
{
System.out.println("i am in start");
try{

Properties env = new Properties();
//env.setProperty("InitialContext.INITIAL_CONTEXT_FACTORY","org.jboss.naming");
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming");

InitialContext jndiContext = new InitialContext(env);
StudentHome home=(StudentHome)PortableRemoteObject.narrow(jndiContext.lookup("StudentHome"),StudentHome.class);

home.create("Ammamn","A01");

}catch(Exception e){System.out.println("error in client"+e);}

System.out.println("i am in end");
}

}

------------------------------------------------------------
pls clear me
1)what r the client jars i have to include in classpath.
2)Is there is any seperate xml file i have to write for client.
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to include JBOSS_HOME/server/(all,default,or whatever server type you are using)/lib/jnpserver.jar in the classpath.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!