[jboss-user] [Beginners Corner] - Re: invoking an EJB over iiop
HibsMax
do-not-reply at jboss.com
Mon Jun 4 09:30:51 EDT 2007
Thanks for your reply, jaikiran!
The servlet is packaged in a WAR file and is deployed on server1.
The EJB is packaged in a JAR file and is deployed on server2.
The jndi-name in jboss.xml and ejb-jar.xml is set to interop.InteropHome. Here's jboss.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
| <jboss>
| <enterprise-beans>
| <session>
| <ejb-name>interop.InteropBean</ejb-name>
| <invoker-bindings>
| <invoker>
| <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>
| </invoker>
| <jndi-name>interop.InteropHome</jndi-name>
| </invoker-bindings>
| </session>
| </enterprise-beans>
| </jboss>
My ejb-jar.xml contains the exact same jndi-name.
Here's how I create the initial context:
Properties h = new Properties();
| String ctx = "";
| ctx = "org.jboss.iiop.naming.ORBInitialContextFactory";
| h.put( Context.INITIAL_CONTEXT_FACTORY, ctx );
| h.put( Context.PROVIDER_URL, url );
| InitialContext initCtx = new InitialContext(h);
| return initCtx;
The URL I am using is:
iiop://server2:3528
Finally, here's the EJB lookup:
Object foo = getInitialContext(url, user, password).lookup(ejbHomeName);
| Object bar = PortableRemoteObject.narrow( foo, InteropHome.class );
| home = (InteropHome) bar;
|
In my source code I use this for the EJB name: iiop://interop.InteropHome
user and password are null in this case. When I run this code and display the class name of the object in foo, I get : com.sun.jndi.cosnaming.CNCtx
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050959#4050959
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050959
More information about the jboss-user
mailing list