<!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;"> </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;"> </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;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>OUTPUT:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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>    at java.lang.Class.getMethod(Unknown Source)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>CODE:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>package com.allurent;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>import javax.naming.InitialContext;</p><p>import javax.naming.NamingException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.mule.api.MuleEvent;</p><p>import org.mule.api.MuleException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class CalculatorLocal implements org.mule.api.processor.MessageProcessor</p><p>{</p><p>    private static Object calculator = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public static void jspInit() {</p><p>        System.out.println("Initializing");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            Hashtable&lt;String, String&gt; t = new Hashtable&lt;String, String&gt;();</p><p>            </p><p>            t.put("java.naming.provider.url", "jnp://localhost:1099");</p><p>            t.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");</p><p>            t.put("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");</p><p>            </p><p>            InitialContext ic = null;</p><p>            try {</p><p>                ic = new InitialContext(t);</p><p>            } catch (NamingException e) {</p><p>                e.printStackTrace();</p><p>            }</p><p>            </p><p>            Object temp = null;</p><p>            try {</p><p>                temp = ic.lookup("example/CalculatorBean/remote");</p><p>            } catch (NamingException e) {</p><p>                e.printStackTrace();</p><p>            }</p><p>            </p><p>            System.out.println("CLASS:"+temp.getClass());</p><p>            calculator = temp;    </p><p>            System.out.println("Loaded Calculator Bean");</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public static void jspDestroy() {</p><p>        calculator = null;</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    public static void main (String [] args)</p><p>    {</p><p>        args = new String[3];</p><p>        args[1] = "12";</p><p>        args[2] = "15";</p><p>        args[0] = "subtract";</p><p>        </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        jspInit();</p><p>        </p><p>        try {</p><p>            String s1 = args[1];</p><p>            String s2 = args[2];</p><p>            String s3 = args[0];</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>            if ( s1 != null &amp;&amp; s2 != null ) {</p><p>                Float num1  = new Float(s1);</p><p>                Float num2  = new Float(s2);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                System.out.println(Arrays.toString(calculator.getClass().getMethods()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                Class&lt;? extends Object&gt; c = calculator.getClass();</p><p>                Method m = c.getMethod(s3, float.class, float.class);</p><p>                Object value = null;</p><p>                value = m.invoke(calculator, num1.floatValue(), num2.floatValue());</p><p>                </p><p>                System.out.println("Result:"+value.toString());</p><p>            }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        }</p><p>        catch (Exception e) {</p><p>            e.printStackTrace ();</p><p>        }</p><p>        jspDestroy();</p><p>    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    @Override</p><p>    public MuleEvent process(MuleEvent event) throws MuleException {</p><p>        CalculatorLocal.main(new String [] {"test","test2"});</p><p>        return null;</p><p>    }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </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>