Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.naming.NoInitialContextException: Cannot instantiate

843829Apr 29 2004 — edited Feb 22 2006
IHi,
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
java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory]

from catch block of jMenuItem1

error from NamingException.getMessage()is: Cannot instantiate
class: weblogic.jndi.WLInitialContextFactory


HERE IS THE CODE FOR CLIENT:
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");
h.put(Context.PROVIDER_URL,"t3://localhost:7001");




try{

context = new InitialContext(h);







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


System.out.println(obj.getClass());


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)

{



Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2006
Added on Apr 29 2004
6 comments
8,983 views