0
votes

I am working on migrating ear application from WebSphere 8.5 to liberty.

As part of the changes I have replaced JNDI bindings (in lookups) with java namespaces

e.g.

ejb/abc/cde/TestHome  
ejblocal:ejb/qwe/ret/AbcHome  

get replaced with java namespaces similar to

java:global/my-ear-app-name/my-ejb-module-name/MyEjbBean!my.package.name.MyEjbLocal

But in some places of the code , there are lookups like

.lookup("com.abc.cde.Test");

Are these lookups local with java namespaces?

How to handle these lookups? Should I add java namespace like java:global/java:app etc ?

1
is the code .lookup("com.abc.cde.Test"); from an InitialContext or did you look up a different context first such as "ejblocal"? do you have anything in a binding filed such as ejb-jar-bnd.xml setting an element as "com.abc.cde.Test" such as simple-binding-name?olendvcook
It is using initial context. I did not find binding in any xml filecooldev

1 Answers

1
votes

As you have noticed, the WebSphere JNDI traditional custom bindings do not work in Liberty currently. For future reference, we are currently working on getting them to work in Liberty to make migration easier in the future. (https://github.com/OpenLiberty/open-liberty/issues/7918)

The lookup you are confused about (InitialContext.lookup("com.abc.cde.Test");) is what we called the default short form binding for a remote bean, which is just the remote interface.

You are correct to replace these with the Java namespace lookups, with these patterns:

  • java:global/<appname>/<modulename>/<bean>!<interface>
  • java:app/<modulename>/<bean>!<interface>
  • java:module/<bean>!<interface>

    • Note: <interface> is the qualified interface name, including the package
    • Note 2: that the call to java:app or java:module needs to be in the same application or module as the bean.

Also if you run the Liberty Server, we print out the java:global binding with CNTR0167I:

For reference the old default bindings that don't work yet:

  • Local long form: ejblocal:<appname>/<modulename>.jar/<bean>#<interface>
  • Local short form: ejblocal:<interface>
  • Remote long form: ejb/<appname>/<modulename>.jar/<bean>#<interface>
  • Remote short form: <interface>

There are also a few old custom bindings forms that can be specified through a binding file, such as ejb-jar-bnd.xml, that would currently have the same migration strategy, but I won't go into all the different styles unless you also run into them. The safe bet is that if it's looking up a bean with a lookup that is not a java namespace, just replace it with java:global.