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

Hi!
I got this error message at runtime.
After adding value to the Intialcontext by adding the following code snippet:
Properties p = new Properties();
p.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
p.put("java.naming.provider.url",
"iiop://127.0.0.1:9010");
initContext = new javax.naming.InitialContext(p);
After this i am getting different error message:
org.omg.CORBA.COMM_FAILURE:
minor code: 1 completed: Maybe at om.sun.corba.se.internal.iiop.IIOPConnection.purge_calls(Unknown Source)
at com.sun.corba.se.internal.iiop.ReaderThread.run(Unknown Source)
Looking forward a proper solution
for this problem.
Thanks in advance.
Regards,
James Arun

I have find the code to specify the naming context property to access another host
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// optional. Defaults to localhost. Only needed if web server is running
// on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

Similar Messages

  • How to specify class name in environment or system property

    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:#3366ff}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:#800000}// {color}{color:#800000}(Line no :20) here only error is pointing{color}
    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}
    please suggest me a solution.
    note: iam using eclipse ganymede and jboss app server
    Edited by: Arun_ece on Mar 10, 2009 1:13 AM

    Hi,
    You need to create a ejb-jar.xml and jboss.xml files to deploy the application on the servers.
    Also, put these lines of codes after getting System Properties.
    prop.put(Context.PROVIDER_URL, "iiop://localhost:[port_no]");Thanks,
    Srikant

  • Javax.naming.NoInitialContextException: Need to specify class name...

    Hello,
    I am trying to use a Database Connection Pool.
    Here is the test class am using to verify the connection pool:
    public static void main(String[] args) { Connection connection = null; try { InitialContext initialContext = new InitialContext(); DataSource dataSource = (DataSource)initialContext.lookup("jdbc/<alias>"); connection= dataSource.getConnection(); } catch (SQLException e) { //   TODO Auto-generated catch block e.printStackTrace(); } catch (NamingException e) { //   TODO Auto-generated catch block e.printStackTrace(); } Statement stmt = null; try { String query = ""; stmt = connection.createStatement(); ResultSet resultSet = null; query = "SELECT <column> ...'"; resultSet = stmt.executeQuery(query); while(resultSet.next()){ System.out.println(resultSet.getString(<column>)); } stmt.close();   stmt = null; connection.close(); connection = null; } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }finally{ if (stmt != null) {   try {   stmt.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   }   stmt = null;   }   if (connection != null) {   try { connection.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   } connection = null;   } } }
    I get 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:640) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.internal.test.TestRun.main(TestRun.java:53) java.lang.NullPointerException at com.internal.test.TestRun.main(TestRun.java:66) Exception in thread "main"
    The exception points to
    DataSource dataSource = (DataSource)initialContext.lookup("jdbc/OrderStatus");
    Is this the correct way to test...?
    Thanks
    Srinivas

    java_2006 wrote:
    You can't access a jdbc pool like that (simply with a main method).
    The Database connection pool must be managed by a container (a servlet or application server) like tomcat.
    That is not entirely true but it certainly helps and is generally the only way it is used anyway so one might as well do it.

  • NoInitialContextException:  ...java.naming.factory.initial

    Calling J2eeRi.LookupEjbHome() throughs a NoInitialContextException (see bottom) in the last example of the COM Bridge Tutorial:
    ----- last line of the following code segement throws exception:
    Dim JvmCtl As New JvmControl
    JvmCtl.Classpath = "%J2EE_HOME%\lib\j2ee.jar;%COMBRIDGE_HOME%\doc\guide\examples\lib\AccountAppClient.jar"
    JvmCtl.StartJvm
    Set J2eeRi = New J2eeRiServices
    J2eeRi.ProviderURL = "iiop://localhost:1244" '1050
    Set AcctHome = J2eeRi.LookupEjbHome("MyAccount", "account.AccountHome")
    java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException: 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:638)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:278)
         at javax.naming.InitialContext.lookup(InitialContext.java:345)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.sun.interop.beans.PrivilegedMethodInvokeAction.run(PrivilegedMethodInvokeAction.java:51)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.interop.beans.RegularDispatcher.invoke(RegularDispatcher.java:142)
         at com.sun.interop.dispatch.InstanceProxy.Invoke(InstanceProxy.java:96)
    java.lang.Exception: Could not call javax.naming.InitialContext.lookup because: 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 com.sun.interop.beans.RegularDispatcher.invoke(RegularDispatcher.java:159)
         at com.sun.interop.dispatch.InstanceProxy.Invoke(InstanceProxy.java:96)
    java.lang.Exception: Could not call javax.naming.InitialContext.lookup because: 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 com.sun.interop.beans.RegularDispatcher.invoke(RegularDispatcher.java:159)
         at com.sun.interop.dispatch.InstanceProxy.Invoke(InstanceProxy.java:96)
    What's missing here?

    http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/Context.html
    maybe you should set the property:Context.INITIAL_CONTEXT_FACTORY
    try that.

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

  • Javax.naming.NoInitialContextException ERROR

    I get the following error:
    Naming exception Error while connecting to the database : 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
    I created a Java class which has a method which connects to the database using:
    InitialContext ctx = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/TMBLDB01CoreDS");
    m_connection = ds.getConnection();
    It errored out on the second line with the above error. I am using JDeveloper 10.1.3.
    I got it to work with a JDBC connection but prefer to use JNDI with JDBC.
    I started the Oracle AS Containers for J2EE (OC4J) by double clicking start_oc4j.bat.
    What is missing to make this work?

    Yes by adding the following solved that issue.
      env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);Another thing is I have added BC4J Client as library to my project. When I run I am getting
    javax.naming.NamingException: oracle.jbo.server.InitialContextImpl [Root exception is java.lang.ClassNotFoundException: oracle.jbo.server.InitialContextImpl]
         at oracle.jbo.common.JboInitialContextFactory.getInitialContext(JboInitialContextFactory.java:65)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
         at javax.naming.InitialContext.init(InitialContext.java:223)
         at javax.naming.InitialContext.<init>(InitialContext.java:197)Do I need any other libraries?
    Thanks

  • Javax.naming.NoInitialContextException - jndi.properties

    I created an Enterprise application and deployed an Ejb project to the JBoss server.When I try to connect to the JNDI like this:
    Object o = initialContext.lookup(JNDI_NAME); I get this 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
    I put the jndi.properties file both into the client app and the bean project, near the .java files.
    here is the jndi.properties file:
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=http://localhost:1099
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    I'm really confused...
    thanks..

    xyzt wrote:
    I put the jndi.properties file both into the client app and the bean project, near the .java files.
    here is the jndi.properties file:
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=http://localhost:1099
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    I think that goes in
    ${JBOSS_HOME}/server/default/deploy/jms/jms-ds.xml

  • Javax.naming.NoInitialContextException when invoking an EJB

    Hi,
    I've deployed a stateless session EJB in oc4j and invoking it thru a Java client. I'm using Eclipse. I've a jndi.properties in config folder of my application which is in the classpath of the client code.
    The jndi.properties has :
    java.naming.factory.initial=com.evermind.server.rmi.RMIInitialContextFactory
    java.naming.provider.url=ormi://<localhost>:12401/OC4JEJB
    java.naming.security.principal=oc4jadmin
    java.naming.security.credentials=oc4jadmin
    where OC4JEJB is the application name deployed in oc4j.
    This jndi.properties file is in the classpath.
    My client code is :
    Server server = null; //interface
    ServerHome testSessionBean; //implementation of methods in Server interface
    try {
    Context ctx = new InitialContext();
    Object objref = ctx.lookup("EJBServer"); //JNDI name
    Object obj = PortableRemoteObject.narrow(objref, ServerHome.class);
    testSessionBean = (ServerHome) PortableRemoteObject.narrow(objref,
                             ServerHome.class);
    server = testSessionBean.create();
    } catch (...) {  }
    When i set the properties and do a look up
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
              "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");//oc4jadmin
    env.put(Context.SECURITY_CREDENTIALS, "oc4jadmin");
    env.put(Context.PROVIDER_URL,
         "ormi://<localhost>:12401/OC4JEJB");           
    InitialContext ctx = new InitialContext(env);
    it works perfectly fine.
    But when i use the jndi.properties it gives 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(Unknown Source)
         at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
         at javax.naming.InitialContext.lookup(Unknown Source)
         at client.ORION_EJB_Util.getServer(ORION_EJB_Util.java:203)
         at client.ORION_EJB_Util.<init>(ORION_EJB_Util.java:90)
         at client.TestClient.main(TestClient.java:26)
    client.exception.EJBUtilException
         at client.ORION_EJB_Util.getServer(ORION_EJB_Util.java:248)
         at client.ORION_EJB_Util.<init>(ORION_EJB_Util.java:90)
         at client.TestClient.main(TestClient.java:26)
    Invoking the server
    Inside getServer method
    Obtained Initial Context javax.naming.InitialContext@422ede
    Exception null
    I've tried placing the jndi.properties in j2ee/home/applib too. Where shud i place this jndi.properties and invoke the EJB?
    Could anyone help resolve this issue?
    Thanks in advance,
    Sprightee

    Try add your jndi.properties to your CLASSPATH.
    See this doc for more details of RMI.
    http://download-east.oracle.com/docs/cd/B31017_01/web.1013/b28958/rmi.htm#i1084792

  • Jndi properties in InitialContext : java.naming.factory.initial

    I am trying to lookup a bean with the following code. I get a NamingException on line 9 when the jndi properties are referenced. The exception message that I receive is "Cannot instantiate class: org.jnp.interfaces.NamingContextFactory". Does anyone know what the problem may be?
    1 // Set the jndi properties
    2 Properties jndiProps = new Properties();
    3 jndiProps.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
    4 jndiProps.setProperty("java.naming.provider.url", "localhost:1099");
    5 jndiProps.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
    6 try
    7 {
    8 Context ctx = new InitialContext(jndiProps);
    9 homeMyBean = (LocalMetricResultsHome) ctx.lookup("MyBean");5
    10 }
    11 catch (NamingException e)
    12 {
    13 // handle namingexception
    14 }

    It means the .jar file containing that class is not in your ClassPath. Try putting jnp-client.jar into your ClassPath.

  • Cannot specify non-default KDC port using system property krb5.kdc

    For testing / debug it's very useful to be able to run the KDC on a non-default port. This can be specified in Kerberos config file by appending the port number to the KDC host name, delimited with a colon.
    The java.security.krb5.kdc property can be used to locate the KDC - Unfortunately in Config.java in the sun.security.krb5 package, when parsing the property the colon is used as a delimiter for multiple KDCs. The config object String.replace()s the colons with space chars. Then the KrbKdcReq.java module, when testing for a non-default port in the KDC string from the config object, looks for the colon delimiter - but this has been zapped. So it seems that it's not possible to specify the non-default port via the property.
    The workaround is to use the config file approach instead, but this is inconvenient and limits programmability (especially when using configuration reload) - Is there a prospect that the config parser might be adjusted backwards compatible (say, to recognise a double colon or an escape char) to fix this?
    regards
    Ted Hayes

    Greetings
    I'm sorry to dig this thread up, but I could really use some help concerning this. I need to set up ApacheDS in a remote machine, but I'm not allowed to have root access to it, which means I can't make ApacheDS to run its KDC at port 88. Port 88 is a reserved port in *nix machines, so I can't make ApacheDS to list on that port without admin previledges.
    On the other hand, I already have a client/server demo program that can connect to a kdc (which can be found at http://thejavamonkey.blogspot.com/2008/04/clientserver-hello-world-in-kerberos.html), but I don't know how to set it up to run on any other port. I noticed that teddy_salad mentioned something about a config file approach, but I don't know what he is referring to.
    At this point I should mention that its my first time trying to use JGSS, but I'm also running out of time to make the ApacheDS work. I'm supposed to make some benchmarking tests for my masters degree dissertation, and the deadline is approaching :\
    I only need to know how to change hte default port to which that application connects to. Thanks in advance to anyone who replies to this.

  • Preventing Child Class Dependency when using conditional disable to specify Class in Development Environment

    Hello
    I am developing an application which I would like to execute on both normal and real-time systems using LabVIEW Proffesional Development System 2012 SP1
    To control how the application interacts with the user, I have created a class which defines the type of user-interface behaviour which should allow me to have nice dialog boxes when the system is executing on a windows machine and have no dialog boxes (or other non-Real-Time friendly code) when operating on a real-time target.
    The parent class is the code that is suitable for Real-Time and the child class is the one with dialog boxes.
    To control which class is loaded, I have a conditional disable structure. This will work fine when the application is built into a executable or real-time executable but the problem arises when I want to use the code during development on the real-time target.
    I find that with the application under a real-time target (RT PXI), the correct conditional-disable case is activated so the parent class is used, but the child classes are also listed under the dependancies - I pressume this is because they exist on the block diagram in the disabled case of the conditional disable diagram.
    This means that I cannot deploy the code to the Real-Time target as it is unhappy with the child class code - even though this will never be run.
    To save posting my real project, I have created an example with a Parent and Child class and a Conditional Disable Flag called "CLASS" to demonstrate the problem.
    If you run Test.vi you will see that the Child class still gets locked (i.e. is a dependancy) during execution even though it is not called.
    So - basically my question is: Is there anything I can do about this or will I just have to do-away with the conditional disable and just put the correct Class constant on the block diagram during testing?
    Thanks in advance
    John.
    Solved!
    Go to Solution.
    Attachments:
    Example Proj.zip ‏18 KB

    I feel your pain.  I ran into a similar problem a short time back.
    Apparently Official NI stance is that you need to put a conditional Disable structure IN EVERY ONE OF YOUR CLASS VIs.  In the Windows VIs, you simply have an empty conditional disable case with the windows code in an appropriate other case and vise versa on the RT.
    I too would much prefer the method you describe...
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

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

  • 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

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

Maybe you are looking for

  • Delivery type determination in case of returns to vendor without return PO

    Hello Gurus, When we create Return PO, and when we want to created delivery for this PO , we assign delivery type RL to the PO in SPRO. Now when I return the material thorugh MIGO (without return PO) with delivery check box active, system determines

  • Content viewer for pc download?

    I'm wanting to share a folio I've created for a client. They need to download it on their pc laptop but will need Content Viewer. I'm struggling to find it as a download? I can find it for Mac, Ipad, Android, Iphone etc. Can anyone help me find a pc

  • Dispatcher running but not connecd to message server

    hi.. iam trying to start my server, in process list iam getting dispatcher  is not getting start.first iam getting 'DISPATCHER IS RUNNING BUT NOT CONNETED TO MESSAGE SERVER' it is in yellow color, after some time , it is changing to green color but t

  • Troubles with .pkg files

    Hi there. I am trying to install Adobe Reader 9, but it seems I can't install any app within a .pkg file. When I double click the file, Apple Installer appears on the dock... and that's all. No installation window, no error message, nothing. I have t

  • How to install a root certificate of private CA for SSL initiation in ACE 4710 ?

    Hello ACE Gurus, We have to deploy end-to-end SSL for one of our application, but of course we won't be buying Entrust or other big name certificates for each web server :  we want to use self-issued certs signed by our private CA.The topology looks