0 Replies Latest reply on Jul 25, 2012 10:58 AM by robert allurent

    Real hard time with EJB3-- javax.naming.Reference instead of $Proxy

    robert allurent Newbie

      Hey all. I'm having a really difficult time with EJB3.


      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.


      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






      If I run my EJB Client on my local client, it works just fine:


      CLASS:class $Proxy2

      Loaded Calculator Bean

      [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]




      But if I run my EJB Client on my Mule Server, it breaks:


      CLASS:class javax.naming.Reference

      Loaded Calculator Bean

      [public void javax.naming.Reference.add(int,javax.naming.RefAddr), public void javax.naming.Reference.add(javax.naming.RefAddr), ..... ]

      java.lang.NoSuchMethodException: javax.naming.Reference.subtract(float, float)

          at java.lang.Class.getMethod(Unknown Source)






      Here's my code. Like I said, it's identicle on both my Mule Server and Eclipse Client.


      package com.allurent;


      import java.lang.reflect.Method;

      import java.util.Arrays;

      import java.util.Hashtable;


      import javax.naming.InitialContext;

      import javax.naming.NamingException;


      import org.mule.api.MuleEvent;

      import org.mule.api.MuleException;


      public class CalculatorLocal implements org.mule.api.processor.MessageProcessor


          private static Object calculator = null;


          public static void jspInit() {



                  Hashtable<String, String> t = new Hashtable<String, String>();


                  t.put("java.naming.provider.url", "jnp://localhost:1099");

                  t.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

                  t.put("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");


                  InitialContext ic = null;

                  try {

                      ic = new InitialContext(t);

                  } catch (NamingException e) {




                  Object temp = null;

                  try {

                      temp = ic.lookup("example/CalculatorBean/remote");

                  } catch (NamingException e) {





                  calculator = temp;   

                  System.out.println("Loaded Calculator Bean");



          public static void jspDestroy() {

              calculator = null;



          public static void main (String [] args)


              args = new String[3];

              args[1] = "12";

              args[2] = "15";

              args[0] = "subtract";





              try {

                  String s1 = args[1];

                  String s2 = args[2];

                  String s3 = args[0];


                  if ( s1 != null && s2 != null ) {

                      Float num1  = new Float(s1);

                      Float num2  = new Float(s2);




                      Class<? extends Object> c = calculator.getClass();

                      Method m = c.getMethod(s3, float.class, float.class);

                      Object value = null;

                      value = m.invoke(calculator, num1.floatValue(), num2.floatValue());






              catch (Exception e) {

                  e.printStackTrace ();






          public MuleEvent process(MuleEvent event) throws MuleException {

              CalculatorLocal.main(new String [] {"test","test2"});

              return null;




      I've been working on this for 3 days now, and I'm at my wit's end.