<!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;">
    [JBoss 6.0.0M3] Cannot use @EJB on jax-ws handler and webservice port
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/O.Bergner">Olaf Bergner</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/556964#556964">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 tried to debug the issue, alas without much luck. What puzzles me though when looking at the method</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>protected String findWithin(DeploymentUnit du, DeploymentUnit excludeChild, EjbReference reference)<br/>&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160; String jndiName = find(du, reference);<br/>&#160;&#160;&#160;&#160;&#160; if(jndiName != null)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return jndiName;<br/>&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160; List&lt;DeploymentUnit&gt; children = du.getChildren();<br/>&#160;&#160;&#160;&#160;&#160; if(children != null)<br/>&#160;&#160;&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for(DeploymentUnit child : children)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // already searched that one<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(child == excludeChild)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; continue;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiName = findWithin(child, null, reference);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(jndiName != null)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return jndiName;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160; DeploymentUnit parent = du.getParent();<br/>&#160;&#160;&#160;&#160;&#160; if(parent != null)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return findWithin(parent, du, reference);<br/>&#160;&#160;&#160;&#160;&#160; return null;<br/>&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>is the question how it is supposed to work. Let's say we have</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>app.ear</p><p>&#160;&#160; |</p><p>&#160;&#160; -- ejb1.jar</p><p>&#160;&#160; |</p><p>&#160;&#160; -- ejb2.jar</p><p>&#160;&#160; |</p><p>&#160;&#160; -- ejb3.jar</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>ejb1.jar contains an artifact referencing a session bean that resides in ejb3.jar. If I understand the code above correctly - and this is a BIG if - what will happen is what follows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1. We start searching in ejb1.jar.</p><p>2. We try to find the referenced session bean in ejb1.jar itself. This fails.</p><p>3. We try to find the referenced session bean in one of ejb1.jar's children. There are no such children, so this fails, too.</p><p>4. We try to find the referenced session bean in ejb1.jar's parent, i.e. app.ear, telling this parent to exclude the current deployment unit, i.e. ejb1.jar.</p><p>5. We try to find - since app.ear itself does not contain any session beans - the referenced session bean in the list of app.ear's children minus ejb1.jar, i.e. [ejb2.jar, ejb3.jar].</p><p>6. Since ejb2.jar does not contain the referenced session bean either, we end up repeating steps 2 - 4, with ejb1.jar replaced by ejb2.jar.</p><p>7. We try to find the referenced session bean in the list of app.ear's children minus ejb2.jar, i.e. [ejb1.jar,ejb3.jar]. And now we are in trouble, since ...</p><p>8. We repeat steps 1 - 7 until we run out of stack space.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Could it be that the above algorithm only succeeds if</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1. the number of children to app.ear is not greater than two OR</p><p>2. the referenced session bean resides in the same deployment unit as the referencing artifact OR</p><p>3. the referenced session bean resides in the deployment unit immediately following - from app.ear's perspective - the deployment unit containing the referencing artifact (ejb2.jar in our example)?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>At least this seems to be implied by a casual analysis of the code above. But then again, I may be wrong and it's rather a problem in my code.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Cheers,</p><p>Olaf</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/556964#556964">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>