Reputation: 263
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
Upvotes: 6
Views: 8675
Reputation: 263
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.
Upvotes: 6
Reputation: 18020
Check this page Running the IBM Thin Client for Enterprise JavaBeans (EJB) for more details.
What are all libraries i need to include in classpath?
You will need com.ibm.ws.ejb.thinclient_8.5.0.jar
(located in app_server_root\runtimes
) and the endorsed_apis_8.5.0.jar
(located in app_server_root\runtimes\endorsed). Copy endoresed jar to JAVA_JRE\lib\endorsed
How to construct lookup string?
Invoke your application like this:
<java_install_root>\bin\java
-classpath com.ibm.ws.ejb.thinclient_8.5.0.jar;<list_of_your_application_jars_and_classes>
-Djava.naming.provider.url=iiop://<your_application_server_machine_name>:<orbPort>
<fully_qualified_class_name_to_run>
If you have security enabled on your server and SSL required, you will need add following:
-Dcom.ibm.SSL.ConfigURL=file:///home/user1/ssl.client.props
-Dcom.ibm.CORBA.ConfigURL=file:///home/user1/sas.client.props
you can find these files in your WebSphere installation files, in PROFILE_ROOT\properties
Upvotes: 5