OSGi client tries to connect to GF4. In maven I added gf-client-module 4. I see that bundle glassfish-naming-4.0.jar is installed.
So in Activator I have.
ClassLoader thatLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
Properties jndiProps = new Properties();
jndiProps.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
jndiProps.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
jndiProps.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
jndiProps.setProperty("org.omg.CORBA.ORBInitialHost", "x.x.x.x");
jndiProps.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(jndiProps);
} finally {
Thread.currentThread().setContextClassLoader(thatLoader);
}
And this is what I get
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
How can it be fixed? Bundle glassfish-naming-4.0.jar has Activator inside. Should I start this bundle? I tried but got unresolved constraints exception.
Solution SerialInitContextFactory not found in glassfish naming didn't help.