users@glassfish.java.net

Re: Pass Principal to EJB from external app

From: <glassfish_at_javadesktop.org>
Date: Fri, 05 Jun 2009 01:46:22 PDT

You have to use Programmatic Login on the client side inside the java app.

Ex :

        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial",
                "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        InitialContext initial = new InitialContext(props);

        ProgrammaticLogin pm = new ProgrammaticLogin();
        pm.login("test", "test"); //pass the username and password here
        System.out.println("Programmatic Login Successful...");
        Object objref = initial.lookup("com.xyz.ejbb.XYZBeanBRemote");
        XYZBeanBHome xyzHome =
                (XYZBeanBHome) PortableRemoteObject.narrow(objref,
                XYZBeanBHome.class);
        XYZBeanBRemote xyzBRemote = xyzHome.create();

        System.out.println(xyzBRemote.sayHelloFromB());
[Message sent by forum member 'kumarjayanti' (kumarjayanti)]

http://forums.java.net/jive/thread.jspa?messageID=349263