<!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;">
    JNDI Lookup fails in JBoss AS 7 [java.naming.CommunicationException]
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/kousikraj">Kousik Rajendran</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/637726#637726">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,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have successfully created and deployed a datasource in my jboss as 7. I tested with jboss CLI and I got the success message like </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">[standalone@localhost:9999 /] /subsystem=datasources/data-source=java\:jboss\/datasources\/Test:test-connection-in-pool
{
&#160;&#160;&#160; "outcome" =&gt; "success",
&#160;&#160;&#160; "result" =&gt; [true]
}
</code></pre><p>But, when I try to access the same data source using the java code</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-family: 'courier new', courier;"> </span></p><pre class="jive-pre"><code class="jive-code jive-java">DataSource ds = <font color="navy"><b>null</b></font>;
Context ctx = <font color="navy"><b>null</b></font>;
String strDSName = <font color="red">"java:jboss/datasources/Test"</font>;
<font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160; Properties env = <font color="navy"><b>new</b></font> Properties();
&#160;&#160;&#160; env.setProperty(<font color="red">"java.naming.factory.initial"</font>, <font color="red">"org.jnp.interfaces.NamingContextFactory"</font>);
&#160;&#160;&#160; env.setProperty(<font color="red">"java.naming.factory.url.pkgs"</font>, <font color="red">"org.jboss.naming:org.jnp.interfaces"</font>);
&#160;&#160;&#160; env.setProperty(<font color="red">"java.naming.provider.url"</font>, <font color="red">"jnp://localhost:1099"</font>);
&#160;&#160;&#160; ctx = <font color="navy"><b>new</b></font> InitialContext(env);
&#160;&#160;&#160; ds = (javax.sql.DataSource) ctx.lookup(strDSName);
<font color="navy">}</font> <font color="navy"><b>catch</b></font> (Exception e) <font color="navy">{</font>
&#160;&#160;&#160; e.printStackTrace();
<font color="navy">}</font>
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am getting this error</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1302)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1382)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at javax.naming.InitialContext.lookup(InitialContext.java:392)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at c&#160;&#160;&#160;&#160; om.aayuwiz.clinic.tests.KousikTests.main(KousikTests.java:42)
Caused by: java.net.SocketTimeoutException: Receive timed out
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.net.PlainDatagramSocketImpl.receive0(Native Method)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at java.net.DatagramSocket.receive(DatagramSocket.java:712)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1272)
&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;... 5 more
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have not done any changes to my <strong>standalone.xml</strong> under <strong>\JBOSS_HOME\standalone\configuration</strong> directory.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Can someone help me out in this regards please. I have tried many forum threads and lot of blogs in and out of jboss.org sites. I am in a very critical situation to fix this issue ASAP.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks in Advance. Please let me know if you need more information.</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/637726#637726">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>