<!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;">
    Problem with NotEligibleForDirectInvocationException
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/argonist">Manu Osten</a> in <i>EJB 3.0</i> - <a href="http://community.jboss.org/message/553803#553803">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>hmmm. I try to start without PortableRemoteObject.narrow. It is not working.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>error message:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">java.lang.ClassCastException: javax.naming.Reference cannot be cast to de.kirchedlau.ponteseam.sessions.ContentInterface

&#160;&#160;&#160; at de.kirchedlau.ponte.utils.sessions.EJBHandler.&lt;init&gt;(EJBHandler.java:26)

&#160;&#160;&#160; at de.kirchedlau.ponte.ejb.sessions.AccoutingBeanTest.setUpBeforeClass(AccoutingBeanTest.java:30)

&#160;&#160;&#160; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>ok with relevant EJB-Code:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>JUnit-Class (AccountingBeanTest):</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>static</b></font> EJBHandler ejbHandler;
&#160;&#160;&#160; <font color="navy"><b>static</b></font> AccountingInterface session;
&#160;&#160;&#160; <font color="navy"><b>static</b></font> AuthInterface authsession;
&#160;
&#160;
&#160;&#160;&#160; @BeforeClass
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>void</b></font> setUpBeforeClass() <font color="navy"><b>throws</b></font> Exception <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ejbHandler = <font color="navy"><b>new</b></font> EJBHandler();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; session = ejbHandler.accoutingsession;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;
&#160;&#160;&#160; @Test
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> testGetInstitutionTypeList() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font>(session == <font color="navy"><b>null</b></font>) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(<font color="red">"session is Null"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>else</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(<font color="red">"session is Not Null"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(session.toString());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Collection&lt;InstitutionType&gt; typeList = <font color="navy"><b>null</b></font>;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; typeList = session.getInstitutionTypeList();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (Exception e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Assert.assertNotNull(typeList);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Assert.assertEquals(typeList.size(), 7);
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>statless Bean (AccountingBean)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@Name(<font color="red">"accountingBean"</font>)
@Stateless
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> AccountingBean <font color="navy"><b>implements</b></font> AccountingInterface <font color="navy">{</font>
&#160;
&#160;&#160;&#160; @PersistenceContext(unitName = <font color="red">"PonteSeam"</font>)
&#160;&#160;&#160; <font color="navy"><b>private</b></font> EntityManager manager;
&#160;&#160;&#160; 
&#160;&#160;&#160; @Resource
&#160;&#160;&#160; SessionContext context;
&#160;
&#160;&#160;&#160; @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
&#160;&#160;&#160; @SuppressWarnings(<font color="red">"unchecked"</font>)
&#160;&#160;&#160; <font color="navy"><b>public</b></font> Collection&lt;InstitutionType&gt; getInstitutionTypeList() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>final</b></font> Query query = manager.createQuery(<font color="red">"from InstitutionType"</font>);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> (Collection&lt;InstitutionType&gt;) query.getResultList();
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Interface:</p><pre class="jive-pre"><code class="jive-code jive-java">@Remote
<font color="navy"><b>public</b></font> <font color="navy"><b>interface</b></font> AccountingInterface <font color="navy">{</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">// InstitutionTypes</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> Collection&lt;InstitutionType&gt; getInstitutionTypeList();
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Calling EJB-Beans from war-files with same EJBHandler is working, but from JUnit not.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Manu</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/553803#553803">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB 3.0 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>