[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [virgo-dev] virgo with gemini-naming

Hi Dmitry

Thanks for the write-up! When you have gotten a bit further, you may want to add this to the Virgo documentation or at least the wiki.

As for KE0003E, perhaps you would raise an enhancement bug so that we at least put the bundle details in the message.

I was playing around with JNDI and Virgo the other week, but didn't get as far as you. Since it was only for a demo, I gave up.

Regards,
Glyn

On 7 Oct 2010, at 20:49, Dmitry Sklyut wrote:

Hi All,

I started playing with the gemini-naming M1 in virgo.  Everything deploys fine with very few config file changes.

1.  Modify /lib/org.eclipse.virgo.kernel.launch.properties to add
file:lib/kernel/org.osgi.enterprise-4.2.0.jar@start,\
file:lib/kernel/org.eclipse.gemini.naming.impl.bundle-Incubation-1.0-SNAPSHOT.jar@start,\

Make sure to copy those jars to lib/kernel.

2.  Modify org.eclipse.virgo.kernel.userregion.properties to add following services to the "serviceImports"
org.osgi.service.jndi.JNDIContextManager,\
org.osgi.service.jndi.JNDIProviderAdmin

Based on my reading of the spec additional InitalContextFactory, InitialContextFactoryBuilder, ObjectFactory, etc can be published from user region.  In that case all of those entries should be added to the "serviceExports" property in org.eclipse.virgo.kernel.userregion.properties.  I tested that by publishing an InitialContextFactoryBuilder from userregion deployed bundle and saw it getting picked up.

One issues that I ran into:
Adding any of the following to the "serviceImports" list causes kernel to fail start up with very little information outside of a tiny stack trace.  javax.naming.spi.InitialContextFactoryBuilder,  javax.naming.spi.InitialContextFactory, javax.naming.spi.ObjectFactory

Error: startup-tracker <KE0003E> Kernel failed to start. java.lang.RuntimeException: bundle stopped

Another issue is that Tomcat set-up with "useNaming = true", so it will try to set-up "java:/" prefix itself.  It will also set system level properties for
"java.naming.factory.initial" and "java.naming.factory.url.pkgs".  This behavior basically forces the client of the InitialContext to provide its own environment settings or keep a jndi.properties in the root of the bundle (section 126.3.1 of OSGi Enterprise spec).

Documentation of Tomcat org.apache.catalina.startup.Embedded.initNaming() says (I think) that useNaming should be false if Tomcat is embedded.

"Initialize naming - this should only enable java:env and root naming. If tomcat is embeded in an application that already defines those - it shouldn't do it. XXX The 2 should be separated, you may want to enable java: but not the initial context and the reverse XXX Can we "guess" - i.e. lookup java: and if something is returned assume false ? XXX We have a major problem with the current setting for java: url"

I guess I should also explain why I want to use jndi in OSGi.   We are using number of third party non osgi enabled web applications that provide ability to configure data source, mail session, etc either manually (properties/xml) or through jndi.  This is a maintenance nightmare waiting to happen as we need to modify x number of config files for each deployment.  One will be missed with about 100% probability :)

I wanted to use "osgi:service/" or a wrapper around "java:" namespace to have config in one spot and fetch services from service registry.  The wrapper for "java:/" namespace is useful for us in case one of those components will move out into its own instance of Tomcat/JEE container.

I will post more once I have a working wrapper for "java:/" namespace with delegation to "osgi:service" namespace.

Is anyone interested in virgo with jndi?  Are there any other mines that are waiting to explode?

Regards,

Dmitry



<ATT00001..txt>