<!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;">
    Accessing secure EJBs from remote server
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/rbalaji">Balaji Katika</a> in <i>EJB3</i> - <a href="http://community.jboss.org/message/634536#634536">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've been trying to invoke EJBs (secured) deployed on a remote server (say A) from my local EAR. Both EARs are deployed and running on JBoss 5.1</p><p>To put it in simple words,... Access secured EJB from local EJB.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please help me get rid of this exception.. Also, suggest me alternate methods of invocation (like using org.jboss.naming.HttpNamingContextFactory). </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've been getting the below exception</p><p><span style="color: windowtext;">&#8216;</span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: windowtext;">Caused by: </span><span style="color: windowtext; font-size: 10.0pt; text-decoration: underline; font-family: 'Courier New \;">org.jboss.aop.NotFoundInDispatcherException</span><span style="font-size: 10.0pt; font-family: 'Courier New \; color: windowtext;">: Object with oid: ProxyFactory/onaro/</span><span style="font-size: 10.0pt; font-family: 'Courier New';">SummarySession</span><span style="font-size: 10.0pt; font-family: 'Courier New \; color: windowtext;">EJB/</span><span style="font-size: 10pt; font-family: 'Courier New';">SummarySession</span><span style="font-size: 10.0pt; font-family: 'Courier New \; color: windowtext;"> was not found in the Dispatcher&rsquo;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 10.0pt; font-family: 'Courier New \; color: windowtext;">Code snippet below...<br/></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> SummarySession ss = </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">null</strong>;</p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> Properties env=</span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">new</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> Properties();</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> env.setProperty(</span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"java.naming.factory.initial"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">, </span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"org.jnp.interfaces.NamingContextFactory"</span><span style="font-size: 10.0pt; font-family: 'Courier New';"> );</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> env.setProperty(</span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"java.naming.factory.url.pkgs"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">, </span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"org.jboss.naming:org.jnp.interfaces"</span><span style="font-size: 10.0pt; font-family: 'Courier New';"> );</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> env.setProperty(</span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"java.naming.provider.url"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">, </span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"10.10.10.1:1099"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">); // IP of the SS Server (Remote machine)</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> env.put(Context.</span><em style="color: #0000c0; font-size: 10.0pt; font-family: 'Courier New';">SECURITY_PRINCIPAL</em><span style="font-size: 10.0pt; font-family: 'Courier New';">, </span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"admin"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">);</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> env.put(Context.</span><em style="color: #0000c0; font-size: 10.0pt; font-family: 'Courier New';">SECURITY_CREDENTIALS</em><span style="font-size: 10.0pt; font-family: 'Courier New';">, </span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"admin123"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';"> try</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> {</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">&#160; context = </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">new</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> <span style="background: silver;">InitialContext</span>(env);</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> } </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">catch</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> (NamingException e) {</span></p><p> <span style="font-size: 10.0pt; font-family: 'Courier New'; color: #3f7f5f;">// </span><strong style="color: #7f9fbf; font-size: 10.0pt; font-family: 'Courier New';">TODO</strong><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #3f7f5f;"> Auto-generated catch block</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">&#160; e.printStackTrace();</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> }</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> System.</span><em style="color: #0000c0; font-size: 10.0pt; font-family: 'Courier New';">out</em><span style="font-size: 10.0pt; font-family: 'Courier New';">.println(</span><span style="font-size: 10.0pt; font-family: 'Courier New'; color: #2a00ff;">"Inititial context created"</span><span style="font-size: 10.0pt; font-family: 'Courier New';">);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> <strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">try</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> {</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> ss = (SummarySession) context.lookup(SummarySession.</span><em style="color: #0000c0; font-size: 10.0pt; font-family: 'Courier New';">JNDI_NAME</em><span style="font-size: 10.0pt; font-family: 'Courier New';">); //the JNDI binding on the remote server<br/></span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> } </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">catch</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> (NamingException e) {</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> e.printStackTrace();</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> }</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> String cbn = </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">null</strong>;</p><p> <strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">try</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> {</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> cbn = ss.getCodeBuildNumber();</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> } </span><strong style="color: #7f0055; font-size: 10.0pt; font-family: 'Courier New';">catch</strong><span style="font-size: 10.0pt; font-family: 'Courier New';"> (SummaryException e1) {</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> e1.printStackTrace();</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';"> }</span></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/634536#634536">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>