You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Kamesh Sampath <ks...@redhat.com> on 2016/05/26 08:10:43 UTC
Accessing JNDI Object
I am using Apache Aries with Camel, as part of my test with pax-jdbc I have registered the JNDI datasource via Karaf cfg – it all works fine when deployed in Karaf, when doing the testing via CamelBlueprintTest am getting the following error :
“
Caused by: 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:313)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:341)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.setProperties(JndiDataSourceFactory.java:52)
“
Where the “ org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.” is a non-OSGi bundle. After debugging I see the failure happens in Utils#doGetBundleContext, when it does the “Object bc = env == null?null:env.get("osgi.service.jndi.bundleContext");”, wondering if I am missing any environment property I miss to set.
-Kamesh
Re: Accessing JNDI Object
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
if you don't use Karaf, then you have to create and provide a JNDI
initial context factory yourself.
That's why Karaf is so helpful ;) and it can be run static on docker too
(no need to use FelixConnect ;)).
Regards
JB
On 06/06/2016 11:06 AM, kamesh.sampath@hotmail.com wrote:
> Hi Jean,
>
> It does work when doing in Karaf directly where jndi was installed. When
> I was doing with Camel tests with blueprint it fails.. may be something
> to do with FelixConnect. I did run the same tests with pax-exam all went
> fine.
>
> +Kamesh
>
> Get Outlook for Android <https://aka.ms/ghei36>
>
>
>
>
> On Mon, Jun 6, 2016 at 1:53 AM -0700, "Jean-Baptiste Onofr�"
> <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>
> Hi Kamesh,
>
> Did you install the jndi feature in Karaf ?
>
> This feature provide a InitialContextFactory (which is not the case by
> default).
>
> Regards
> JB
>
> On 05/26/2016 10:10 AM, Kamesh Sampath wrote:
> > I am using Apache Aries with Camel, as part of my test with pax-jdbc I
> > have registered the JNDI datasource via Karaf cfg \u2013 it all works fine
> > when deployed in Karaf, when doing the testing via CamelBlueprintTest am
> > getting the following error :
> >
> > \u201c
> > Caused by: 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:313)
> > at
> >
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:341)
> > at javax.naming.InitialContext.lookup(InitialContext.java:417)
> > at
> >
> org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.setProperties(JndiDataSourceFactory.java:52)
> > \u201c
> >
> > Where the \u201c org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.\u201d is
> > a non-OSGi bundle. After debugging I see the failure happens in
> > Utils#doGetBundleContext, when it does the \u201cObject bc = env ==
> > null?null:env.get("osgi.service.jndi.bundleContext");\u201d, wondering if I
> > am missing any environment property I miss to set.
> >
> > -Kamesh
>
> --
> Jean-Baptiste Onofr�
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
--
Jean-Baptiste Onofr�
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Accessing JNDI Object
Posted by ka...@hotmail.com.
Hi Jean,
It does work when doing in Karaf directly where jndi was installed. When I was doing with Camel tests with blueprint it fails.. may be something to do with FelixConnect. I did run the same tests with pax-exam all went fine.
+Kamesh
Get Outlook for Android
On Mon, Jun 6, 2016 at 1:53 AM -0700, "Jean-Baptiste Onofré" <jb...@nanthrax.net> wrote:
Hi Kamesh,
Did you install the jndi feature in Karaf ?
This feature provide a InitialContextFactory (which is not the case by
default).
Regards
JB
On 05/26/2016 10:10 AM, Kamesh Sampath wrote:
> I am using Apache Aries with Camel, as part of my test with pax-jdbc I
> have registered the JNDI datasource via Karaf cfg – it all works fine
> when deployed in Karaf, when doing the testing via CamelBlueprintTest am
> getting the following error :
>
> “
> Caused by: 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:313)
> at
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:341)
> at javax.naming.InitialContext.lookup(InitialContext.java:417)
> at
> org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.setProperties(JndiDataSourceFactory.java:52)
> “
>
> Where the “ org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.” is
> a non-OSGi bundle. After debugging I see the failure happens in
> Utils#doGetBundleContext, when it does the “Object bc = env ==
> null?null:env.get("osgi.service.jndi.bundleContext");”, wondering if I
> am missing any environment property I miss to set.
>
> -Kamesh
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Accessing JNDI Object
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Kamesh,
Did you install the jndi feature in Karaf ?
This feature provide a InitialContextFactory (which is not the case by
default).
Regards
JB
On 05/26/2016 10:10 AM, Kamesh Sampath wrote:
> I am using Apache Aries with Camel, as part of my test with pax-jdbc I
> have registered the JNDI datasource via Karaf cfg \u2013 it all works fine
> when deployed in Karaf, when doing the testing via CamelBlueprintTest am
> getting the following error :
>
> \u201c
> Caused by: 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:313)
> at
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:341)
> at javax.naming.InitialContext.lookup(InitialContext.java:417)
> at
> org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.setProperties(JndiDataSourceFactory.java:52)
> \u201c
>
> Where the \u201c org.apache.ibatis.datasource.jndi.JndiDataSourceFactory.\u201d is
> a non-OSGi bundle. After debugging I see the failure happens in
> Utils#doGetBundleContext, when it does the \u201cObject bc = env ==
> null?null:env.get("osgi.service.jndi.bundleContext");\u201d, wondering if I
> am missing any environment property I miss to set.
>
> -Kamesh
--
Jean-Baptiste Onofr�
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com