Hi,
I am trying to run the tuscany framework (milestone 4) in the glassfischv3
web container. So far I managed to start everything without errors or
exceptions...
Trying some examples for the tuscany framework I run into a NPE:
java.lang.NullPointerException
at
com.sun.hk2.component.ExistingSingletonInhabitant.<init>(ExistingSingletonIn
habitant.java:54)
at
org.jvnet.hk2.osgiadapter.HK2Main$HK2ServiceTrackerCustomizer.addingService(
HK2Main.java:212)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker
.java:896)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.j
ava:840)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallbac
k(EventDispatcher.java:878)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDi
spatcher.java:732)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispat
cher.java:662)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3587)
at org.apache.felix.framework.Felix.access$000(Felix.java:40)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:625)
at
org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.j
ava:97)
at org.apache.felix.framework.Felix.registerService(Felix.java:2711)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:252)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:230)
at
org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProvide
r$1.run(OSGiImplementationProvider.java:125)
at
org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProvide
r$1.run(OSGiImplementationProvider.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at
org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProvide
r.start(OSGiImplementationProvider.java:120)
at
org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl.start(Compo
siteActivatorImpl.java:510)
at
org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl.start(Compo
siteActivatorImpl.java:475)
at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:148)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiServiceImporter.impo
rtService(OSGiServiceImporter.java:71)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.RemoteServiceAdminImpl.i
mportService(RemoteServiceAdminImpl.java:265)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl.impo
rtService(TopologyManagerImpl.java:369)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl.endp
ointAdded(TopologyManagerImpl.java:336)
at
org.apache.tuscany.sca.osgi.service.discovery.impl.AbstractDiscoveryService.
triggerCallbacks(AbstractDiscoveryService.java:197)
at
org.apache.tuscany.sca.osgi.service.discovery.impl.AbstractDiscoveryService.
endpointChanged(AbstractDiscoveryService.java:274)
at
org.apache.tuscany.sca.osgi.service.discovery.impl.DomainDiscoveryService.en
dpointAdded(DomainDiscoveryService.java:90)
at
org.apache.tuscany.sca.core.assembly.impl.EndpointRegistryImpl.addEndpoint(E
ndpointRegistryImpl.java:50)
at
org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl.start(Compo
siteActivatorImpl.java:543)
at
org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl.start(Compo
siteActivatorImpl.java:475)
at org.apache.tuscany.sca.node.impl.NodeImpl.start(NodeImpl.java:148)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiServiceExporter.expo
rtService(OSGiServiceExporter.java:96)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.RemoteServiceAdminImpl.e
xportService(RemoteServiceAdminImpl.java:123)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl.expo
rtService(TopologyManagerImpl.java:181)
at
org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl.addi
ngService(TopologyManagerImpl.java:147)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker
.java:896)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.j
ava:840)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallbac
k(EventDispatcher.java:878)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDi
spatcher.java:732)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispat
cher.java:662)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3587)
at org.apache.felix.framework.Felix.access$000(Felix.java:40)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:625)
at
org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.j
ava:97)
at org.apache.felix.framework.Felix.registerService(Felix.java:2711)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:252)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:230)
at
calculator.dosgi.operations.impl.OperationsActivator.start(OperationsActivat
or.java:68)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
a:640)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
at
org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:1
14)
at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activa
tor.java:286)
at org.apache.felix.shell.remote.Shell.run(Shell.java:109)
at java.lang.Thread.run(Thread.java:637)
I have already posted that problem on the tuscany mailing list and got
following answer:
> Further investigation shows that GlassFish (HK2) is a bit aggressive to
> get the service object when the OSGi service is registered. We use a
> ServiceFactory to create a service proxy for the client bundle that calls
> BundleContext.getService(ServiceReference ...). As a result, the bundle is
> the HK2 which doesn't have access to the SCA component business interface.
> So a null is returned to the getService() call and HK2 doesn't like that.
>
> public Object getService(Bundle bundle, ServiceRegistration
> registration) {
> Class<?> interfaceClass = null;
> try {
> interfaceClass = bundle.loadClass(interfaceName);
> } catch (ClassNotFoundException e) {
> return null;
> }
> ...
> }
>
> I'm not sure if you should get GlassFish to fix the NPE or we should try
> to return a non-null dummy object to work around it. My understanding of
> the OSGi API [1] is that it's possible that getService() returns a null.
>
> [1]
>
http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html#getServi
ce(org.osgi.framework.ServiceReference)
Maybe there is a work around for that problem?
Does anyone has experience in combining glassfish and tuscany?
Thanks
Alex