It's not a secret anymore!
The moose likes BEA/Weblogic and the fly likes NoInitialContext  Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "NoInitialContext  Exception" Watch "NoInitialContext  Exception" New topic

NoInitialContext Exception

Ajoy Sharma

Joined: Feb 24, 2004
Posts: 18
Iam trying to run my first application on WEBLOGIC SERVER 8.1. I have already deploed class file on server.i have already set path for my client jar .
When I use my client run on JDK to access the application.
I got following errror::::
Naming Error: catch block of getInitalContext()
javax.naming.NoInitialContextException: Cannot instantiate
class: weblogic.jndi.WLInitialContextFactory [Root exception is
from catch block of jMenuItem1
error from NamingException.getMessage()is: Cannot instantiate
class: weblogic.jndi.WLInitialContextFactory

import java.awt.event.*;
import javax.rmi.*;
import java.rmi.*;
import javax.swing.event.*;
import javax.swing.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Hashtable;
import java.util.Properties;
import javax.ejb.CreateException;
import org.omg.CosNaming.*;
import java.util.Hashtable;
import weblogic.jndi.*;
//import javax.weblogic.jndi.WLInitialContext;
public class Client {
public static void main(String[] args){

Context context= null;
Hashtable h = new Hashtable();

h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

context = new InitialContext(h);
Object obj = context.lookup("ServerObject"); //Server ejb-name


ServerHome serverhome =(ServerHome) javax.rmi.PortableRemoteObject.narrow(context.lookup("ServerObject"),ServerHome.class);
Server server = serverhome.create();
String Message = JOptionPane.showInputDialog("Enter Your Message");
JOptionPane.showMessageDialog(null, server.performAction(Message) );

catch(Exception e){
JOptionPane.showMessageDialog(null ,"Exception is " +e);
code for bean:::::::
//package EJBExample;
import javax.ejb.*;
import java.rmi.*;
import javax.swing.*;
public class ServerBean implements SessionBean
private SessionContext stx;
//In following five methods create is by contract others to be implemented by Container
public void ejbCreate(){}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(SessionContext ctx)
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Well, the error basically speaks for itself. The weblogic.jndi.WLInitialContextFactory class was not found. You need to make sure you include the wlclient.jar on your client's CLASSPATH.
Moving to the WebLogic Forum for further discussion...
I agree. Here's the link:
subject: NoInitialContext Exception
It's not a secret anymore!