Using the jmxmp jmx remote protocol in OSGi

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using the jmxmp jmx remote protocol in OSGi

cschneider
I am porting some jmx code to karaf.

The code wants to offer a remote jmx connector using the jmxmp protocol.
This is implemented in the jmxremote_optional.jar in the jdk.
The problem is that the jmx impl scans the class path META-INF/services
for protocol implementations. This does not work in OSGi.

So I guess I either have to tweak the classpath or have to add the
protocol programmatically.

Did anyone already do one of the variants for remote jmx and can help me
get this working?

Christian

--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply | Threaded
Open this post in threaded view
|

Re: Using the jmxmp jmx remote protocol in OSGi

earcam

Hi Christian,

Some work has been done getting ServiceLoader working in an OSGi context, see http://coderthoughts.blogspot.com/2011/08/javautilserviceloader-in-osgi.html which links to the Aries project.  Might help.

cheers,
Caspar



On 31 August 2011 16:20, Christian Schneider <[hidden email]> wrote:
I am porting some jmx code to karaf.

The code wants to offer a remote jmx connector using the jmxmp protocol. This is implemented in the jmxremote_optional.jar in the jdk.
The problem is that the jmx impl scans the class path META-INF/services for protocol implementations. This does not work in OSGi.

So I guess I either have to tweak the classpath or have to add the protocol programmatically.

Did anyone already do one of the variants for remote jmx and can help me get this working?

Christian

--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Reply | Threaded
Open this post in threaded view
|

Re: Using the jmxmp jmx remote protocol in OSGi

Freeman-2
In reply to this post by cschneider
Hi Christian,

The normal java SPI mechanism doesn't work in OSGi container, so in Servicemix we wrap some spec bundle which need use SPI to find the implementations by using OSGiLocator.

You can find the OSGiLocator code here[1], and an example how a spec bundle use this OSGiLocator[2]


Freeman
On 2011-8-31, at 下午11:20, Christian Schneider wrote:

I am porting some jmx code to karaf.

The code wants to offer a remote jmx connector using the jmxmp protocol. This is implemented in the jmxremote_optional.jar in the jdk.
The problem is that the jmx impl scans the class path META-INF/services for protocol implementations. This does not work in OSGi.

So I guess I either have to tweak the classpath or have to add the protocol programmatically.

Did anyone already do one of the variants for remote jmx and can help me get this working?

Christian

--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


---------------------------------------------
Freeman Fang

FuseSource
Twitter: freemanfang









Reply | Threaded
Open this post in threaded view
|

Re: Using the jmxmp jmx remote protocol in OSGi

stegven
If all you need to do is use the JMXMP connector from within OSGi, and you don't care about dynamic support for other protocols, here's a really simple solution that I am using. Simply make sure your copy of jmxremote_optional.jar has proper OSGi headers in its manifest, add that jar as a plug-in to your project, and in the code that creates your JMX connector server, add this:

        Map<String, Object> env = new HashMap<String, Object>();
        env.put(JMXConnectorServerFactory.PROTOCOL_PROVIDER_PACKAGES,
                "com.sun.jmx.remote.protocol");


When you invoke JMXConnectorServerFactory.newJMXConnectorServer, provide the above map as the second argument.

You can use the same thing for creating a connector client with JMXConnectorFactory.newJMXConnector().