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

Apache's JIRA Issue Tracker | Saurabh Thapar | 2 years ago
  1. 0

    [AMQ-5355] Problem in making JNDI connection - Apachive ActiveMQ 5.10.0 - ASF JIRA

    apache.org | 12 months ago
    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
  2. 0

    I am not create a jndi connection from my java program despite specifying all the connection parameters in the jndi.properties and activemq.xml: I have done the configuration of jndi.properties file as follows: java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory java.naming.provider.url=tcp://localhost:61616 java.naming.security.principal=system java.naming.security.credentials=manager # use the following property to configure the default connector java.naming.provider.url = vm://localhost #connectionFactoryNames = TopicCF #topic.topic1 = jms.topic1 connectionFactoryNames = QueueCF queue.LoanRequestQ = jms.LoanRequestQ queue.LoanResponseQ = jms.LoanResponseQ Added the following in activemq.xml: <destinations> <! -- topic name="topic1" physicalName="jms.topic1" / --> <queue name="LoanRequestQ" physicalName="jms.LoanRequestQ" /> <queue name="LoanResponseQ" physicalName="jms.LoanResponseQ" /> </destinations> Now, in my Java program, I have the QLender class and I have the following statements: Context ctx = new InitialContext(); ConnectionFactory qCFactory = (ConnectionFactory)ctx.lookup("QueueCF"); I get 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:662) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344) at javax.naming.InitialContext.lookup(InitialContext.java:411) at ch04.p2p.QLender.<init>(QLender.java:34) at ch04.p2p.QLender.main(QLender.java:134) Further I enhanced the program to make a set environment parameters: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "http://localhost:61616"); env.put(Context.SECURITY_PRINCIPAL, "system"); env.put(Context.SECURITY_CREDENTIALS, "manager"); Context ctx = new InitialContext(env); ConnectionFactory qCFactory = (ConnectionFactory)ctx.lookup("QueueCF"); On compiling I get the following error: javax.naming.NameNotFoundException: QueueCF at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235) at javax.naming.InitialContext.lookup(InitialContext.java:411) at ch04.p2p.QLender.<init>(QLender.java:32) at ch04.p2p.QLender.main(QLender.java:132)

    Apache's JIRA Issue Tracker | 2 years ago | Saurabh Thapar
    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
  3. 0

    I am not create a jndi connection from my java program despite specifying all the connection parameters in the jndi.properties and activemq.xml: I have done the configuration of jndi.properties file as follows: java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory java.naming.provider.url=tcp://localhost:61616 java.naming.security.principal=system java.naming.security.credentials=manager # use the following property to configure the default connector java.naming.provider.url = vm://localhost #connectionFactoryNames = TopicCF #topic.topic1 = jms.topic1 connectionFactoryNames = QueueCF queue.LoanRequestQ = jms.LoanRequestQ queue.LoanResponseQ = jms.LoanResponseQ Added the following in activemq.xml: <destinations> <! -- topic name="topic1" physicalName="jms.topic1" / --> <queue name="LoanRequestQ" physicalName="jms.LoanRequestQ" /> <queue name="LoanResponseQ" physicalName="jms.LoanResponseQ" /> </destinations> Now, in my Java program, I have the QLender class and I have the following statements: Context ctx = new InitialContext(); ConnectionFactory qCFactory = (ConnectionFactory)ctx.lookup("QueueCF"); I get 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:662) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344) at javax.naming.InitialContext.lookup(InitialContext.java:411) at ch04.p2p.QLender.<init>(QLender.java:34) at ch04.p2p.QLender.main(QLender.java:134) Further I enhanced the program to make a set environment parameters: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "http://localhost:61616"); env.put(Context.SECURITY_PRINCIPAL, "system"); env.put(Context.SECURITY_CREDENTIALS, "manager"); Context ctx = new InitialContext(env); ConnectionFactory qCFactory = (ConnectionFactory)ctx.lookup("QueueCF"); On compiling I get the following error: javax.naming.NameNotFoundException: QueueCF at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235) at javax.naming.InitialContext.lookup(InitialContext.java:411) at ch04.p2p.QLender.<init>(QLender.java:32) at ch04.p2p.QLender.main(QLender.java:132)

    Apache's JIRA Issue Tracker | 2 years ago | Saurabh Thapar
    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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    jta-data-source breaks generation

    GitHub | 2 years ago | rkorn86
    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
  6. 0

    Configuration JUnit 4 in Spring + eclipse

    Stack Overflow | 3 years ago | kiduxa
    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

  1. Kawada 18 times, last 6 months ago
29 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. 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()
  2. Java RT
    InitialContext.lookup
    1. javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
    2. javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
    3. javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
    4. javax.naming.InitialContext.lookup(InitialContext.java:411)
    4 frames
  3. ch04.p2p
    QLender.main
    1. ch04.p2p.QLender.<init>(QLender.java:34)
    2. ch04.p2p.QLender.main(QLender.java:134)
    2 frames