I found the solution for this problem. Since it was not able to register the Mbeans we need to override the jmx-context.xml which scans for jmx Mbeans with different domain name.
Create jmx-context.xml in one of your batch project under /META-INF/spring/batch/override/ directory with overridden context:mbean-export for scan & int-jmx:mbean-export for integrating Mbeans like following -
/META-INF/spring/batch/override/jmx-context.xml -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application.mybatch" server="mbeanServer" />
<context:mbean-export default-domain="spring.application.mybatch" server="mbeanServer" />
</beans>
Make sure that you change the default-domain with unique name for this spring batch project. After implementing this solution I have both the batch applications running simultaneously in single cluster inside Weblogic domain.
It’s important to put jmx-context.xml under /META-INF/spring/batch/override/ as webapp-config.xml you import in your servlet.xml file, for configuring admin console, imports all the *.xml from this override folder & this can be used to override any default configuration. Just for reference I have copied here contents of webapp-config.xml from spring-batch-admin-manager-resources jar which should be pulled in as dependency in your project.
/org/springframework/batch/admin/web/resources/webapp-config.xml -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- Workaround for INT-1831 -->
<bean id="dummy" class="java.util.Date"/>
<import resource="classpath*:/META-INF/spring/batch/bootstrap/**/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/override/**/*.xml" />
<bean id="parameterUnpackerFilter" class="org.springframework.batch.admin.web.filter.ParameterUnpackerFilter">
<property name="prefix" value="unpack_"/>
<property name="putEmptyParamsInPath" value="true"/>
</bean>
</beans>
Just in case if you are wondering where we import this webapp-config.xml, I have put down the contents of servlet.xml for configuring batch admin console, which you load on start-up in web.xml of your project.
/WEB-INF/config/spring-beans/servlet.xml -
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Spring Batch Admin -->
<import resource="classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml"/>
<import resource="classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml"/>
<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
</beans>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…