Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes OSGI JNDI allow coexistence with JNDI calls from non-OSGI code?
    primarykey
    data
    text
    <p>Chapter 126 of the <a href="http://www.osgi.org/Download/Release5" rel="noreferrer">OSGI Enterprise Release 5 specification</a> mentions compatibility:</p> <blockquote> <p>"Support the traditional JNDI programming model used by Java SE and Java EE clients."</p> </blockquote> <p>and use of OSGI-unaware code:</p> <blockquote> <p>"Clients and JNDI Context providers that are unaware of OSGi use static methods to connect to the JRE JNDI implementation. The InitialContext class provides access to a Context from a provider and providers use the static NamingManager methods to do object conversion and find URL Contexts. This traditional model is not aware of OSGi and can therefore only be used reliably if the consequences of this lack of OSGi awareness are managed."</p> </blockquote> <p>but it is not clear to me if this text only applies to "legacy" code executed inside an OSGI bundle, or also to code outside the OSGI container, f ex in a scenario where the OSGI container is embedded in an application.</p> <p>In an embedding scenario, there may be application code both outside and inside the OSGI container that performs JNDI calls, and as they execute in the same JVM they will share JNDI implementation.</p> <p><strong>Question:</strong> Should an OSGI JNDI implementation running in an embedded OSGI container allow OSGI-unaware code outside the container to perform its JNDI calls like usual, or is some porting to "OSGI-awareness" required?</p> <p>Trying this out myself with Apache Karaf 2.3.0 (which uses Apache Aries JNDI 1.0.0) this doesn't seem to work, as Apache Aries requires JNDI client calls to originate from an OSGI bundle.<br> Partial stacktrace:</p> <pre><code>javax.naming.NoInitialContextException: The calling code's BundleContext could not be determined. at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:46) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) at javax.naming.InitialContext.init(InitialContext.java:242) at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:192) </code></pre> <p><strong>Question:</strong> Is this correct behaviour, or is there a section of the specification I can refer to that is violated by this limitation?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload