1

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

1

There's no generic Transport Listener specification in the JMS Api / specification, so hence it's not possible to keep this part generic.

You should be able simply remove the transportListener and the references to it and then invalidation will still work.

1

I guess the conclusion maybe is that the name of the class JMSTransportListener should possibly have been ActiveMQTransportListener instead, and if you are not intenting to use ActiveMQ, you should implement your own jmsTransportListener.

However I'm not completely sure because you fail to mention what changes you are making to support your other JMS server. Note the org.apache.activemq.transport.TransportListener is just an interface, if that is a universal JMS Transport Listener interface (I don't know), including the ActiveMQ dependency in the pom.xml would be considered acceptable. But again, you failed to supply the details in your question for me to make this conclusion (maybe you can edit your question and supply a bit more detail about that).

  • Hi Bart; I was expecting DD4T2.0-Java to be generic and support JMS Cache Invalidation with any JMS server used. And allows this by using relevant conf/class names in the bean entries as per the JMS server used. Is there any configuration available that can work for JMS server like OSB. – Gulshan Thakur Jun 1 '17 at 18:51
  • @GulshanThakur I don't know actually, the one thing I do know is that technically the JMS messages are not an open API, so while it is very nice and the most useful cache invalidation, it is also a bit of a hack. So I'm guessing you have some work to do yourself, good thing it's open source. – Bart Koopman Jun 1 '17 at 19:04
0

After skipping the reference for JMSTransportListener it works and complete working configuration is present in below post

How to configure JMS ConnectionFactory in DD4T2.0-Java webapp when its OSB as JMS server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.