<!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;">
    How to connect to remote queue?
</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/799447#799447">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi<br/>i'm trying to run JMS Java Application(Jboss4.2.3) on Remote server that grant permission to me so I wrote the following code:</p><p>&#160;&#160;&#160; package test;<br/>&#160;&#160;&#160; import java.io.IOException;<br/>&#160;&#160;&#160; import java.util.Properties;<br/>&#160;&#160;&#160; import javax.jms.DeliveryMode;<br/>&#160;&#160;&#160; import javax.jms.JMSException;<br/>&#160;&#160;&#160; import javax.jms.MapMessage;<br/>&#160;&#160;&#160; import javax.jms.Queue;<br/>&#160;&#160;&#160; import javax.jms.QueueConnection;<br/>&#160;&#160;&#160; import javax.jms.QueueConnectionFactory;<br/>&#160;&#160;&#160; import javax.jms.QueueSender;<br/>&#160;&#160;&#160; import javax.jms.QueueSession;<br/>&#160;&#160;&#160; import javax.jms.TextMessage;<br/>&#160;&#160;&#160; import javax.naming.Context;<br/>&#160;&#160;&#160; import javax.naming.InitialContext;<br/>&#160;&#160;&#160; import javax.naming.NamingException;<br/>&#160;&#160;&#160; import java.net.UnknownHostException;<br/>&#160;&#160;&#160; public class QueueProduce {<br/>&#160;&#160;&#160; public static void main(String[] args)throws JMSException,NamingException<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt; Begain Producer ..... &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context =QueueProduce.getInitialContext();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; QueueConnectionFactory queueconnectionfactory = (QueueConnectionFactory) context.lookup&#160;&#160; ("ConnectionFactory");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Queue queue =(Queue) context.lookup("queue/D");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queueConnection queueconnection = queueconnectionfactory.createQueueConnection("un","pwd");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; QueueSession queuesession =&#160; queueconnection.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queueconnection.start();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; QueueProduce queueproducer =new QueueProduce();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queueproducer.sendmessage(".this message send for from queue testing " ,queuesession,queue);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;Testing Message has been sent &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");<br/>&#160;&#160;&#160; }<br/>&#160;&#160;&#160; catch (JMSException e)<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();<br/>&#160;&#160;&#160; }<br/>&#160;&#160;&#160; }<br/>&#160; this method to send message:</p><p>&#160;&#160;&#160; public void sendmessage (String text,QueueSession queuesession ,Queue queue)throws JMSException<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; QueueSender queuesender = queuesession.createSender(queue);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TextMessage textmessage = queuesession.createTextMessage(text);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queuesender.setDeliveryMode(DeliveryMode.PERSISTENT);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queuesender.send(textmessage&#160; );<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; queuesender.close();<br/>&#160;&#160;&#160; }<br/>&#160;&#160;&#160; public static Context getInitialContext () throws JMSException,NamingException<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Properties prop = new Properties();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.setProperty("java.naming.provider.url", "jnp://192.150.50.20:1099");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context = new InitialContext(prop);<br/>&#160;&#160;&#160; return context;<br/>&#160;&#160;&#160; }<br/>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> But I got this exception:<br/>&#160; Exception in thread "main" javax.naming.communicationException<br/>&#160; [root java.lang.ClassNotfoundException:org.jboss.jms.client.jbossconnection<br/>&#160; &lt;no security manager:RMI class loader disable&gt;]<br/>&#160; at org.jnp.interfaces.NamingContext.lookup<br/>&#160; coused by: java.lang.ClassNotFoundException: org.jboss.jms.client.jbossconnectionFactory&lt;no security manager:RMI class loader disable&gt;<br/>&#160; at sun.rmi,security.loaderhandler.loadclass<br/>&#160; at java.io.ObjectInputStream.readnoproxydesc<br/>&#160; at java.io.ObjectInputStream.readclassDesc<br/>&#160; at org.jnp.interfacesmarshalledvaluepair.get</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So any help?</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/799447#799447">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>