Jaikiran Pai wrote:
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
Arnab,
You have to place a jndi.properties file in the classpath of the client application. The jndi.properties will contain the Context related information for the jndi lookup. For more details have a look at I get NoInitialContextException
Hi i gt it
but an error is still dre the following is the error
{
Exception in
thread "main" java.lang.NoClassDefFoundError: Ljavax/transaction/TransactionManager;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredField(Unknown Source)
at java.io.ObjectStreamClass.getDeclaredSUID(Unknown Source)
at java.io.ObjectStreamClass.access$700(Unknown Source)
at java.io.ObjectStreamClass$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(Unknown Source)
at java.io.ObjectStreamClass.lookup(Unknown Source)
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:80)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:80)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:157)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:655)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:590)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(AdviceClient.java:31)
at AdviceClient.main(AdviceClient.java:13)
}
my client looks like this
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.rmi.*;
import java.util.Properties;
import headfirst.*;
import javax.ejb.*;
public class AdviceClient {
public static void main(String args[]){
new AdviceClient().go();
}
public void go(){
try{
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces ");
properties.put("java.naming.provider.url",
"jnp://localhost:1099");
System.out.println("start");
Context ic = new InitialContext(properties);
System.out.println("exception in lookup");
Object o = ic.lookup("AdviceBean");
System.out.println("exception in portable remote object");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);
System.out.println("exception in home.create");
Advice advisor = home.create();
System.out.println((advisor.getAdvice()));
}
catch(Exception e){
e.printStackTrace();
System.out.println(e.getStackTrace());
}
}
}
I think dre is some problem at "Object o = ic.lookup("AdviceBean");" because sop's till dre are getting printed