0
votes

I was getting the below error when I enabled WireTap interceptor for one of the channels. The OotB WireTap interceptor was not loading, and throwing the below exception during server startup. The spring-integration version was 3.x

org.springframework.web.context.ContextLoader (ContextLoader.java:319) - Context initialization failed [java] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exporter' defined in resource loaded from byte array: Invocation of init method failed; nested exception is org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.integration.channel.interceptor.WireTap@5596e217] with key 'org.springframework.integration.channel.interceptor.WireTap#0'; nested exception is javax.management.MalformedObjectNameException: Key properties cannot be empty [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [java] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [java] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [java] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) [java] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [java] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [java] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [java] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [java] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [java] at org.broadleafcommerce.common.web.extensibility.MergeContextLoaderListener.contextInitialized(MergeContextLoaderListener.java:50) [java] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) [java] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) [java] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [java] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) [java] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) [java] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) [java] at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649) [java] at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1585) [java] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [java] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [java] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [java] at java.lang.Thread.run(Thread.java:745) [java] Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.integration.channel.interceptor.WireTap@5596e217] with key 'org.springframework.integration.channel.interceptor.WireTap#0'; nested exception is javax.management.MalformedObjectNameException: Key properties cannot be empty [java] at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:602) [java] at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:527) [java] at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:413) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485) [java] ... 26 more

1

1 Answers

0
votes

I think this error happens in spring-integration v3. Below is how I resolved it.

  • Create a custom class extending WireTap, define the spring bean.
  • Use ManagedResource annotation to provide the name, this should match spring bean name.
  • Add the interceptor to channel that needs to be tapped.

Post this, I was able to tap the channel successfully.

You don't need override any method in the custom class, just add the constructors similar to WireTap class. In simple words, I created my own interceptor class and used it to tap the channel.

@ManagedResource(objectName = "com.xyz.channel.interceptor:name=wireTapExtended") public class WireTapExtended extends WireTap

<int:channel id="channelIdToTap">
    <int:interceptors>
        <int:ref bean="wireTapExtended" />
    </int:interceptors>
</int:channel>
<bean id="wireTapExtended" name="wireTapExtended" class="com.xyz.channel.interceptor.WireTapExtended">
    <constructor-arg name="channel" ref="channelIdToTap" />
</bean>

I see this is only MBean config

<bean id="jmxExporterSite" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="server" ref="mbeanServer" /> <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/> <property name="beans"> <map> <entry key="SpringBeans:name=hibernateStatisticsMBeanSite" value-ref="hibernateStatisticsMBeanSite" /> <entry key="SpringBeans:name=ehCacheManagerMBean" value-ref="cacheManager" /> </map> </property> </bean>