You don't need the "java:/comp/env/ejb/" prefix before the EJB name.  Here
is an example of some code that we use to load an EJB. In this example the
bean is OrgTreeBean, the remote interface is OrgTree, and the home interface
is OrgTreeHome.




          System.setSecurityManager( new RMISecurityManager() );
        OrgTree returnTree = null;
        try
        {
                Properties props = new Properties();
                props.setProperty("java.naming.factory.initial",
"allaire.ejipt.ContextFactory");
                props.setProperty("java.naming.provider.url", 
"ejipt://127.0.0.1:2323");
                InitialContext ctx = new InitialContext( props );
            OrgTreeHome home = (OrgTreeHome)ctx.lookup("OrgTreeBean");
            returnTree = (OrgTree)home.create();
        }
        catch( Exception e )
        {
            System.out.println("Error retrieving org tree.");
            returnTree = null;
        }



-----Original Message-----
From: Christophe Marchand [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 7:38 AM
To: JRun-Talk
Subject: JNDI lookup problem


Hi all !

I've deployed some EJB on my default-serveur. Having a look at log
files, everything seems to be correct, no errors...
Then, I've deployed a Struts-based web app, which calls my ejb's.
When trying to look up for a home reference, JRun throws a
javax.naming.NameNotFoundException.
I have not modified any server parameter, and the ejbName sent is the
same than the one declared in ejb-jar.xml (in <ejb-name> tag).
See my code below. Could someone help me ?

Thanks a lot in advance,
Christophe.

public class HomePooler {
    public static EJBHome getHome (String ejbName)
            throws javax.naming.NamingException
    {
        InitialContext ctx = new InitialContext();
        ctx.addToEnvironment(
            "java.naming.factory.initial",
            "allaire.ejipt.ContextFactory");
        ctx.addToEnvironment(
            "java.naming.provider",
            "ejipt://127.0.0.1:2323");
        return (EJBHome)ctx.lookup("java:/comp/env/ejb/"+ejbName);
    }
}




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
Archives: http://www.mail-archive.com/jrun-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to