File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "NoInitialContext  Exception" Watch "NoInitialContext  Exception" New topic
Author

NoInitialContext Exception

Ajoy Sharma
Greenhorn

Joined: Feb 24, 2004
Posts: 18
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)
{
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: http://aspose.com/file-tools
 
subject: NoInitialContext Exception
 
Similar Threads
NoIntailContextException
JNDI
error: java.lang.ClassCastException
Jndi Error In Client Application
where to run the JNDI program