MC service does not maintain properties
thomas.diesler May 7, 2010 2:29 PMCurrently there are multiple failures when the testsuite is run against the AS.
https://jira.jboss.org/jira/browse/JBOSGI-326
In this particular case the client API uses
context.getServiceReferences("javax.management.MBeanServer", null)
which discovers multiple MBeanServers one of which it cannot obtain the properties from.
------------------------------------------------------------------------------- Test set: org.jboss.test.osgi.example.simple.husky.SimpleHuskyTestCase ------------------------------------------------------------------------------- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.834 sec <<< FAILURE! testSimpleBundle(org.jboss.test.osgi.example.simple.husky.SimpleHuskyTestCase) Time elapsed: 1.761 sec <<< ERROR! java.lang.IllegalArgumentException: Service with id [171959] Not Found at org.apache.aries.jmx.util.FrameworkUtils.resolveService(FrameworkUtils.java:106) at org.apache.aries.jmx.framework.ServiceState.getProperties(ServiceState.java:101) ... at $Proxy125.getProperties(Unknown Source) at org.jboss.osgi.jmx.internal.ServiceStateExt.getProperties(ServiceStateExt.java:194) ... at $Proxy7.getProperties(Unknown Source) at org.jboss.osgi.testing.internal.RemoteRuntime.getServiceReferences(RemoteRuntime.java:200) at org.jboss.osgi.testing.internal.OSGiRuntimeImpl.addCapability(OSGiRuntimeImpl.java:92) at org.jboss.osgi.testing.internal.OSGiRuntimeImpl.addCapability(OSGiRuntimeImpl.java:85) at org.jboss.test.osgi.example.simple.husky.SimpleHuskyTestCase.setUp(SimpleHuskyTestCase.java:68) asdf
2010-05-07 09:46:59,567 TRACE [org.jboss.osgi.jmx.internal.ServiceStateExt] (RMI TCP Connection(4)-127.0.0.1) getServices [clazz=javax.management.MBeanServer,filter=null] 2010-05-07 09:46:59,575 TRACE [org.jboss.osgi.jmx.internal.ServiceStateExt] (RMI TCP Connection(4)-127.0.0.1) Added service: javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=SERVICE,items=((itemName=BundleIdentifier,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=Identifier,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=UsingBundles,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.Long;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.Long),primitiveArray=false)),(itemName=objectClass,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.String;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.String),primitiveArray=false)))),contents={BundleIdentifier=0, Identifier=171959, UsingBundles=[Ljava.lang.Long;@149650, objectClass=[Ljava.lang.String;@1986b90}) 2010-05-07 09:46:59,575 TRACE [org.jboss.osgi.jmx.internal.ServiceStateExt] (RMI TCP Connection(4)-127.0.0.1) Added service: javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=SERVICE,items=((itemName=BundleIdentifier,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=Identifier,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=UsingBundles,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.Long;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.Long),primitiveArray=false)),(itemName=objectClass,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.String;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.String),primitiveArray=false)))),contents={BundleIdentifier=7, Identifier=76690, UsingBundles=[Ljava.lang.Long;@1bdda87, objectClass=[Ljava.lang.String;@1560732})
I suppose it is ok that multiple services are discovered, one of which is non-osgi. What needs to get fixed here is that the MC service provides properties in the same way as the OSGi service. The getServiceReference("javax.management.MBeanServer") API however needs to choose a single instance however. More generally the sorting of multiple service references needs to be defined in the context of service mix.
I suggest we provide/generate proper service metadata (i.e. service id) that can be used by the standard OSGi algorithms. The service ranking has higher priority than the service id. Should we perhaps register MC services with lower ranking than OSGi services instead of relying on service id.
This is related to http://community.jboss.org/thread/151237