0 Replies Latest reply on Jun 19, 2013 3:24 PM by Niraj Patel

    javax.naming.NamingException: JBAS011843

    Niraj Patel Newbie

      I am calling the following code from a webpage, which is then sent to a controller, which then calls sender.java (code below). The program looks up a name and sends it to a JMS queue. I get the error listed at the bottom. Please help

      CODE:


      package com.java;

       

      import java.util.Properties;

       

      import javax.jms.DeliveryMode;

      import javax.jms.Queue;

      import javax.jms.QueueConnection;

      import javax.jms.QueueConnectionFactory;

      import javax.jms.QueueSender;

      import javax.jms.QueueSession;

      import javax.jms.Session;

      import javax.jms.TextMessage;

      import javax.naming.Context;

      import javax.naming.InitialContext;

       

       

      public class sender {

       

       

                public static void main(String[] args) throws Exception {

                          if(args[0].equals("first")){

                                    System.out.println("Finding "+args[1]+"'s first name!");

                          }

                          else{

                                    System.out.println("Finding "+args[1]+"'s last name!");

                          }

       

       

                          Properties env = new Properties();

                          env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");

                          env.put(Context.PROVIDER_URL, "tcp://localhost:61616");

                          env.put("queue.queue", "nameQueue");

       

       

                          // get the initial context

                          InitialContext ctx = new InitialContext(env);

       

       

                          // lookup the queue object

                          Queue queue = (Queue) ctx.lookup("queue");

       

       

                          // lookup the queue connection factory

                          QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup("QueueConnectionFactory");

                          // create a queue connection

                          QueueConnection queueConn = connFactory.createQueueConnection();

       

       

                          // create a queue session

                          QueueSession queueSession = queueConn.createQueueSession(false,Session.DUPS_OK_ACKNOWLEDGE);

       

       

                          // create a queue sender

                          QueueSender queueSender = queueSession.createSender(queue);

                          queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

       

       

                          // find input matching information

                          if(args[0].equals("first")){

                                    TextMessage message = queueSession.createTextMessage(names.getFirst(args[1]));

                                    queueSender.send(message);

                                    System.out.println("sent: " + message.getText());

                          }

       

       

                          else if(args[0].equals("last")){

                                    TextMessage message = queueSession.createTextMessage(names.getLast(args[1]));

                                    queueSender.send(message);

                                    System.out.println("sent: " + message.getText());

                          }

       

       

                          else{

                                    System.out.println("ERROR: ARGUMENT NOT FOUND");

                          }

       

       

       

       

                          // close connection

                          queueConn.close();

                }

       

       

      STACKTRACE:

       

      02:12:57,211 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.apache.activemq.jndi.ActiveMQInitialContextFactory from classloader ModuleClassLoader for Module "deployment.HelloWorld.war:main" from Service Module Loader

       

       

      02:12:57,213 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

       

       

      02:12:57,215 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)

       

       

      02:12:57,216 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)

       

       

      02:12:57,217 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.naming.InitialContext.init(InitialContext.java:242)

       

       

      02:12:57,218 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.naming.InitialContext.<init>(InitialContext.java:216)

       

       

      02:12:57,219 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at com.java.sender.main(sender.java:30)

       

       

      02:12:57,220 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at com.ControllerServlet.processRequest(ControllerServlet.java:60)

       

       

      02:12:57,221 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at com.ControllerServlet.doPost(ControllerServlet.java:36)

       

       

      02:12:57,222 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

       

       

      02:12:57,223 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

       

       

      02:12:57,224 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

       

       

      02:12:57,226 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

       

       

      02:12:57,227 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

       

       

      02:12:57,228 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

       

       

      02:12:57,229 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

       

       

      02:12:57,231 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

       

       

      02:12:57,232 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

       

       

      02:12:57,233 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

       

       

      02:12:57,234 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

       

       

      02:12:57,235 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

       

       

      02:12:57,236 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

       

       

      02:12:57,238 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

       

       

      02:12:57,239 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)           at java.lang.Thread.run(Thread.java:722)