<!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;">
    org.jboss.ejb3.annotation.RemoteBinding on JBOSS4
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/twolak">Tomasz Wolak</a> in <i>EJB3</i> - <a href="http://community.jboss.org/message/599934#599934">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>I have been tasked with wipping out a small app using ejb3 and jsf on jboss. Having jboss 5 already up and running I coded it there first.&#160; The app is very simple: entity Bean together with Manager bean with local/remote interfaces.&#160; I used the org.jboss.ejb3.annotation.RemoteBinding to map my custom name of the manager bean.&#160; The manager bean was being accessed from JSF backing bean using direct injection.&#160; This setup worked great on Jboss5.&#160; However we currently use JBoss4 in production but I figured this will be a non issue just put the ear file in the Jboss4.x and off we go.&#160; Well not quite.&#160; I was aware of the fact that DI does not work in non container manager beans (such as JSF bean) so I used direct context lookup to account for this fact.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here is stub for my manager:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import <strong>org.jboss.ejb3.annotation</strong>.LocalBinding;</p><p>import <strong>org.jboss.ejb3.annotation</strong>.RemoteBinding;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@RemoteBinding(jndiBinding = "FakeInvManager/remote")</p><p>@LocalBinding(jndiBinding = "FakeInvManager/local")</p><p>public class FakeInvManagerBean implements FakeInvManagerRemote,</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; FakeInvManagerLocal {</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>here is part of JSF where I look up the manager:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context envCtx = new InitialContext();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; invMgr = (FakeInvManagerLocal) envCtx</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .lookup("FakeInvManager/local");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (NamingException ne) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; log.error("Cannot create instance of the FakeInvManager",</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ne);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw ne;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>This is where it is getting intresting: I deployed this on JBOSS 4 and I had a failure ("FakeInvManager/local" not bound).&#160; Looked in the JNDI tree to find that the bean is not getting registered under "FakeInvManager/local".&#160; I could only use the global name "<strong>earFileName/BeanName/local</strong>".&#160; This meant that @LocalBinding is not working.&#160; Did a bit digging and found out that @LocalBinding implmentation changed from JBoss4 to JBoss5 from</p><p>org.jboss.annotation.ejb.LocalBinding;</p><p>to</p><p>org.jboss.ejb3.annotation.LocalBinding;</p><p>So I updated my manager to use JBoss4 (org.jboss.annotation.ejb.LocalBinding) implementation and everything went to normal i.e. I could look up the resource using the LocalBinding specified jndiBiding name (i.e. FakeInvManager/local").</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You'd think that the story is over...problem solved?</p><p>Well here is my dilema: Originally I have deployed my manager Bean to JBOSS4.x using JBOSS5.x specific import:<strong>org.jboss.ejb3.annotation.</strong>LocalBinding;</p><p>Yet there is NO trace of that package on Jboss4.x so how come I did not explode with "ClassNotFound" or something to this account?&#160; In fact once I changed my lookup to the global JNDI biding the whole thing worked where I think it shouldn't?&#160; </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/599934#599934">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>