<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
<table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
<h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
<!-- To have a header image/logo replace the name below with your img tag -->
<!-- Email clients will render the images when the message is read so any image -->
<!-- must be made available on a public server, so that all recipients can load the image. -->
<a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Hi there
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/haithamnor">Haitham Safi</a> in <i>JNDI and Naming</i> - <a href="https://community.jboss.org/message/787525#787525">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>i'm new with JMS and i wrote the folloing example</p><p>import java.io.*;</p><p>  import javax.jms.*;</p><p>import javax.naming.Context;</p><p>import javax.naming.InitialContext;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> public class Qsender </p><p>{</p><p>public static void main(String[] args) {</p><p>          new Qsender().send();</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public void send() {</p><p>          BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));</p><p>try {</p><p>  </p><p>//Prompt for JNDI names</p><p>    </p><p>          System.out.println("Enter QueueConnectionFactory name:");</p><p>          String factoryName = reader.readLine();</p><p>          System.out.println("Enter Queue name:");</p><p>          String queueName = reader.readLine();</p><p>  </p><p>          //Look up administered objects</p><p>          InitialContext initContext = new InitialContext();</p><p>  </p><p>          QueueConnectionFactory factory =(QueueConnectionFactory) initContext.lookup(factoryName);</p><p>          Queue queue = (Queue) initContext.lookup(queueName);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          initContext.close();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>           //Create JMS objects</p><p>          QueueConnection connection = factory.createQueueConnection();</p><p>          QueueSession session =           connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);</p><p>          QueueSender sender = session.createSender(queue);</p><p>//Send messages</p><p>          String messageText = null;</p><p>while (true) {</p><p>          System.out.println("Enter message to send or 'quit':");</p><p>          messageText = reader.readLine();</p><p>          if ("quit".equals(messageText))</p><p>          break;</p><p>          TextMessage message = session.createTextMessage(messageText);</p><p>          sender.send(message);</p><p>}</p><p>//Exit</p><p>System.out.println("Exiting...");</p><p>          reader.close();</p><p>          connection.close();</p><p>          System.out.println("Goodbye!");</p><p>} catch (Exception e) {</p><p>          e.printStackTrace();</p><p>          System.exit(1);</p><p>}</p><p>}</p><p>}</p><p>i have Jboss v5 App server but at execut the code i recived this error</p><p>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</p><p>          at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)</p><p>          at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)</p><p>          at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)</p><p>          at javax.naming.InitialContext.lookup(Unknown Source)</p><p>          at Qsender.send(Qsender.java:32)</p><p>          at Qsender.main(Qsender.java:13)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Some one can help me</p><p>thx</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/787525#787525">going to Community</a></p>
<p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>