How to write an EJB 3.1 client for WebSphere 8.5?

I ran into a problem while searching for EJB 3.1 deployed in WebSphere 8.5.

Please suggest me:

  • What all libraries do I need to include in the classpath?
  • How to build a search string?
  • Should I change the settings on the server side?

Note. I am using the Eclipse IDE

+6
source share
2 answers

Try the following:

  • Add com.ibm.ws.ejb.thinclient_8.5.0.jar and com.ibm.ws.orb_8.5.0.jar banks to the client application class path.
  • Create a client stub by running the createEJBStubs.sh script.
    createEJBStubs.sh script found in <WAS_HOME>/bin .
    Syntax: ./createEJBStubs.sh <ejbJarName>.jar
  • Add the generated jar to the path to the client application class.
  • Specify the JNDI username as follows:
    Open the WebSphere console, in the left sidebar, click Applications>All applications .
    Click on the deployed application.
    Click Bind EJB Business in the Enterprise Java Bean Properties section.
    Set the custom JNDI name for the EJB in the JNDI name column. e.g. customLookupString

Example 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(); } } } 

The code and the process worked on me.

+5
source

Check this page. Launch the IBM Thin Client for Enterprise JavaBeans (EJB) for more information.

What all libraries do I need to include in the classpath?

You will need com.ibm.ws.ejb.thinclient_8.5.0.jar (located in app_server_root\runtimes ) and endorsed_apis_8.5.0.jar (located in app_server_root \ runtimes \ endorsed). Copy the compressed jar to JAVA_JRE\lib\endorsed

How to build a search string?

Call your application as follows:

 <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 require SSL, you need to add the 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 the WebSphere installation files, in PROFILE_ROOT\properties

+4
source

Source: https://habr.com/ru/post/972637/


All Articles