Announcement Announcement Module
Collapse
No announcement yet.
question on accessing the spring context from business tier Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • question on accessing the spring context from business tier

    Spring newbie here....

    I have been baffled with the following -
    I am developing a web application using spring 2.5.
    I am using the following file name for my spring context springweb-test.xml
    and I also have applicationContext.xml (but its blank for now). Both are under /WEB-INF.
    Now here is what I dont get - I am currently using one controller
    for which I have injected some simple properties inside
    the springweb-test.xml file. When the app starts up (on weblogic).
    My controller is initiated fine and has available to its injected properties from springweb-test.xml.
    I wired in simple property "myname" and the controller is able to get this property because i can print it to the console.
    Now in my business tier I created a new java class.
    I also registered this class in springweb-test.xml and injected into
    it a simple property. Now when I try to get this property from within this class, its giviing a null. It was my understanding that in a web application, as long as you have defined all you're beans and their properties in
    the spring context file, you're classess should be able to have these properties injected and avialable to them. This is not the case for my business tier class, I keep get null for the injected property.
    I have declared both in web.xml context params. Interestingly
    the controller is always getting its property available and I am able to print it to the console.
    But for my other businesss class which is just a POJO, it does not
    get its DI property. When i print it to the console it gives NULL.
    Does this make sense...

    SImply put how does a POJO for a web application within the business tier

    get its properties from the spring context? DO you have to make this POJO

    aware of the spring context in order to get its DI properties? I thought for a

    web application spring did that all for you. All need to do is just wire up the beans in the spring context file and voila....these beans/properties are available???

  • #2
    Hi ,

    pls post your code,

    Comment


    • #3
      Most likely you're not using the spring managed instance of the POJO. Like sami said, post your code please.

      Comment

      Working...
      X