javax.naming.NoInitialContextException: Cannot instantiate

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)

{

[2800 byte] By [ajoyxs] at [2007-9-30 7:32:46]
# 1
Make sure u have weblogic.jar in the classpath of client. -Kshitij.
kshitij_u at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

The problem is related to the classpath.

I use the .bashrc file to set the environment. I use JBOSS for my EJB services.

I set the JLIB variable (could be any variable) to point to my JBOSS_HOME/client directory.

JBLIB=/opt/jboss-3.2.5/client

export JBLIB

I included the jar's in the client directory in the classpath

CLASSPATH=.:$JBLIB/jnp-client.jar:$JBLIB/jboss-common-client.jar:$JBLIB/jboss-j2ee.jar:$JBLIB/jboss-net-client.jar:$JBLIB/jbossall-client.jar

export CLASSPATH

The when I ran the sample jboss, I ran it as follows:

java -classpath $CLASSPATH:assemble/cartclient.jar com.sme.ejb.cart.CartClient

where assemble was the directory in which I have my jar files stored.

Hopefully this classpath should resolve your problem.

vramamur at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

hi

Am facing the problem whenever i run the client jsp definitly run the first time but next time i get the particular error please let me clear about this error i m attaching the client code and also error screen..

client jsp

<%UserInfoSB objUserInfoSB;

System.out.println("########## 2 #########");

Properties props= System.getProperties();

System.out.println("########## 3 #########");

Context ctx = new InitialContext(props);

System.out.println("########## 4 #########");

props.put(Context.INITIAL_CONTEXT_FACTORY, "Weblogic.jndi.WlInitialContextFactory");

props.put(Context.PROVIDER_URL,"t3://localhost:7001");

System.out.println("########## 5 #########");

UserInfoSBHome objUserInfoSBHome =(UserInfoSBHome) ctx.lookup("UserInfoSBHome");

System.out.println("########## 6 #########");

objUserInfoSB = objUserInfoSBHome.create();

System.out.println("########## 7 #########");

//objUserInfoSB.processInterfaceUserHistoryDetails(objUserDetailVO);

ArrayList alResult = objUserInfoSB.processInterfaceGetAllUserDetail();

objUserInfoSB.remove();

System.out.println("########## 8 #########");

%>

It is error which i am facing plz let me clear

NoInitialContextException: Cannot instantiate class: Weblogic.jndi.WlInitialContextFactory. Root exception is java.lang.ClassNotFoundException: Weblogic.jndi.WlInitialContextFactory

at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:186)

at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:62)

at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:41)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:217)

at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.init(InitialContext.java:219)

at javax.naming.InitialContext.(InitialContext.java:195)

at jsp_servlet._jsp._epfindia._mydata.__userdisplayall._jspService(__userdisplayall.java:374)

at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)

at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6291)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)

at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)

at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)

at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)

at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)

at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)

manish_sisl at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Please use the following with same case whatever i had mentioned and also confirm that proper class path is setweblogic.jndi.WLInitialContextFactory
ezhil75 at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

> It is error which i am facing plz let me clear

> NoInitialContextException: Cannot instantiate class:

> Weblogic.jndi.WlInitialContextFactory. Root

> exception is java.lang.ClassNotFoundException:

> Weblogic.jndi.WlInitialContextFactory

Class and package names are case sensitive. It should be weblogic.jndi.WlInitialContextFactory.

Annie. at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6
Place weblogic.jar in the class path,that solves the problem.For Non Weblogic Server users place servername.jar file in the class path,that solves the problem.
akash_kumar_99 at 2007-7-2 0:27:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...