0

I'm new to Open Liberty. I need to call an EJB 3.1 deployed on WAS 8.5 but I can't find any documentation or tutorial on how to do it.

Is this feature present in OpenLiberty? Which features should i enable on my server.xml? And what is the code to call the server?

UPDATE

After reading some documentation, I've tried to make the call with the following server.xml

<server description="Sample Liberty server">
    <featureManager>
        <feature>webProfile-7.0</feature>
    </featureManager>

    <variable name="default.http.port" defaultValue="9080" />
    <variable name="default.https.port" defaultValue="9443" />
    <variable name="app.context.root" defaultValue="ServletSample" />

    <webApplication location="open-liberty-template.war"
        contextRoot="/test" />

    <keyStore id="defaultKeyStore" password="keypassword"/>

    <!-- EXAMPLE TRACE: when you visit the /health endpoint, additional traces 
        are logged in the trace.log file. -->
    <!-- <logging traceSpecification="com.ibm.ws.microprofile.health.*=all"></logging> -->

    <httpEndpoint host="*" httpPort="${default.http.port}"
        httpsPort="${default.https.port}" id="defaultHttpEndpoint" />

    <httpDispatcher enableWelcomePage="false" />


</server>

and Servlet

@WebServlet("/RemoteTxAttrServlet")
public class TestServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Properties p = new Properties();
        // p.put(Context.PROVIDER_URL, "iiop://10.64.2.93:2821");
        Object found = null;
        try {
            Context c = new InitialContext();
            found = c.lookup(
                    "corbaname::ip:port#ejb/global/ear-module/ejb-module/BeanName!package.Interface");
        } catch (NamingException e) {
            e.printStackTrace();
        }

        System.out.println(found);

    }
}

but I obtain the following Exception:

[INFO] [err] javax.naming.NameNotFoundException: Intermediate context does not exist: corbaname::10.64.2.93:2821#ejb/global
[INFO] [err]    at com.ibm.ws.jndi.internal.ContextNode.getTargetNode(ContextNode.java:125)
[INFO] [err]    at [internal classes]
[INFO] [err]    at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
[INFO] [err]    at it.aci.grpc.services.TestServlet.doGet(TestServlet.java:27)
[INFO] [err]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
[INFO] [err]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
[INFO] [err]    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1258)
[INFO] [err]    at [internal classes]
[INFO] [err]    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[INFO] [err]    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[INFO] [err]    at java.base/java.lang.Thread.run(Thread.java:834)

furthermore i cannot find the javax.rmi.PortableRemoteObject on the classpath to norrow the Object reference to my target remote interface.

How can i fix it?

Yanosh
  • 368
  • 5
  • 15
  • At least `ejbRemote-3.2` feature. Some basic information is provided here [Using enterprise JavaBeans with remote interfaces on Liberty](https://www.ibm.com/docs/en/was-liberty/base?topic=liberty-using-enterprise-javabeans-remote-interfaces). It was a while ago, so I'm not sure about the latest state but you might need also `com.ibm.ws.ejb.thinclient_8.5.0.jar` Check this - https://www.ibm.com/mysupport/s/question/0D50z00005q4HhCCAU/how-to-set-up-thin-client-to-call-remote-ejb-on-liberty?language=en_US – Gas Nov 16 '22 at 18:43
  • I've followed those posts but I cannot make the call. I've updated my question with the error and code – Yanosh Nov 17 '22 at 10:03
  • First of all you have `webProfile-7.0` which has only `ejbLite-3.2` not the one that I mentioned `ejbRemote-3.2` so you need to add that one. This is also the reason that you are not finding `PortableRemoteObject `. Second - double check your WAS `SystemOut.log` to see what is actual EJB bind name in the JNDI, to make sure you are using the correct name. – Gas Nov 17 '22 at 11:02

0 Answers0