Jigar Joshi
Jigar Joshi

Reputation: 240966

Grails 2.0.1 : async messaging: `jmsConnectionFactory` compilation error

I have resource.groovy

beans = {
    jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'vm://localhost' }
}

and on run it says

 Running Grails application
| Error 2012-02-24 18:02:13,490 [pool-6-thread-1] ERROR spring.GrailsRuntimeConfigurator  - [RuntimeConfiguration] Unable to load beans from resources.groovy
Message: No such property: org for class: resources
   Line | Method
->>   3 | doCall                    in resources$_run_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   736 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|   569 | beans . . . . . . . . . . in     ''
|   736 | invokeBeanDefiningClosure in     ''
|   569 | beans . . . . . . . . . . in     ''
|   511 | invokeMethod              in     ''
|   303 | innerRun . . . . . . . .  in java.util.concurrent.FutureTask$Sync
|   138 | run                       in java.util.concurrent.FutureTask
|   886 | runTask . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run                       in     ''
^   662 | run . . . . . . . . . . . in java.lang.Thread
| Error 2012-02-24 18:02:16,537 [pool-6-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'delayedCreateMessageJmsListenerContainer': Cannot resolve reference to bean 'jmsConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jmsConnectionFactory' is defined
Message: Error creating bean with name 'delayedCreateMessageJmsListenerContainer': Cannot resolve reference to bean 'jmsConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jmsConnectionFactory' is defined

It worked all well before upgrade, after updating to 2.0.1 it failed with this error, I am using groovy compiler 1.8.6

Upvotes: 2

Views: 2647

Answers (2)

James Allman
James Allman

Reputation: 41208

I have always configured ActiveMQ in Grails as follows:

BuildConfig.groovy

dependencies {
    compile 'org.apache.activemq:activemq-core:5.5.0'
}

resources.groovy

import org.springframework.jms.connection.SingleConnectionFactory
import org.apache.activemq.ActiveMQConnectionFactory

beans = {
    jmsConnectionFactory(SingleConnectionFactory) {
        targetConnectionFactory = { ActiveMQConnectionFactory cf ->
            brokerURL = 'vm://localhost'
        }
    }
}

Upvotes: 6

chrislatimer
chrislatimer

Reputation: 3560

It may be a ClassNotFound error in disguise. Try adding an import statement:

import org.apache.activemq.ActiveMQConnectionFactory

and see if you get a ClassNotFoundError, if so then it's just a matter of tracking down the missing dependency.

Upvotes: 2

Related Questions