Can I use Spring JMX connectors with JBoss EAP?

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform 6.x

Issue

I would like to use Spring JMX to invoke a MBean.

EAP does not expose jmx over rmi but with remoting-jmx. However, when we attempt to use this with spring-jmx component I get the following stack trace even though I have followed the steps in the document "MalformedURLException Unsupported protocol remoting-jmx when JMX client tries to connect to JBoss EAP 6 MBean Server" to include org.jboss.remoting-jmx as a dependency to my deployment and the Spring module that I've installed on JBoss EAP.

java.net.MalformedURLException: Unsupported protocol: remoting-jmx
	at javax.management.remote.JMXConnectorServerFactory.newJMXConnectorServer(JMXConnectorServerFactory.java:342) [rt.jar:1.7.0_17]
	at org.springframework.jmx.support.ConnectorServerFactoryBean.afterPropertiesSet(ConnectorServerFactoryBean.java:154) [org.springframework.context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571) [org.springframework.beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509) [org.springframework.beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]

Resolution

Use spring-integration which includes jmx capabilities.

Here's an extract from a Spring beans configuration that uses Spring jmx capabilities from spring-integration

	<bean id="clientConnector"
		class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
		<property name="serviceUrl" value="service:jmx:remoting-jmx://myJbossInstance:9999" />
	</bean>
	<context:component-scan base-package="org.jboss.example.packages.to.scan" />

	<bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
		<property name="objectName" value="bean:name=testBean" />
		<property name="proxyInterface" value="org.jboss.examples.test.IJmxTest" />
		<property name="server" ref="clientConnector" />
	</bean>

Root Cause

The main problem is what version of Spring do you want to use?

Spring-jmx is what was used about 8 or 9 years ago and will not work with the modern versions of Spring. If you must use spring-jmx you should use the older version of Spring-framework (2.0 / 2.5) and that will require you to use Snowdrop to get it to work on JBoss. This is not recommended because spring-jmx is no longer around and has not a release since 2008.

However if you just want the JMX feature with MBeans then using the latest version of spring-framework and spring-integration, which includes Spring jmx capabilities. This feature in Spring however is not supported on JBoss EAP as it's not been tested 1^. Spring 4.x works much better with JBoss than older versions of Spring.

Please take a look at Content from docs.spring.io is not included.2^ and Content from projects.spring.io is not included.3^.


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.