1

I try to convert application using Websphere 8.5 full profile to Liberty profile, but I got issue regarding to incompatibility.

Unable to find the InitialContextFactory com.ibm.websphere.naming.WsnInitialContextFactory

I know the class location com.ibm.ws.ejb.thinclient_8.0.0.jar in full profile verison, but I could not the relevant one in Liberty profile, And one more thing, because I am doing maintenance application, so the class to look at

com.ibm.websphere.naming.WsnInitialContextFactory

it already complied in jar file, so I am unable to change it,

I totally get stuck on this. any idea on this issue is appreciated.

2 Answers 2

2

Liberty is not using WsnInitialContextFactory, so you will need to refactor your classes using it to parameter less constructor of InitialContext like this:

InitialContext ctx = new InitialContext(); 

Where in your application you need that WsnInitialContextFactory?

6
  • Thanks for your response, I have tried to use your suggestion but its still failed to look at ejb component.
    – Joey Trang
    Commented Apr 29, 2015 at 3:19
  • Hi @Gas Thanks for your response, Because its legacy code, I de-compiled the jar file to see the code as below Context initial = new InitialContext(env); with env is hashmap containing values from properties file I tried to use new constructor without arg as you suggested Context initial = new InitialContext() but I come up with another problem, can not look up the ejb component, although ejb component deployed in same jvm I'm wondering that there is any way to see these jndi name of ejb component deployed in liberty profile? Many thanks for you help.
    – Joey Trang
    Commented Apr 29, 2015 at 3:27
  • I just want to add more info. I my application I have SSOApiHome, I expected that is deployed as component, and JNDI name as below. public static final String COMP_NAME = "java:comp/env/ejb/SSOApi"; public static final String JNDI_NAME = "SSOApi"; The client code, I used the following code to lookup. Context initial = new InitialContext(); Object objref = initial.lookup("SSOApi"); Many thanks in advance.
    – Joey Trang
    Commented Apr 29, 2015 at 3:46
  • @Vab What error do you have now? You have to be aware that Liberty doesn't support EJB 2.x nor Remote interfaces (it doesn't matter if it is same JVM). Check what version of the EJB module you have (in ejb-jar.xml). You probably have 2 interfaces - SSOApiHome and SSOApiXyz which would suggest EJB 2.0.
    – Gas
    Commented Apr 29, 2015 at 7:40
  • hi @Gas, thanks for you response, basically my application need to lookup ejb component deployed in different server (these ejb version 2.x).. As I understand The Liberty profile does not use com.ibm.websphere.naming.WsnInitialContextFactory. so I tried to comment it out from property file. now I got namingNotFound exception..
    – Joey Trang
    Commented May 5, 2015 at 14:35
0

In my case, I was using *java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory into the application properties which was further injected into the spring bean of QuartzSchedulerService as a property injection.

I just removed the line from the application properties java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory and removed property java.naming.factory.initial injection also from spring bean config. It got fixed.

I'm using the above config in Quartz scheduler. So, shared if helpful for someone. Thanks.

Not the answer you're looking for? Browse other questions tagged or ask your own question.