Announcement Announcement Module
Collapse
No announcement yet.
calling beans defined in action-servlet.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • calling beans defined in action-servlet.xml

    Hello,

    I'm using AppFuse example application.
    I'm trying to call a bean defined in action-servlet.xml in StartupListener.java.
    Unfortunately I receive nullPointerException: .NoSuchBeanDefinitionException: No bean named 'myBean' is defined


    The example StartupListener is referencing to beans defined in applicationContext-service.xml and it works fine, but how can I use beans defined in action-servlet.xml?

    As attachement is two files concerned. Those 2 files are from Appfuse exmaple application that I have modified.

  • #2
    did you add in web.xml dispatcherservler and ContextLoaderListener ?

    Comment


    • #3
      You cannot access beans defined in the servet from a Listener. (Although you might get some access depending on your servlet container). Listeners are instantiated BEFORE servlets so lifecycle technical speaking servlets might not yet be available.

      The only thing you can do is access beans from the Root context (i.e. ContextLoaderListener loaded beans).

      Comment


      • #4
        Originally posted by duardito View Post
        did you add in web.xml dispatcherservler and ContextLoaderListener ?
        That was my mistake. I added this and now it works! Thanks.

        Comment

        Working...
        X