Haitham Safi [https://community.jboss.org/people/haithamnor] created the discussion
"Hi there" To view the discussion, visit: https://community.jboss.org/message/787525#787525 -------------------------------------------------------------- i'm new with JMS and i wrote the folloing example import java.io.*; import javax.jms.*; import javax.naming.Context; import javax.naming.InitialContext; public class Qsender { public static void main(String[] args) { new Qsender().send(); } public void send() { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); try { //Prompt for JNDI names System.out.println("Enter QueueConnectionFactory name:"); String factoryName = reader.readLine(); System.out.println("Enter Queue name:"); String queueName = reader.readLine(); //Look up administered objects InitialContext initContext = new InitialContext(); QueueConnectionFactory factory =(QueueConnectionFactory) initContext.lookup(factoryName); Queue queue = (Queue) initContext.lookup(queueName); initContext.close(); //Create JMS objects QueueConnection connection = factory.createQueueConnection(); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); QueueSender sender = session.createSender(queue); //Send messages String messageText = null; while (true) { System.out.println("Enter message to send or 'quit':"); messageText = reader.readLine(); if ("quit".equals(messageText)) break; TextMessage message = session.createTextMessage(messageText); sender.send(message); } //Exit System.out.println("Exiting..."); reader.close(); connection.close(); System.out.println("Goodbye!"); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } } i have Jboss v5 App server but at execut the code i recived this 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 Qsender.send(Qsender.java:32) at Qsender.main(Qsender.java:13) Some one can help me thx -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/787525#787525] Start a new discussion in JNDI and Naming at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
