Message Boards

Liferay 7.3: JNDIContextManager Implementation as an OSGi Module

Gamini Muthukumarana, modified 2 Years ago.

Liferay 7.3: JNDIContextManager Implementation as an OSGi Module

New Member Posts: 3 Join Date: 7/13/20 Recent Posts

Hi all,

we are in process of migrating a customer liferay 6.2 project into Liferay 7.3.  This Liferay Portal runs on JBoss EAP 7.3.5 Server and contains few custom jars to fetch data from another JBoss Server over Bean-calls (ejb).

OSGi Framework supports JNDI Calls within OSGi Container as it is described in https://docs.osgi.org/download/r6/osgi.cmpn-6.0.0.pdf.  All what is needed is an implementation of JNDIContextManager that deliver an Context instance that enable JNDI calls.

My question is; do we have a standard JNDIContextManager implementation for Liferay 7.3? 

Secondly; i tried an OSGi Module by extracting code from an apache example http://www.apache.org/dyn/closer.cgi/aries/org.apache.aries.jndi-1.0.0.jar. and deployed in OSGi Container as a service. I can access this from my consumer module whereas i get the exception:

class cs.jndi.context.manager.impl.CsJndiContextManagerImpl cannot be cast to class org.osgi.service.jndi.JNDIContextManager (cs.jndi.context.manager.impl.CsJndiContextManagerImpl is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @14de92ba; org.osgi.service.jndi.JNDIContextManager is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @66a1b9f5)

(cs.jndi.context.manager.impl.CsJndiContextManagerImpl is the implementation and org.osgi.service.jndi.JNDIContextManager is the interface from osgi.cmpn-6.0.0.jar.)

It would be great if someone here could give us a feedback.  Thank you very much.

Gamini Muthukumarana, modified 2 Years ago.

RE: OSGI Module with external Dependencies

New Member Posts: 3 Join Date: 7/13/20 Recent Posts

Hi,

When debugging i see that creating a context and resolving the required bean in WildflyRootContext works as the namingProviderFactories contains enties. These entries are somehow disappear after the JBoss Server and Liferay is started.  Hence i tried to test the issue by instantiating the bean after the JBoss Server started and Liferay is up. In this case i get following  the CNFE : 

javax.naming.NamingException: WFLYNAM0027: Instantiierung von InitialContextFactory org.wildfly.naming.client.WildFlyInitialContextFactory vom Klassenlader org.eclipse.osgi.internal.loader.EquinoxClassLoader@69c96ce3[com.liferay.gogo.shell.web:4.0.14(id=695)] fehlgeschlagen [Root exception is java.lang.ClassNotFoundException: org.wildfly.naming.client.WildFlyInitialContextFactory cannot be found by com.liferay.gogo.shell.web_4.0.14]

My module contains the jar in lib that contains org.wildfly.naming.client packages and the Bundle-ClassPath contains a reference to it.

I also exported all org.wildfly.naming.client packages and tried. Still i get the same problem. 

Has anyone any idea what i miss here?  Thanks.