Reputation: 961
I have created an remote EJB bean using EJB 3.1 and deployed it on web logic 12c. Now through a simple java client I am able to access the remote bean. It is working fine.
Java Client Code:
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
try {
InitialContext ic = new InitialContext(ht);
}
My next approach is to call this remote bean in a web application that is deployed in Tomcat 7. But it is throwing exception
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory.
I am using the following code to call the ejb bean : Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
properties.put("java.naming.factory.url.pkgs", "weblogic.jndi.factories:weblogic.corba.j2ee.naming.url");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
properties.put( Context.SECURITY_PRINCIPAL, "weblogic");
properties.put( Context.SECURITY_CREDENTIALS, "weblogic1");
try {
Context ic = new InitialContext(properties);
}
What to do to make it work.
Thanks
Upvotes: 0
Views: 1962
Reputation: 36
Work for me adding wlclient.jar and wlthint3client.jar (in this order) on classpath.
In my case I was trying to invoke EJB from the test class. To get the instance I did this way:
weblogic.ejb.spi.BusinessObject obj = (weblogic.ejb.spi.BusinessObject) context.lookup("MyEJBRemoteMappedName#br.com.ejbclient.MyEJBRemote");
br.com.ejbclient.MyEJBRemote myEJB = (br.com.ejbclient.MyEJBRemote) obj._WL_getBusinessObjectHandle().getBusinessObject();
I'm using wls12130.
Upvotes: 0