• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoInitialContext Exception  RSS feed

Ajoy Sharma
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!