2
votes

In summary, method with @PostConstruct is not call by JSF on WebLogic12c, on managed bean.

I have a very basic application.

Technologies used: JSF2.0

Application Server: WebLogic 12c

Java

@ManagedBean
@ViewScoped

public class BeanTest implements Serializable {

    private String hola_mundo = "";

    public BeanTest(){
        this.init();
    }

    private void init(){
        hola_mundo +=" Enter to construct - ";
    }


    @PostConstruct
    public void initPostConstruct(){
        hola_mundo +=" Enter to PostConstruct - ";
    }

    public String getHola_mundo() {
        return hola_mundo;
    }

    public void setHola_mundo(String hola_mundo) {
        this.hola_mundo = hola_mundo;
    }
}

XHTML

<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    Test
    <br/>
    #{beanTest.hola_mundo}
</h:body>

When the managed bean is instance for JSF, The managed bean beanTest is create, (Enter at normal constructor) but don't enter (ignore, don't call) method with PostConstruct.

The text displayed with WebLogic: Enter to Construct The expected text, but not displayed with WL: Enter to Construct - Enter to PostConstruct

The application has been deployed on other application servers:

  • GlassFish 3.1.1
  • GlassFish 3.1.2
  • Tomcat 7.0.22

And show the expected result.

The problem only happens with JSF managed beans(request, session, view, application), if use CDI, the PostConstruct is called. But I need to use the JSF ViewScoped annotation.

Someone with any idea?

1
This problem is Weblogic specific. I can't tell from own experience, but I've read from earlier posts/references that Weblogic will somehow fail to invoke @PostConstruct on JSF artifacts whenever the JSF libraries are supplied along with the web application (in the /WEB-INF/lib folder) instead of that the web application uses Weblogic's own supplied JSF libraries. - BalusC
It's interesting because in fact my application does not use the libraries in WEB-INF/lib, you are instructed to use the application server. Weblogic 12c gives me JSF libraries now (and these are what I use) to avoid problems that occurred in previous versions of weblogic (10.3g and 11g). I also do test, adding to libraries in WEB-INF/lib, and no good result was observed. - Adam M. Gamboa G.
Well, Weblogic is an odd beast. Sorry that I can't be of more assistance. Have never really used Weblogic. - BalusC
Really, it is true. WebLogic does not behave like other application servers. Thanks for you assistance.. - Adam M. Gamboa G.

1 Answers

2
votes

Well, the problem is solved.

This is a bug reported, and already has a patch.

Bug: 13703600
Patch : SU Patch [UXPH]: WLS12C - POSTCONSTRUCT NOT CALLED ON @MANAGEDBEAN BEANS IN JSF APP.

I apply the patch and the problem was fixed...