• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown

@EnableJms not working

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've annotated my Configuration class with @EnableJms and Spring doesn't seem to be picking up my JMS endpoint. Can someone point me in the right direction?

When I run the class I am expecting the JMS messages to start printing to the console. They don't print because it doesn't seem to be loading my JMSListener.

Here's my config class:

public class MyConfig {

public JndiTemplate jndiTemplate() {
JndiTemplate jndiTemplate = new JndiTemplate();
Properties jndiProps = new Properties();

jndiProps.setProperty("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
jndiProps.setProperty("java.naming.provider.url", "t3://app1.qarc1.blahblahblah.com:7201"); // t3://serverAddress:port
jndiProps.setProperty("java.naming.security.principal", "user"); // injected from properties file username
jndiProps.setProperty("java.naming.security.credentials", "password"); //injected from properties file password

return jndiTemplate;

public JndiDestinationResolver destinationResolver() {
JndiDestinationResolver destinationResolver = new JndiDestinationResolver();
return destinationResolver;

public JndiObjectFactoryBean jmsConnectionFactory() {
JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();

jndiObjectFactoryBean.setJndiName("jms/MyQueueConnectionFactory"); // connectionFactory name.

return jndiObjectFactoryBean;

public TransactionAwareConnectionFactoryProxy connectionFactoryProxy() {
return new TransactionAwareConnectionFactoryProxy((ConnectionFactory) jmsConnectionFactory().getObject());

public DefaultJmsListenerContainerFactory myContainerFactory() {
DefaultJmsListenerContainerFactory factory =
new DefaultJmsListenerContainerFactory();
return factory;


And here's my JMS endpoint:

public class QueueMessageReceiver {

@JmsListener(containerFactory = "myContainerFactory", destination = "jms/MyQueue")
public void onMessage(String message) {

try {
}catch(Exception e){



And my main class:

public class App
public static void main( String[] args ) throws InterruptedException
ApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class);
Thread.sleep(1000 * 60);

Now If I take the exact same code and add this to my MyConfig then the messages start appearing:

public QueueMessageReceiver queueMessageReceiver() {
return new QueueMessageReceiver();

But I shouldn't need that with the @EnableJms annotation right?
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic