• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Bean from another application context to be referred in my application context

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two application context files. I want to refer a bean in first application context in the second application context. When I do this, I am getting a NoSuchBeanDefintionException.

How do I go about it?
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on the relationship between your contexts. If there is a parent child relationship that the child can see the parent but not vice versa. Assuming the beans are in the same context (not the same as the same .xml file) then you should be able to just use



from the reference docs

Specifying the target bean through the bean attribute of the <ref/> tag is the most general form, and
allows creation of a reference to any bean in the same container or parent container, regardless of whether
it is in the same XML file. The value of the bean attribute may be the same as the id attribute of the
target bean, or as one of the values in the name attribute of the target bean.



Alternatively if your second second application context is just a new file you created to split things up you will need to import it.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what exact requirement do you want? you want to refer bean in two applicaton contexts?
or one by one you wanna refer?
and also send full stack trace?
reply
    Bookmark Topic Watch Topic
  • New Topic