You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Christian Schneider <ch...@die-schneider.net> on 2011/08/31 17:20:43 UTC

Using the jmxmp jmx remote protocol in OSGi

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


Re: Using the jmxmp jmx remote protocol in OSGi

Posted by Caspar MacRae <ea...@gmail.com>.
Hi Christian,

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

cheers,
Caspar



On 31 August 2011 16:20, Christian Schneider <ch...@die-schneider.net>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
>
>

Re: Using the jmxmp jmx remote protocol in OSGi

Posted by stegven <ma...@sas.com>.
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().

--
View this message in context: http://karaf.922171.n3.nabble.com/Using-the-jmxmp-jmx-remote-protocol-in-OSGi-tp3298676p3564868.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Using the jmxmp jmx remote protocol in OSGi

Posted by Freeman Fang <fr...@gmail.com>.
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]

[1]https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk/locator/
[2]https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk/stax-api-1.0/

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
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com