Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help me to run a client

 
Jasmine kaur
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody ,
Iam facing this problem to run a client with JBoss4.0 , this is my client code and In the classpath I have put the following jar files :
a)jboss-client.jar
b)jnp-client.jar
c)jbosssx-client.jar
d)jndi.properties
if any other file is requierd please tell me or something is wrong in the classpath or in code so please do tell me.

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

public class MathClient
{
public static void main(String h[])
{
try{
System.out.println("Iam in the client");
Properties prop=new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
prop.put(Context.PROVIDER_URL,"jnp://127.0.0.1:1099");
Context context=new InitialContext(prop);
Object object=context.lookup("abhi");
MathHome home=(MathHome)PortableRemoteObject.narrow(object,MathHome.class);
MathRemote remote=home.create();
System.out.println("My addition value is:"+remote.add(20,20));
}
catch(NamingException e){
e.printStackTrace();
}
catch(Exception f){
System.out.println(f.getMessage());
}
}
}


This exception is comming after running the program .

D:\ABHI\EJB\SESSION>java MathClient
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at MathClient.main(MathClient.java:16)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
... 4 more



Thanks in advance.
 
Heonkoo Lee
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add jbossall-client.jar to your classpath. This is only API you need to include to run your client.
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use jbossall-client.jar instead of all the other jars, you should have everything you need.
 
Jasmine kaur
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Thanks a lot for helping me , client is running .
Thanks a tonnne.
Thanks once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic