To enable JMS cache invalidation in a dd4t-2.0 webapp, we need to add below bean in the Spring configuration of webapp. For Details check here
<bean id="jmsTransportListener"
class="org.dd4t.core.caching.jms.impl.JMSTransportListener"/>
Now JMSTransportListener
class does import org.apache.activemq.transport.TransportListener
package org.dd4t.core.caching.jms.impl;
import org.apache.activemq.transport.TransportListener;
import javax.annotation.Resource;
import java.io.IOException;
public class JMSTransportListener implements TransportListener {
...
.....
}
This creates issues when we are using any other JMS server and not ActiveMQ it throws Error java.lang.NoClassDefFoundError: org/apache/activemq/transport/TransportListener
Error Logs below:
WARN AnnotationConfigWebApplicationContext:546 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myproject.testapp.web.interceptor.CommonRequestAttributesInterceptor com.myproject.testapp.web.config.WebConfig.commonRequestAttributesInterceptor; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.dd4t.core.caching.jms.impl.JMSTransportListener] for bean with name 'jmsTransportListener' defined in class path resource [dispatcher-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/apache/activemq/transport/TransportListener
ERROR ContextLoader:353 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myproject.testapp.web.interceptor.CommonRequestAttributesInterceptor com.myproject.testapp.web.config.WebConfig.commonRequestAttributesInterceptor; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.dd4t.core.caching.jms.impl.JMSTransportListener] for bean with name 'jmsTransportListener' defined in class path resource [dispatcher-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/apache/activemq/transport/TransportListener
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
Is there any clean way to fix this issue rather than adding ActiveMQ dependency in the pom.xml
because I do not want to use any references of ActiveMQ if that is not part of project implementation. Any thoughts on same are most welcomed