users@glassfish.java.net

Re: accessing ejb3.0 hosted by glassfish from sun java system Web

From: <glassfish_at_javadesktop.org>
Date: Wed, 16 Jan 2008 12:24:57 PST

 server 7
In-Reply-To: <478E159C.10505_at_Sun.Com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

That's exactly what I'm doing. The class path suffix of sun web server 7 is pointing to both javaee.jar and appserv-rt.jar in {glassfish-home}/lib. The code that does the lookup is wrapped in the function getEJBBean:

public <T> T getEJBBean(Class<T> beanClass, String jndiName) throws NamingException
    {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial",
                          "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs",
                          "com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state",
                          "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

        // optional. Defaults to localhost. Only needed if web server is running
        // on a different host than the appserver
        props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");

        // optional. Defaults to 3700. Only needed if target orb port is not 3700.
        props.setProperty("org.omg.CORBA.ORBInitialPort", "7038");

        InitialContext ic = new InitialContext(props);
        Object object = ic.lookup(jndiName);
        return beanClass.cast(object);
    }

The remote objects are on the local machine, but wil be moved to another machine as soon as we get it working. The port 7038 was obtained from the configuration section of the GlassFish IIOP-Listeners.

Thanks for your replies in advance!
[Message sent by forum member 'jvshahid' (jvshahid)]

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