Hi All, 

I am trying for a simple Queue Sender and receiver JBoss messaging program. I 
am using JBoss-5.0.0 G.A. application server. I am getting the following 
exception while running the program. 


]JNDI lookup failed: javax.naming.NameNotFoundException: QueueConnectionFactory 
not bound

public static void main(String[] args) {
  |             // TODO Auto-generated method stub
  |             String queueName = null;
  |             Context jndiContext = null;
  |             QueueConnectionFactory queueConnectionFactory = null;
  |             QueueConnection queueConnection = null;
  |             QueueSession queueSession = null;
  |             Queue queue = null;
  |             QueueSender queueSender = null;
  |             TextMessage message = null;
  | 
  |             final int NUM_MSGS;
  | 
  |             if ((args.length < 1) || (args.length > 2)) {
  |                     System.out.println("Usage: java SimpleQueueSender "
  |                                     + "<queue-name> 
[<number-of-messages>]");
  |                     System.exit(1);
  |             }
  | 
  |             queueName = new String(args[0]);
  |             System.out.println("Queue Name Is : " + queueName);
  | 
  |             if (args.length == 2) {
  |                     NUM_MSGS = (new Integer(args[1])).intValue();
  |             } else {
  |                     NUM_MSGS = 1;
  |             }
  |             
  |             Properties props = new Properties();
  |             props.put("java.naming.factory.initial", 
"org.jnp.interfaces.NamingContextFactory");
  |             props.put("java.naming.factory.url.pkgs", 
"org.jboss.naming:org.jnp.interfaces");
  |             props.put("java.naming.provider.url", "localhost:1099");
  |             
  |             try {
  |                     jndiContext = new InitialContext(props);
  |             } catch (NamingException e) {
  |                     System.out.println("Could not create JNDI " + "context: 
"
  |                                     + e.toString());
  |                     System.exit(1);
  |             }
  |             
  |             try {
  |                     queueConnectionFactory = (QueueConnectionFactory) 
jndiContext
  |                     .lookup("QueueConnectionFactory");
  |                     queue = (Queue) jndiContext.lookup("queue/"+queueName);
  |             } catch (NamingException e) {
  |                     System.out.println("JNDI lookup failed: " + 
e.toString());
  |                     System.exit(1);
  |             }
  | 
  |             try {
  |                     queueConnection = 
queueConnectionFactory.createQueueConnection();
  |                     queueSession = queueConnection.createQueueSession(false,
  |                                     Session.AUTO_ACKNOWLEDGE);
  |                     queueSender = queueSession.createSender(queue);
  |                     message = queueSession.createTextMessage();
  | 
  |                     for (int i = 0; i < NUM_MSGS; i++) {
  |                             message.setText("This is message " + (i + 1));
  |                             System.out.println("Sending Message: " + 
message.getText());
  |                             queueSender.send(message);
  |                     }
  |                     queueSender.send(queueSession.createMessage());
  |             } catch (JMSException e) {
  |                     System.out.println("Exception occurred: " + 
e.toString());
  |             } finally {
  |                     if (queueConnection != null) {
  |                             try {
  |                                     queueConnection.close();
  |                             } catch (JMSException e) {
  |                                     System.out.println("Exception occurred: 
" + e.toString());
  |                             }
  |                     }
  |             }
  | 
  |     }


Dosen't JBoss-5.0.0. G.A. application server gives a default 
QueueConnectionFactory and a default TopicConnectionFactory as in JBoss-4.2.2 
GA.? Do we have to create a QueueConnectionFactory and TopicConnectionFactory 
by ourselves. If yes, then where do we create it - in 
jboss-5.0.0.GA\server\default\deploy\messaging\destinations-service.xml. 

Please do guide me as I am not able to proceed further. Thanks in advance. 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4209338#4209338

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4209338
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to