GeeCON Prague 2014*
The moose likes Websphere and the fly likes NoInitilaContextException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Websphere
Bookmark "NoInitilaContextException" Watch "NoInitilaContextException" New topic
Author

NoInitilaContextException

Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
Hi
When i run Client side program i get the following exception...How can i resolve this exception.and i attach the client side program also.pls help me ....
javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websph
ere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundE
xception: com.ibm.websphere.naming.WsnInitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
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:195)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:45)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.<init>(InitialContext.java:198)
at ConverterClient.main(ConverterClient.java:21)
-----------------------------
ConvertClient.java
import convert.*;
import javax.servlet.http.*;
import java.io.*;
import java.rmi.*;
import javax.rmi.*;
import java.util.*;
import javax.naming.*;
import javax.ejb.*;
import java.math.BigDecimal;
public class ConverterClient {
public static void main(String[] args) {



try {
Hashtable h=new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
h.put(Context.PROVIDER_URL,"iiop://localhost:900");
Context initial = new InitialContext(h);
System.out.println("********"+initial);
Object objref = initial.lookup("ConverterBean");
System.out.println("7777777"+objref);
ConverterHome home =(ConverterHome)PortableRemoteObject.narrow(objref,ConverterHome.class);
Converter currencyConverter = home.create();
BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount =currencyConverter.dollarToYen(param);
System.out.println(amount);
amount = currencyConverter.yenToEuro(param);
System.out.println(amount);
System.exit(0);
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
 
GeeCON Prague 2014
 
subject: NoInitilaContextException