Hi,
I set the properties but still getting some errors,
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory. Root exception is java.lang.ClassNotFoundException:
org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
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 test.Main.main(Main.java:37)
And I set the classpath for jboss-client.jar like
>set classpath=.;C:\jboss-3.0.8_tomcat-4.1.24\client\jboss-client.j
ar;%classpath%
and the jndi.properties in C:\jboss-3.0.8_tomcat-4.1.24\server\cinfig\conf
so i set the classpath for that also.
jndi.propeerties files looklike this,
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming
rg.jnp.interfaces
# Do NOT uncomment this line as it causes in VM calls to go over
# RMI!
#java.naming.provider.url=localhost
and The client code is,
package test;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.ejb.CreateException;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import javax.naming.*;
import test.TestRemote;
import test.TestHome;
public class Main
{
/** This method does all the work. It creates an instance of the Interest EJB on
the EJB server, and calls its `calculateCompoundInterest()' method, then prints
the result of the calculation.
*/
public static void main(String[] args)
{
try
{
// Get a naming context
/* InitialContext jndiContext = new InitialContext();
System.out.println("Got context");*/
Properties props = new Properties();
props.putContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingC
ontextFactory");
//props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming
rg.jnp.interfaces");
props.put(Context.PROVIDER_URL, "localhost:1099");
InitialContext context=new InitialContext(props);
// Get a reference to the Interest Bean
Object ref = context.lookup("First");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
TestHome home = (TestHome)
PortableRemoteObject.narrow(ref, TestHome.class);
// Create an Interest object from the Home interface
TestRemote call = home.create();
System.out.println("Process strat");
String msg = call.process();
System.out.println(msg);
System.out.println("Process end");
}
catch(java.rmi.RemoteException re)
{
re.printStackTrace();
}
catch(Throwable t)
{
t.printStackTrace();
}
}
}
Help would be so appriciate,
Thanks,
Sharief