<!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="http://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;">
Upgrade from 4.0.3 to 5.1.0
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/tauman%40yahoo.com">Steven Reich</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/555707#555707">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 am upgrading an application from JBoss 4.0.3 to 5.1.0 and have run into a problem when attempting to get an InitialContext object to connect to JNDI from another machine (or even the same machine when referred to by its name or IP rather than just localhost). Here is a test class which reproduces the problem:</p><p><span style="font-family: courier new,courier;"><br/></span></p><p><span style="color: #0000ff; font-family: courier new,courier; ">import java.util.Properties;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #0000ff; font-family: courier new,courier; ">import javax.naming.Context;<br/>import javax.naming.InitialContext;<br/>import javax.naming.NamingException;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #0000ff; font-family: courier new,courier; ">public class ContextTest {<br/>  public static void main(String[] args) {<br/>    String url = "localhost:1099";<br/>    // String url = "AHRC00WKG2208:1099";</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #0000ff; font-family: courier new,courier; ">    Properties p = new Properties();</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #0000ff; font-family: courier new,courier; ">    p.setProperty(Context.INITIAL_CONTEXT_FACTORY,<br/>        "org.jnp.interfaces.NamingContextFactory");<br/>    p.setProperty(Context.URL_PKG_PREFIXES,<br/>        "org.jboss.naming:org.jnp.interfaces");<br/>    p.setProperty(Context.PROVIDER_URL, url);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #0000ff; font-family: courier new,courier; ">    try {<br/>      InitialContext context = new InitialContext(p);<br/>      Object queue = context.lookup("queue/ImageUploadQueue");<br/>      System.out.println(queue);<br/>    }<br/>    catch (NamingException e) {<br/>      e.printStackTrace();<br/>    }<br/>  }<br/>}</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When I run this against JBoss 4.0.3, either url will work, but against 5.1.0, running against the non-localhost value causes the following exception:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #ff0000; font-family: courier new,courier; ">javax.naming.CommunicationException: Could not obtain connection to any of these urls: AHRC00WKG2208:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server AHRC00WKG2208/143.134.34.36:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server AHRC00WKG2208/143.134.34.36:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]<br/>    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)<br/>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)<br/>    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)<br/>    at javax.naming.InitialContext.lookup(InitialContext.java:392)<br/>    at com.tauman.test.ContextTest.main(ContextTest.java:24)<br/>Caused by: javax.naming.CommunicationException: Failed to connect to server AHRC00WKG2208/143.134.34.36:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server AHRC00WKG2208/143.134.34.36:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]<br/>    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:335)<br/>    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)<br/>    ... 4 more<br/>Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server AHRC00WKG2208/143.134.34.36:1099 [Root exception is java.net.ConnectException: Connection refused: connect]<br/>    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:305)<br/>    ... 5 more<br/>Caused by: java.net.ConnectException: Connection refused: connect<br/>    at java.net.PlainSocketImpl.socketConnect(Native Method)<br/>    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)<br/>    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)<br/>    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)<br/>    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)<br/>    at java.net.Socket.connect(Socket.java:519)<br/>    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)<br/>    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)<br/>    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:301)<br/>    ... 5 more</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm sure that there is something simple I am missing, but for the life of me, I can't figure it out. Any help would be greatly appreciated.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Steve</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/555707#555707">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="http://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>