Win a copy of Head First Android this week in the Android 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 ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Beans from resources.groovy not beging picked up by DI

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In order to define my beans using Spring DSL, I have moved my bean definitions from resources.xml to resources.groovy. After doing so my beans are not automatically injected to my controllers and services. Previously, with resources.xml, without explicitly wiring the beans if I define something like



in the controllers or services code, myBeanName would be automatically injected. But this is not happening now.

Is there any other configuration or setting we have to do in addition to just moving the definitions from resources.xml to resources.groovy

The beans in .groovy are being initiated and loaded by the container, because if I make any mistake in the definition, it complains. The only thing is that the beans are not being injected to controllers.

Regards,
Paras
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are these beans classes you've pulled in to your grails app via a JAR file or possibly sitting under you src/java folder? Or are they groovy classes. If they are groovy classes, where do they reside?
 
Paras Jain
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Gregg,

Most of these are Java classes pulled from one of the jar.
 
author
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does your resources.groovy file look like?
 
Paras Jain
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,
Thanks for the reply. It is working now. Actually one of the bean which had backslashes \ was not working. I kept that one in resources.xml and moved everything else to resources.groovy.

The culprit bean looks like this



I tried to escape the backslashes with \\ but it was not working. So I left that one in .xml and moved everything else to .groovy. I found that this one is the real culprit by just hit and trial. In the logs there was nothing which points me to this.
 
Peter Ledbrook
author
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know that you can use / as a string delimiter? If you use that, you don't need to escape backslashes. For example:


Cheers,

Peter
 
Paras Jain
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peter.

I tried using / as the delimiter. But in my string I have curly braces too. These curly braces don't seem to be escaped by /

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic