This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

@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://"); // t3://serverAddress:port
jndiProps.setProperty("", "user"); // injected from properties file username
jndiProps.setProperty("", "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?
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic