Hi All,

I was trying out deploying a set of server-side bundles in Geronimo for last couple of days and had some issues getting access to osgi http service from my bundles.

So as a secondary option;
I created a web-app mode application to deploy my bundles in a separate osgi runtime. It's something similar to what's discussed here [1].
What my web-app does is, it starts a osgi-runtime and proxies the http requests coming to the web-app's context to the osgi http service so that the other bundles in the repository can serve the requests via osgi http service.

However after deploying my war file and starting Geronimo I came across a JNDI error [3]. One of the bundles is trying to create a JNDI context and getting a  javax.naming.NoInitialContextException.
This is caused by : javax.naming.NoInitialContextException: Unable to determine caller's BundleContext
    at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:49)

I found out a similar issue reported at [2]. Is this a bug in org.apache.aries.jndi 0.3.0 used in Geronimo? Does anyone have an idea on this?
Appreciate your thoughts.

Thanks,
Dileepa

[1] http://www.eclipse.org/equinox/server/http_in_container.php
[2] https://issues.apache.org/jira/browse/KARAF-304

[3]
[**************************************  ]  97%  27s  Loading crbn                                            [2012-08-28 10:57:41,739] ERROR {org.wso2.carbon.ndatasource.core.DataSourceRepository} -  Error in registering data source: WSO2_CARBON_DB - Error in creating JNDI subcontext 'javax.naming.InitialContext@20828fe4/jdbc: Unable to determine caller's BundleContext
org.wso2.carbon.ndatasource.common.DataSourceException: Error in creating JNDI subcontext 'javax.naming.InitialContext@20828fe4/jdbc: Unable to determine caller's BundleContext
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.checkAndCreateJNDISubContexts(DataSourceRepository.java:243)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerJNDI(DataSourceRepository.java:268)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:389)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:485)
    at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSource(DataSourceManager.java:158)
    at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSources(DataSourceManager.java:130)
    at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.initSystemDataSources(DataSourceServiceComponent.java:168)
    at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.setSecretCallbackHandlerService(DataSourceServiceComponent.java:154)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:367)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:430)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bind(ServiceComponentProp.java:218)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:344)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:588)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:196)
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:328)
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:221)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
    at org.wso2.carbon.securevault.internal.SecretManagerInitializerComponent.activate(SecretManagerInitializerComponent.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:252)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:346)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:588)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:196)
    at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:441)
    at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:213)
    at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:800)
    at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:767)
    at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
    at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: javax.naming.NoInitialContextException: Unable to determine caller's BundleContext
    at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:49)
    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.createSubcontext(InitialContext.java:464)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.checkAndCreateJNDISubContexts(DataSourceRepository.java:241)
    ... 45 more
[**************************************  ]  97%  27s  Loading crbn                                            [2012-08-28 10:57:42,138] ERROR {org.wso2.carbon.user.core.internal.Activator} -  Cannot start User Manager Core bundle
java.lang.RuntimeException: Error in looking up data source: Unable to determine caller's BundleContext
    at org.wso2.carbon.user.core.util.DatabaseUtil.lookupDataSource(DatabaseUtil.java:92)
    at org.wso2.carbon.user.core.util.DatabaseUtil.createRealmDataSource(DatabaseUtil.java:178)
    at org.wso2.carbon.user.core.util.DatabaseUtil.getRealmDataSource(DatabaseUtil.java:72)
    at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:92)
    at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:128)
    at org.wso2.carbon.user.core.internal.Activator.startDeploy(Activator.java:66)
    at org.wso2.carbon.user.core.internal.BundleCheckActivator.start(BundleCheckActivator.java:61)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:389)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1130)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: javax.naming.NoInitialContextException: Unable to determine caller's BundleContext
    at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:49)
    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.lookup(InitialContext.java:392)
    at javax.naming.InitialContext.doLookup(InitialContext.java:265)
    at org.wso2.carbon.user.core.util.DatabaseUtil.lookupDataSource(DatabaseUtil.java:90)
    ... 21 more



--
Dileepa Jayakody,
Software Engineer, WSO2 Inc.
Lean . Enterprise . Middleware

Mobile : +94777-857616