how to client look up ejb object from sybase-EA server4.0


EJB design: how to client look up ejb object from sybase-EA server4.0

  1. hi all

    plesae tell me if any one knows the client code to look up an ejb object deployed in sybase-ea4.0 app server.
    (what jndi look up context code)

  2. Certainly, here ya go. FYI, you may want to check out our public newsgroups at where we have very extensive coverage by our engineers as well as our partners.

    Jason Weiss
    Manager, Software Engineering
    eBusiness Systems Group

    import javax.naming.*;
    import java.rmi.*;
    import java.util.*;
    import Calculator.*;

    public class ConsoleClient
      public static Context getInitialContext() throws Exception
         Properties p = new Properties();
    /* change provider_url property accordingly. replace weissj-nt with
    machine name, which can be obtain by jaguar manager-> listener */
          p.put(Context.SECURITY_PRINCIPAL,"your user id here");
          p.put(Context.SECURITY_CREDENTIALS,"your password here");

         return new InitialContext(p);

      public static void main(String args[])
    Calculate calculate;
    CalculateHome calculateHome;

    Context jndiContext = getInitialContext();
    Object obj = jndiContext.lookup("Currencybean");
    calculateHome = (CalculateHome)javax.rmi.PortableRemoteObject.narrow(obj,CalculateHome.class);
    calculate= calculateHome.create();
    double abc = calculate.calculateCurrency("USD",15.5,"Y");
    System.out.println("Currency value is :" +abc);

    }catch(Exception e)
    System.out.println("exception has occoured" + e.toString());