NoInitialContextException

Hi!
I have uploaded my jar file on weblogic server 6.1.
But when i execute my client program it gives me following
problem .
Exception in thread "main" javax.naming.NoInitialContextException: Need to speci
fy class name in environment or system property, or as an applet parameter, or i
n an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
43)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:283)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at HelloClient.main(HelloClient.java:17)
So pl. tell me how to solve this.
Thanks

Assuming ur client is a standalone application...
Make sure the file weblogic.jar is present in the classpath of ur client. Also make sure u specify the name of the InitialContextFactory class while creating the InitialContext.
eg.,
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://machineName:port_no");
ctx = new InitialContext(ht);

Similar Messages

  • Exception in thread "main" javax.naming.NoInitialContextException: Need to

    Hey,
    I am exploring the technique 'JMS'. I found an sample code on the Internet (https://www.redhat.gl/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/JMS_Examples-A_Point_To_Point_Example.html).
    But unfortunately, by running the code on my local computer, I got an NoInitialContextException (Exception in thread "main" javax.naming.NoInitialContextException: Need to ...Application resource file: java.naming.factory.initial). After searching on the Internet, I discovered I need to configure some JNDI values. But, also after passing on the variables to the class by parameter (-Djava.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory), I still get the same error.
    What have I forgotten? Hope someone can help. Thanks!
    Tongue78.
    public void setupPTP()
    throws JMSException,
    NamingException
    InitialContext iniCtx = new InitialContext();
    Object tmp = iniCtx.lookup("ConnectionFactory"); // exception occurs here..
    QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
    conn = qcf.createQueueConnection();
    que = (Queue) iniCtx.lookup("queue/testQueue");
    session = conn.createQueueSession(false,
    QueueSession.AUTO_ACKNOWLEDGE);
    conn.start();
    ....

    Refer to the Sun App Server documentation.
    http://docs.sun.com/source/819-0079/dgacc.htmlIt lists down the steps you need to follow.

  • How to get rid of  "javax.naming.NoInitialContextException"

    Hi,
    Iam learning ejb. I was practicing the stateless session bean. I wrote a sample hello world application. While executing the client am getting the following error.
    {color:#ff0000}Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at hw.HelloClient.main(HelloClient.java:20){color}
    My Client program:
    {color:#ff0000}package hw;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.*;
    import java.util.*;
    public class HelloClient {
    public static void main(String[] args)throws Exception {
    Properties prop = System.getProperties();
    Context ctx= new InitialContext(prop); {color}{color:#ff0000}{color:#800000}// (Line no :20) here only error is pointing
    {color:#ff0000}Object obj = ctx.lookup("HelloHome");
    HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
    Hello hello = home.create();
    System.out.println(hello.hello());
    hello.remove();
    }{color}{color}
    {color}
    please suggest me a solution. what has gone wrong!!

    At a guess, I would say you "Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file". But I'm just guessing.

  • Error in EJB client program (javax.naming.NoInitialContextException)

    Hi folks ,
    I'm new to j2ee programming and using Netbeans 5.5 , i created a session bean program and deployed successfully in JOnAS application server but i'm not able to run the client program which invokes session bean (EJB module ).
    when i run client program i'm getting the following error .
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
            at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
            at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
            at javax.naming.InitialContext.lookup(InitialContext.java:351)
            at SimpleSessionClient.Main.main(Main.java:33)
    BUILD SUCCESSFUL (total time: 21 seconds)
    but the same program runnig perfectly when i deploy in Java System Application Server(8.2(JSAS))
    I included j2ee.jar and appserv-rt jar in classpath of client program for JSAS i don't know what are the jar files (which does the same function as j2ee.ar,appserv-rt.jar ) which is to be included for JOnAS .
    i'm struggling with this for the past two weeks . please tell me the solution .
    Thanks in advance

    Thanks for the suggestion artntek.
    I located the jndi.properties file in the %J2EE_HOME%\lib\classes folder, and I copied it to the %J2EE_HOME%\bin directory, but nothing seems to have changed.
    does anyone know what value should be associated with Context.INITIAL_CONTEXT_FACTORY in the properties for the InitialContext object? More specifically, what value should be used for the reference install of the 1.3 j2ee release from sun?
    This error suggests to me that a class name must be specified for the initial naming context factory - but I don't know what to use.

  • NoInitialContextException in jms

    i wrote a simple jms program for point to point Destination
    i am able to run the program in j2ee 1.3
    but i get problem with j2ee 1.4
    here is my program
    import javax.jms.*;
    import javax.naming.*;
    class test
         public static void main(String arg[])
              try {
                   Context ctx = new InitialContext();
                   QueueConnectionFactory  connectionFactory = (QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
                   Queue myDest = (Queue) ctx.lookup("MyQueue");
                   QueueConnection connection = connectionFactory.createQueueConnection();               
                   QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                   QueueSender producer = session.createSender(myDest);
                   TextMessage message = session.createTextMessage();
                   message.setText("Message");
                   producer.send(message);          
                   connection.close();
              } catch (NamingException e) {               
                   e.printStackTrace();
              } catch (JMSException e) {               
                   e.printStackTrace();
    }& i got following error
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
         at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
         at javax.naming.InitialContext.lookup(Unknown Source)
         at test.main(test.java:9)i have created QueueConnectionFactory in admin console
    & even i tried as jms/QueueConnectionFactory but i am getting same error. what is the reason for this plz give me solutions
    Thanks in advance

    i need it urgently anybody could send me solution please.

  • NoInitialContextException when I try to lookup my ConnectionFactory

    Hello everyone,
    I'm now working on a small project using JMS, and I have installed the last version of JDK 6 Update 17 With J2EE.
    try{
         Context jndiContext = new InitialContext();
         connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/ConnectionFactory");
         queue = (Queue)jndiContext.lookup("jms/queue");
    }catch(NamingException exc){
         System.err.println("Lookup Object failed");
         exc.printStackTrace();
         System.exit(1);
    ... ... ...When I tried to run the program above, I got a NoInitialContextException at the line : Context jndiContext = new InitialContext() . The full error message is:
    {color:#0000ff}
    javax.naming.NoInitialContextException: Cannot instantiate class: org.exolab.jms
    .jndi.InitialContextFactory [Root exception is java.lang.ClassNotFoundException:
    org.exolab.jms.jndi.InitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    57)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:175)
    at SimpleMessageProducer.main(SimpleMessageProducer.java:49)
    Caused by: java.lang.ClassNotFoundException: org.exolab.jms.jndi.InitialContextF
    actory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
    a:46)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    54)
    ... 4 more{color}
    I have created a javax.jms.ConnectionFactory and a javax.jms.Queue in the Glassfish Admin Consle -> Resources -> JMS Resources -> Connection Factories / Destinations Resources, and I have also added the appserv-rt.jar and javaee.jar into CLASSPATH. But my program still doesn't work.
    I have tried to get my connection factory with the annotations @Resource, but it doesn't work either.
    Si I'm "lookup" someone who could debug this program for me,
    Greetings
    Edited by: WeepInSilence on Nov 8, 2009 8:57 AM
    Edited by: WeepInSilence on Nov 8, 2009 11:05 AM

    Hello esiuolyma,
    After reviewing your post, it sounds like the iPod is not recognized and that will not allow you to sync. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
    iPhone, iPad, or iPod not recognized in iTunes for Windows - Apple Support
    If you don't see your connected device in iTunes for Mac - Apple Support
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Using JDBC Data Sources with ADFBC, NoInitialContextException

    Using JDBC Data Sources with ADF Business Components, NoInitialContextException
    I follow the instruction in the link below to create an ADF Swing application using datasource. I am using JDeveloper version 10.1.3.
    http://www.oracle.com/technology/products/jdev/howtos/10g/usingdatasources/using_datasources.html
    The ADF generated code looks like this:
    JUMetaObjectManager.setErrorHandler(new JUErrorHandlerDlg());
    JUMetaObjectManager mgr = JUMetaObjectManager.getJUMom();
    mgr.setJClientDefFactory(null);
    BindingContext ctx = new BindingContext();
    ctx.put(DataControlFactory.APP_PARAM_ENV_INFO, new JUEnvInfoProvider());
    ctx.setLocaleContext(new DefLocaleContext(null));
    HashMap map = new HashMap(4);
    map.put(DataControlFactory.APP_PARAMS_BINDING_CONTEXT, ctx);
    mgr.loadCpx("datasource.view.DataBindings.cpx" , map);
    final FormMain frame = new FormMain();
    frame.setBindingContext(ctx);
    I got this error when executing the last line: frame.setBindingContext(ctx);
    (oracle.jbo.common.ampool.ApplicationPoolException) JBO-30003: The application pool (datasource.datamodel.AppModuleDS) failed to checkout an application module due to the following exception:
    ----- LEVEL 1: DETAIL 0 -----
    (oracle.jbo.JboException) JBO-29000: Unexpected exception caught: oracle.jbo.DMLException, msg=JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/xe_hrDS
    ----- LEVEL 2: DETAIL 0 -----
    (oracle.jbo.DMLException) JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/xe_hrDS
    ----- LEVEL 3: DETAIL 0 -----
    (javax.naming.NoInitialContextException) Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    If I configure the application module connection type as JDBC URL, everything works.
    If the connection type is JDBC Datasource, I got the above error.
    Can someone show me how to adjust the generated code by ADF to use datasource?

    ADF BC has a bug. With Data Source in Application Module, application module does not connect. Use JDBC Connection URL.
    Also refer
    ADF BC: JDBC URL vs JDBC DataSource

  • NoInitialContextException when re-submitting a message using command line

    Hello,
    I am trying to re-submit an application message, following discussion in section 18 of the user guide. The command and the exception are shown below., Basically, I am getting a jndi exception. What am I missing / not doing right?
    C:\Oracle\Middleware\jdev_home\jdeveloper\ant\bin\ant -f "C:\Oracle\Middleware\11g_home\Oracle_SOA1\bin\ant-b2b-util.xml" b2bresubmit -Ddirection=outbound -Dmsgsource=appMsg -Dmsgid=2d383837363839393330363531393933 -DpayloadPath="BusMsg_Payload_2d383837363839393330363531393933.txt"
    Buildfile: C:\Oracle\Middleware\11g_home\Oracle_SOA1\bin\ant-b2b-util.xml
    b2bresubmit:
    weblogic_dependencies:
    [echo]
    [echo] Weblogic server location: C:\Oracle\MIDDLE~1\11g_home\WLSERV~1.3
    [echo] JNDI properties folder location: C:\Oracle\Middleware\11g_home\Oracle_SOA1\bin
    [echo]
    utility:
    [echo]
    [echo] java.naming.provider.url=${java.naming.provider.url}
    [echo] java.naming.factory.initial=${java.naming.factory.initial}
    [echo] java.naming.security.principal=${java.naming.security.principal}
    [echo] java.naming.security.credentials=*****
    [echo]
    [echo]
    [echo] args=resubmit ${propfile}
    [echo]
    [java] Commandline arguments 2: [resubmit, ${propfile}]
    [java] Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system p
    roperty, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    [java] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    [java] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    [java] at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
    [java] at javax.naming.InitialContext.lookup(InitialContext.java:392)
    [java] at oracle.tip.b2b.utility.B2BCommandLineUtility.getB2BUtility(B2BCommandLineUtility.java:197)
    [java] at oracle.tip.b2b.utility.B2BCommandLineUtility.resubmitMessage(B2BCommandLineUtility.java:1249)
    [java] at oracle.tip.b2b.utility.B2BCommandLineUtility.main(B2BCommandLineUtility.java:786)
    [java] Java Result: 1
    BUILD SUCCESSFUL
    Total time: 6 seconds
    C:\Oracle\Middleware\11g_home\user_projects\domains\single_server_domain>

    Thanks, Anuj.
    Indeed I did not read 18.1. Now I have.
    18.1 uses Unix syntax, the Windows syntax (where I am working) would look like that shown below, where JDK location will naturally vary and the middleware home may be different:
    set ORACLE_HOME=C:\Oracle\Middleware\11g_home\Oracle_SOA1
    set ANT_HOME=%ORACLE_HOME%\..\modules\org.apache.ant_1.7.1
    set JAVA_HOME=C:\jdk1.6.0_20
    The one-off jndi properties generation will be as shown in teh manual however it would see that teh port number of the weblogic server may need to be changed as well as the weblogic password - for me it was generated as 8001 whwere my weblogic server actually runs on 7001
    @REM create once off jndi proprties
    cd %ORACLE_HOME%\bin
    ant -f ant-b2b-util.xml b2bcreate-prop
    @rem Edit the jndi.properties file to include the weblogic password and fix weblogic port number
    To submit a "repaired" applicaiton message one would do:
    @rem run the utility - must have absolute path to message file!
    set ORACLE_HOME=C:\Oracle\Middleware\11g_home\Oracle_SOA1
    set ANT_HOME=%ORACLE_HOME%\..\modules\org.apache.ant_1.7.1
    set JAVA_HOME=C:\jdk1.6.0_20
    %ANT_HOME%\bin\ant -f %ORACLE_HOME%\bin\ant-b2b-util.xml b2bresubmit ^
    -Dmsgid=2d373838303530333432393931303931 ^
    -Dmsgsource=APPMSG ^
    -Ddirection=OUTBOUND ^
    -Dpayloadpath=C:\hl7\repair\AppMsg_Payload_2d373838303530333432393931303931.txt
    It is critical to make sure the absolute path to the repaired message file is provided otherwise null pointer exceptions will be had even if the command is executed from the directory in which the messge file is located.
    Another thing that will trip the beginner is the Message ID. The Message ID that is needed is that shown all over the place as MSG_ID or as b2b.messageId, which are the same. In the B2B Web Console this message ID will be shown in "application Message" tab of teh "reporting" facility, when one clicks the "details" "button" and looks at b2b.messageId property value. It is also shown as "Message Id" in teh details of teh business message. It would be nice if one could see this applicaitn message id in teh applicaiton messages report but I guess one can't have everything.
    One also gets to know what the applicatin message Id is when one "downloads" the payload of the application message. The file name, which will be provided as default, will have the message id embedded - nice and easy :-) AppMsg_Payload_2d373838303530333432393931303931.txt
    Thanks again
    Michael

  • EJB ERR: Namingexception caught:javax.naming.NoInitialContextException

    Hi,
    I am trying to deploy a sample ejb on Jboss and trying to call it from a client.
    I am getting the following error.
    *********Before LookUP*********
    Namingexception caught:javax.naming.NoInitialContextException: Need to specify c
    lass name in environment or system property, or as an applet parameter, or in an
    application resource file: java.naming.factory.initial
    This is my client code for the ejb where I have specified the INITIAL_CONTEXT_FACTORY and PROVIDER_URL..
    Am I missing something here?
    Is there any other way to go about this. Any help would be greatly appreciated.
    Thanks and Regards,
    Ajith
    THE CLIENT CODE IS AS GIVEN BELOW
    package simple_bean_client;
    import javax.ejb.*;
    import simpleBean.*;
    import javax.naming.Context;
    import java.util.Properties;
    import java.util.Hashtable;
    import javax.naming.InitialContext;
    class SalaryClient
         public static void main(String args[])
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              env.put(Context.PROVIDER_URL, "localhost:1099");
              env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
         /*Properties pro = System.getProperties();
         pro.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
         pro.put( "java.naming.provider.url","localhost:1099" );*/
              try{
                   InitialContext ctx=new InitialContext();
                   System.out.println("*********Before LookUP*********");
                   Object objRef=ctx.lookup("SalaryHome");
                   System.out.println("*********After LookUP*********");
                   SalaryHome home=(SalaryHome)javax.rmi.PortableRemoteObject.narrow(
                   objRef,SalaryHome.class);
                   Salary bean=home.create();
                   System.out.println("monthly net salary:"+bean.calculateSalary(28000,2,500));
              }catch(javax.naming.NamingException ne){
                   System.out.println("Namingexception caught:"+ne);
              }catch(javax.ejb.CreateException ce){
                   System.out.println("Create exeption caught:"+ce);
              }catch(java.rmi.RemoteException re){
                   System.out.println("Remote Exception caught:"+re);               
         }//closing main
    }//closing the class

    Found this . . .
    The following works for JBOSS, jndi.properties -file:
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=jnp://your.host.com:1099
    The client code is as follows:
    Properties prop = new Properties();
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(jndi_property_file);
    prop.load(is);
    Context ctx = new InitialContext(prop);
    anEJBHome =(EJBHome)PortableRemoteObject.narrow(ctx.lookup(homeClass.getName()),homeClass);

  • Javax.naming. NoInitialContextException

    public class client {
         public String doStandalone() {
              try {
                   Context jndiContext = getInitialContext();
                   Object ref = jndiContext.lookup("TestSessionHome");
                   TestSessionHome home = (TestSessionHome) PortableRemoteObject.narrow(ref, TestSessionHome.class);
                   TestSession remote = home.create();
                   remote.test("[email protected]");
              } catch (RemoteException e) { return "failed! RemoteException";
              } catch (NamingException e) {
                   StringWriter sw = new StringWriter();
                   PrintWriter bf = new PrintWriter(sw);
                   e.printStackTrace(bf);
                   return "failed! NamingException" + "\n" + sw.toString();
              } catch (CreateException e) { return "failed! CreateException";
              return "Success!";
         public Context getInitialContext() throws NamingException {
             Properties p = new Properties();
             p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
             p.put(Context.PROVIDER_URL,  "iiop://localhost:2809/");
             return new InitialContext(p);
    }1. All imports are well set
    2. IDE = Websphere studio 5
    3. output:
    (java.lang.String) failed! NamingException
    javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory. Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:240)
    Can anyone tell me how to properly set the jndi settings?
    Thanks!
    Also: everything works fine when the bean is used in a jsp or servlet either directly or through an access bean.
    The above code is for a remote client trying to access the bean.

    It is not the JNDI settings. Check to see if you have the jar file containing the WsnInitialContextFactory available in your classpath
    Vijay

  • 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)

    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)

  • Naming error: javax.naming.NoInitialContextException

    I get the below error message when I try to run the testing class below that. I googled the exception and read:
    This exception is thrown when no initial context implementation can be created. The policy of how an initial context implementation is selected is described in the documentation of the InitialContext class.
    // then I read this: http://publib.boulder.ibm.com/infocenter/adiehelp/index.jsp?topic=/com.sun.api.doc/javax/naming/NoInitialContextException.html
    This exception can be thrown during any interaction with the InitialContext, not only when the InitialContext is constructed. For example, the implementation of the initial context might lazily retrieve the context only when actual methods are invoked on it.
    I really dont understand what I read. Could someone please explain what my issue is and why it is occurring and how I could fix it.
    Thank you in advance,
    Crystal
    Naming error: javax.naming.NoInitialContextException: Need to specify class name
    in environment or system property, or as an applet parameter, or in an applicat
    ion resource file:  java.naming.factory.initial
    Exception in thread "main" java.lang.NullPointerException
            at notifier.notifierMethod.SiteManager(notifierMethod.java:230)
            at notifier.testing.main(testing.java:22)
    testing.java
    class testing {
        public static void main(String[] args) {
            //Display "Hello World!"
            System.out.println("Hello World!");
            notifier notifierInformation = new notifier();
            //session.setAttribute("notifier", notifierInformation);
            //get db connection
            database.DataFactory dbf = database.DataFactory.getDataFactory(database.DataFactory.sybase);
            notifierInterface notifierDB = dbf.getNotifierInterface();
            notifier sitemanager = notifierDB.SiteManager(newID, notifierInformation);  // LINE 22
    notifierMethod
    public notifier SiteManager(String newID, notifier notifierInformation) {
            try {
                ArrayList sitemgrList = new ArrayList();
                this.conn = database.SybaseDAO.grabConnection();
                cs = conn.prepareCall("{call mt."+newID+"_Notifier_SiteManager()}"); // LINE 230
                rs = cs.executeQuery();
                while(rs.next()) {
                    String owner = rs.getString(1);
                        sitemgrList.add(owner);
                notifierInformation.setSitemgrList(sitemgrList);
    }

    Aleen - Thank you for your help but I just dont get what you are saying at all! I am reading through all the links and its just not clicking with me. Is it possible for you to show me a vague example of what you mean?
    What do you mean by system properties/enviroment parameters? Do you mean what is in my web.xml/server.xml, like so?
    public static Connection grabConnection() {
            Connection conn = null;
            try {
                Context ctx = (Context)new InitialContext().lookup("java:comp/env");
                DataSource ds = (DataSource)ctx.lookup("jdbc/connectDB");
                conn = ds.getConnection();
            } catch(SQLException e) { System.err.println("SQL error: " + e);
            } catch(NamingException n) { System.err.println("Naming error: " + n);
            return conn;
    web.xml
    <description>MySQL Test App</description>
    <resource-ref>
          <description>DB Connection</description>
          <res-ref-name>jdbc/connectDB</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
    </resource-ref>
    server.xml
    <Context path="/appName" docBase="/appName"
            debug="5" reloadable="true" crossContext="true">
      <Logger className="org.apache.catalina.logger.FileLogger"
                 prefix="localhost_DBPool_log" suffix=".log"
                 timestamp="true"/>
    <Resource name="jdbc/connectDB" auth="Container" type="javax.sql.DataSource"
                   maxActive="5" maxIdle="1" maxWait="10000" removeAbandoned="true"
                removeAbandonedTimeout="60" logAbandoned="true"
                   username="myName" password="myPass" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
                   url="jdbc:odbc:webdev"/>
    </Context>I just dont understand why if I have this code in a servlet it works fine but when I try to put it in a java class it doesnt work. And I am sorry in advance, I am not trying to be a pain in the a55 to you.. and I will keep reading
    Thanks - Crystal

  • NoInitialContextException error in Client stub tester

    I keep on getting the following exception.
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at TestClient.main(TestClient.java:9)
    My bean is in the testing package. It compiles quite alright, but won't execute when I try the lookup. It fails on lookup, What more do I need 2 be doing. I can access the bean using a JSP page but not via client stub code????
    import testing.*;
    import javax.naming.InitialContext;
    public class TestClient
    public static void main(String [] args){
         try {
         InitialContext ic = new InitialContext();
         Object o = ic.lookup ("ejb/TestingBean");
         } catch (Exception e) {
         System.err.println ("Some weird asss exception occurred");
         e.printStackTrace();
    }

    The best option is to write a portable Java EE Application Client component and let the Application Client container bootstrap the naming service so your code doesn't have to. If you prefer to write a non-portable stand-alone java client, we have instructions for how to do that here :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Jndi.properties - javax.naming.NoInitialContextException

    hi
    i'm new to netbeans (5.5) and the Sun 9 appserver. I've been using JBoss & Eclipse to date.
    I'm getting the javax.naming.NoInitialContextException and I believe it's because I'm not using jndi.properties like in jboss.
    The problem is that I cannot seem to find where it should go and what it should look like.
    Can someone please help ?
    Thanks

    All the documentation you need is here:
    http://docs.sun.com/app/docs/coll/1343.3
    I would particularly point you to http://docs.sun.com/app/docs/doc/819-3659/6n5s6m5bn?a=view

  • Javax.naming.NoInitialContextException! Urgent help needed

    Hi All
    I'm using Oracle Application Server(OC4J) for J2EE. i created an application of Stateless Session Bean & tested on j2sdkee1.3.1, & it is working fine on it. Same Application (an .ear file) i deployed on OC4J. But it is giving an error NoInitialContextException, lookup fails here.
    Application contains method getEchoString(String):String & a index.jsp page calling a bean's method.
    Can anybody tell me the solution to get handle of beans home interface for calling method.
    Already i've wasted many days for this. Plz help. It's urgent
    Thanks in Advance

    To the best of my knowledge, the 'javax.naming.ldap' package is fairly new, and is only included in the most recent distributions of the JNDI API. I know that this package is included with J2SDK 1.3, and I can also confirm that the very latest JNDI distribution (from http://java.sun.com/products/jndi/#download) contains the package.
    Good luck,
    -Derek

Maybe you are looking for

  • Good Receipt using BARCODE

    Hi, we want to make good receipt (gate entry MIGO) thru BARCODE. what setting are required in MM and ABAP Please reply it is urgent Any help will be rewarded. Regards shakir

  • Low quality video after import from After Effects in FCP 7, but not FCP5

    Hi everyone, I trying to export a video from final cut pro. This video has motion graphics I built in After Effects, as well as footage from my T2i camera. I then took it into FCP to drop in audio and edit all my elements together. When I exported a

  • Mail to Form Code Confussion

    Hello everyone. I am having an issue with my Mail to Form code. It's not so much a technical one (I don't think it is anyway) It's mostly I don't understand what information to plug into a couple parts. I will post the code here (leaving out everythi

  • Triggering BPM Process without using Guest

    Hi All, I am triggering BPM web service from webdynpro from java. This is giving error message : Server Exception: Guest,  is not allowed to start a process.; nested exception is: javax.xml.rpc.soap.SOAPFaultException: Guest,  is not allowed to start

  • Rename all Vis in a library(llb)

    Hi, How can I automatically rename all Vis in a Vi library in LabVieW 5.0.1? My application must change all the names of the Vis in the Library and update all the callers to use the new names so that it won't request me to find the new Vi when I run