Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: 1.2_09
    • Fix Version/s: unscheduled
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      800

      Description

      The @PostConstruct function is not called for a managed bean when the function
      is defined in the base class.

      Detail:

      In the base class BaseClass I have a function

      @PostConstruct
      public void BaseClass.init();

      My bean class OuterBean is derived from BaseClass, so it inherits this init
      function and hopefully the @PostConstruct annotation.

      In the old version of JSF, namely 1.2-b20-FCS from April/21/2006, the init()
      function was called. But in the new version of JSF, which is JSF 1.2.9 from
      July/17/2008, init() is not called.

      If in the class OuterBean I add a new function with the annotation, such as

      @PostConstruct
      public void callInit()
      {
      init();
      }

      then it works.

      Does this seem like a bug in JSF 1.2.9?

      I did not find a bug on this issue. There was some discussion of this on the
      java sun forums http://forums.sun.com/thread.jspa?messageID=10432734.

        Activity

        Hide
        Ryan Lubke added a comment -

        What container are you using?

        Show
        Ryan Lubke added a comment - What container are you using?
        Hide
        sn72 added a comment -

        In response to

        > What container are you using?

        INFO: Starting Servlet Engine: Apache Tomcat/6.0.14

        Show
        sn72 added a comment - In response to > What container are you using? INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
        Hide
        Ryan Lubke added a comment -

        Some background. As of 1.2_01 we added an SPI for resource injection/callback
        notification to allow better integration with EE5 containers. Right now, 1.2_09
        supports Tomcat, Jetty, and GlassFish resource injection services out of the box.

        The problem here looks to be in Tomcat's DefaultAnnotationProcessor
        implementation. It only checks the instance's declared methods without moving
        up the class hierarchy.

        As a workaround you can add the following context init parameter to your web.xml:

        <context-param>
        <param-name>com.sun.faces.injectionProvider</param-name>
        <param-value>com.sun.faces.vendor.WebContainerInjectionProvider</param-value>
        </context-param>

        This will force Mojarra to use the WebContainerInjectionProvider (the default
        for the cases where tomcat, jetty, or glassfish isn't detected and no other
        provider is found or configured) instead of the implementation for Tomcat.
        NOTE: This only supports the @PostConstruct and @PreDestroy callbacks.

        Please follow up and confirm that this works for you.

        Show
        Ryan Lubke added a comment - Some background. As of 1.2_01 we added an SPI for resource injection/callback notification to allow better integration with EE5 containers. Right now, 1.2_09 supports Tomcat, Jetty, and GlassFish resource injection services out of the box. The problem here looks to be in Tomcat's DefaultAnnotationProcessor implementation. It only checks the instance's declared methods without moving up the class hierarchy. As a workaround you can add the following context init parameter to your web.xml: <context-param> <param-name>com.sun.faces.injectionProvider</param-name> <param-value>com.sun.faces.vendor.WebContainerInjectionProvider</param-value> </context-param> This will force Mojarra to use the WebContainerInjectionProvider (the default for the cases where tomcat, jetty, or glassfish isn't detected and no other provider is found or configured) instead of the implementation for Tomcat. NOTE: This only supports the @PostConstruct and @PreDestroy callbacks. Please follow up and confirm that this works for you.
        Hide
        sn72 added a comment -

        Yes, this workaround works. To be clear, I added the <context-param> stuff as a
        direct child of <web-app>. So is this the final solution going forward, or will
        there be a fix in a future version like JSF 1.2.10 such that the workaround is
        not necessary?

        Show
        sn72 added a comment - Yes, this workaround works. To be clear, I added the <context-param> stuff as a direct child of <web-app>. So is this the final solution going forward, or will there be a fix in a future version like JSF 1.2.10 such that the workaround is not necessary?
        Hide
        Ryan Lubke added a comment -

        I would recommend logging an issue against Tomcat 6.x's
        DefaultAnnotationProcessor not scanning the class hierarchy for
        @PostConstruct and @PreDestroy annotations.

        Show
        Ryan Lubke added a comment - I would recommend logging an issue against Tomcat 6.x's DefaultAnnotationProcessor not scanning the class hierarchy for @PostConstruct and @PreDestroy annotations.
        Hide
        sn72 added a comment -

        For anyone interested, I wrote a bug against Tomcat 6.x. The URL is

        https://issues.apache.org/bugzilla/show_bug.cgi?id=45869

        Show
        sn72 added a comment - For anyone interested, I wrote a bug against Tomcat 6.x. The URL is https://issues.apache.org/bugzilla/show_bug.cgi?id=45869
        Hide
        Ryan Lubke added a comment -

        The Tomcat folks closed sn72's bug report as a duplicate of [1]. This issue
        will be resolved in Tomcat 6.0.18 and above.

        [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=45285

        Show
        Ryan Lubke added a comment - The Tomcat folks closed sn72's bug report as a duplicate of [1] . This issue will be resolved in Tomcat 6.0.18 and above. [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=45285
        Hide
        sn72 added a comment -

        FYI, I reopened the Tomcat bug is the problem is still there in 6.0.18. Am not
        reopening this bug as yet, just letting you know.

        Show
        sn72 added a comment - FYI, I reopened the Tomcat bug is the problem is still there in 6.0.18. Am not reopening this bug as yet, just letting you know.
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            javaserverfowner
            Reporter:
            sn72
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: