I'm facing problem while doing lookup for EJB 3.1 deployed on WebSphere 8.5.
Please suggest me :
Note : I'm using Eclipse IDE
Try This :
com.ibm.ws.ejb.thinclient_8.5.0.jar
and com.ibm.ws.orb_8.5.0.jar
jars to classpath of client application.createEJBStubs.sh
script.
createEJBStubs.sh
script found under <WAS_HOME>/bin
directory.
./createEJBStubs.sh <ejbJarName>.jar
JNDI
name to your EJB
as follows :
Applications>All applications
.
Bind EJB Business
under Enterprise Java Bean Properties
.
JNDI
name for your EJB
under JNDI name
column. e.g. customLookupString
Sample Client Code :
public class WebSphereClient {
public static void main(String[] args) {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2818");
TestBeanRemote bean = null;
Object obj;
try {
InitialContext ctx = new InitialContext(props);
obj= ctx.lookup("customLookupString");
if (obj instanceof TestBeanRemote) {
bean = (TestBeanRemote) obj;
}
System.out.println("Name : "+bean.getName());
} catch (NamingException e) {
e.printStackTrace();
}
}
}
Above code and process worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With