<!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="https://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;">
    Real hard time with EJB3-- javax.naming.Reference instead of $Proxy
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/robert.piskule">robert allurent</a> in <i>EJB3</i> - <a href="https://community.jboss.org/message/750237#750237">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hey all. I'm having a really difficult time with EJB3.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have a server running a simple calculator demo. I am trying to create a Mule ESB call into it. If I run my calculator client standalone, it works fine. If I move my calculator client to Mule, it fails.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>One hint I have is that running standalone, my EJB call returns a class $Proxy2 and running on Mule, it returns class javax.naming.Reference. Any Ideas</p><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>OUTPUT:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I run my EJB Client on my local client, it works just fine:</p><p>Initializing</p><p>CLASS:class $Proxy2</p><p>Loaded Calculator Bean</p><p><a class="jive-link-external-small" href="public final float $Proxy2.division(float,float), public final float $Proxy2.subtract(float,float), .....public final void java.lang.Object.wait() throws java.lang.InterruptedException">public final float $Proxy2.division(float,float), public final float $Proxy2.subtract(float,float), .....public final void java.lang.Object.wait() throws java.lang.InterruptedException</a></p><p>Result:-3.0</p><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>But if I run my EJB Client on my Mule Server, it breaks:</p><p>Initializing</p><p>CLASS:class javax.naming.Reference</p><p>Loaded Calculator Bean</p><p><a class="jive-link-external-small" href="public void javax.naming.Reference.add(int,javax.naming.RefAddr), public void javax.naming.Reference.add(javax.naming.RefAddr), ..... ">public void javax.naming.Reference.add(int,javax.naming.RefAddr), public void javax.naming.Reference.add(javax.naming.RefAddr), ..... </a></p><p>java.lang.NoSuchMethodException: javax.naming.Reference.subtract(float, float)</p><p>&#160;&#160;&#160; at java.lang.Class.getMethod(Unknown Source)</p><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 style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>CODE:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here's my code. Like I said, it's identicle on both my Mule Server and Eclipse Client.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>package com.allurent;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import java.lang.reflect.Method;</p><p>import java.util.Arrays;</p><p>import java.util.Hashtable;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.naming.InitialContext;</p><p>import javax.naming.NamingException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import org.mule.api.MuleEvent;</p><p>import org.mule.api.MuleException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public class CalculatorLocal implements org.mule.api.processor.MessageProcessor</p><p>{</p><p>&#160;&#160;&#160; private static Object calculator = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public static void jspInit() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Initializing");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Hashtable&amp;lt;String, String&amp;gt; t = new Hashtable&amp;lt;String, String&amp;gt;();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; t.put("java.naming.provider.url", "jnp://localhost:1099");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; t.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; t.put("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InitialContext ic = null;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ic = new InitialContext(t);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (NamingException e) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Object temp = null;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; temp = ic.lookup("example/CalculatorBean/remote");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (NamingException e) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("CLASS:"+temp.getClass());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; calculator = temp;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Loaded Calculator Bean");</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public static void jspDestroy() {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; calculator = null;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public static void main (String [] args)</p><p>&#160;&#160;&#160; {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; args = new String[3];</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; args[1] = "12";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; args[2] = "15";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; args[0] = "subtract";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; jspInit();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String s1 = args[1];</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String s2 = args[2];</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String s3 = args[0];</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ( s1 != null &amp;amp;&amp;amp; s2 != null ) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Float num1&#160; = new Float(s1);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Float num2&#160; = new Float(s2);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(Arrays.toString(calculator.getClass().getMethods()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Class&amp;lt;? extends Object&amp;gt; c = calculator.getClass();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Method m = c.getMethod(s3, float.class, float.class);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Object value = null;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; value = m.invoke(calculator, num1.floatValue(), num2.floatValue());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Result:"+value.toString());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (Exception e) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace ();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; jspDestroy();</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @Override</p><p>&#160;&#160;&#160; public MuleEvent process(MuleEvent event) throws MuleException {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; CalculatorLocal.main(new String [] {"test","test2"});</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return null;</p><p>&#160;&#160;&#160; }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've been working on this for 3 days now, and I'm at my wit's end.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks,</p><p>-Rob </p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/750237#750237">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="https://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>