I am having a problem calling EJB's across platforms. I created a routine in
jsp(temporarily) from the coded supplied to this group by Jens Stutte(Thank
you!) in a previous posting. I have EJB's called "inventory" on two different
boxes. My main Orion server is running on local host. This Test.jsp on
retrieves the context from server xyz.xyz.xyz.xyz. However when I retrieve the
"home" inventory be it keeps pulling in the "home" inventory bean from local
host.
However, on xyz.xyz.xyz.xyz as a test I bound in foo=bar( ctx.bind("foo","bar")
) and I am able to(from localhost) retrieve that value from the xyz.xyz.xyz.xyz
server. See code below.
Am I doing something wrong? Or might this be a bug.
Both xyz.xyz.xyz.xyz have the inventory ejb loaded. They do use the same
interfaces, but the InventoryEJB classes are coded differently.
Any help would be appreciated!
Thanks!
Evan Vaala
Test.jsp:
----------------------------------------------
String ejbUrl = "ormi://xyz.xyz.xyz.xyz/inventory";
String m_Factory = "com.evermind.server.rmi.RMIInitialContextFactory";
String m_User = "admin";
String m_Password = "123";
try {
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,m_Factory);
h.put(Context.PROVIDER_URL, ejbUrl);
if (m_User != null) {
h.put(Context.SECURITY_PRINCIPAL, m_User);
if (m_Password == null) m_Password = "";
h.put(Context.SECURITY_CREDENTIALS, m_Password);
}
Context plantctx = new InitialContext(h);
Object homeObject = plantctx.lookup("inventory");
home = (InventoryHome)PortableRemoteObject.narrow(homeObject,
InventoryHome.class);
System.out.println( plantctx.lookup("foo") );
} catch (NamingException ex) {ex.printStackTrace();}
Inventory inv = home.findByPrimaryKey("0008-6807");
Collection items = inv.getItems();
-----------------------------------------------
ejb-jar.xml:
-----------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<description></description>
<enterprise-beans>
<entity>
<description></description>
<display-name>inventory.ejb.Inventory</display-name>
<ejb-name>inventory</ejb-name>
<home>inventory.ejb.InventoryHome</home>
<remote>inventory.ejb.Inventory</remote>
<ejb-class>inventory.ejb.InventoryEJB</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
</entity>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>
-------------------------------------------------