You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by Guillaume Nodet <gn...@gmail.com> on 2010/11/30 11:29:47 UTC

JNDI and legacy code

One of our users found the following problem when using Aries JNDI in Karaf:

Exception in thread "JMX Connector Thread
[service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root]"
java.lang.RuntimeException: Could not start JMX connector server
       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:103)
Caused by: java.io.IOException: Cannot bind to URL
[rmi://localhost:1099/karaf-root]:
javax.naming.NoInitialContextException: Unable to determine caller's
BundleContext
       at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)
       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:101)
Caused by: javax.naming.NoInitialContextException: Unable to determine
caller'sBundleContext
       at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:53)
       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:316)
       at javax.naming.InitialContext.bind(InitialContext.java:400)
       at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625)
       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412)
       ... 1 more

The exception is quite clear and kinda expected in that case since the
calls are done from the JRE itself and no TCCL has been set.
Now the question is where the bug is.
I would think that such code should work as it only access the rmi
jndi provider which is built into the JRE and the client code should
not have to be OSGi aware.

Thoughts ?

-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: JNDI and legacy code

Posted by Guillaume Nodet <gn...@gmail.com>.
So investigating a bit more, I think what's missing is a registered
ObjectFactory for rmi urls.
So unless someone has a better solution, I'll add a new maven module
which will just do that.
Unfortunately, this class is JVM specific, so i'll hard code the sun
one for now, but if anyone knows the class for other JVM, that would
be nice !

On Tue, Nov 30, 2010 at 11:13, Guillaume Nodet <gn...@gmail.com> wrote:
> Reading the spec, it seems this behavior should be supported from
> section 126.5.6 ...
>
> On Tue, Nov 30, 2010 at 10:29, Guillaume Nodet <gn...@gmail.com> wrote:
>> One of our users found the following problem when using Aries JNDI in Karaf:
>>
>> Exception in thread "JMX Connector Thread
>> [service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root]"
>> java.lang.RuntimeException: Could not start JMX connector server
>>       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:103)
>> Caused by: java.io.IOException: Cannot bind to URL
>> [rmi://localhost:1099/karaf-root]:
>> javax.naming.NoInitialContextException: Unable to determine caller's
>> BundleContext
>>       at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
>>       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)
>>       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:101)
>> Caused by: javax.naming.NoInitialContextException: Unable to determine
>> caller'sBundleContext
>>       at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:53)
>>       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
>>       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>       at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:316)
>>       at javax.naming.InitialContext.bind(InitialContext.java:400)
>>       at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625)
>>       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412)
>>       ... 1 more
>>
>> The exception is quite clear and kinda expected in that case since the
>> calls are done from the JRE itself and no TCCL has been set.
>> Now the question is where the bug is.
>> I would think that such code should work as it only access the rmi
>> jndi provider which is built into the JRE and the client code should
>> not have to be OSGi aware.
>>
>> Thoughts ?
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: JNDI and legacy code

Posted by Guillaume Nodet <gn...@gmail.com>.
Reading the spec, it seems this behavior should be supported from
section 126.5.6 ...

On Tue, Nov 30, 2010 at 10:29, Guillaume Nodet <gn...@gmail.com> wrote:
> One of our users found the following problem when using Aries JNDI in Karaf:
>
> Exception in thread "JMX Connector Thread
> [service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root]"
> java.lang.RuntimeException: Could not start JMX connector server
>       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:103)
> Caused by: java.io.IOException: Cannot bind to URL
> [rmi://localhost:1099/karaf-root]:
> javax.naming.NoInitialContextException: Unable to determine caller's
> BundleContext
>       at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
>       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)
>       at org.apache.karaf.management.ConnectorServerFactory$1.run(ConnectorServerFactory.java:101)
> Caused by: javax.naming.NoInitialContextException: Unable to determine
> caller'sBundleContext
>       at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:53)
>       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
>       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>       at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:316)
>       at javax.naming.InitialContext.bind(InitialContext.java:400)
>       at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625)
>       at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412)
>       ... 1 more
>
> The exception is quite clear and kinda expected in that case since the
> calls are done from the JRE itself and no TCCL has been set.
> Now the question is where the bug is.
> I would think that such code should work as it only access the rmi
> jndi provider which is built into the JRE and the client code should
> not have to be OSGi aware.
>
> Thoughts ?
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com