2

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?

Maozturk
  • 339
  • 1
  • 5
  • 20
  • 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 Mar 24 '12 at 18:16
  • 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. Mar 27 '12 at 16:09
  • Well, Weblogic is an odd beast. Sorry that I can't be of more assistance. Have never really used Weblogic. – BalusC Mar 27 '12 at 16:13
  • Really, it is true. WebLogic does not behave like other application servers. Thanks for you assistance.. – Adam M. Gamboa G. Mar 27 '12 at 18:29

1 Answers1

2

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...

  • 1
    First, download the patch from Oracle. I think you must have a Oracle account for do this. Then, be sure, the weblogic is shutdown, unzip the patch in path ':C:\Oracle\Middleware\utils\bsu\cache_dir'. Run bsu.cmd or bsu.sh, the smart update window open, select the patch that appears, and follow de instructions (next... next... next... accept, etc etc)... Start the weblogic server, and ready. Patch has been applied... More info here [SmartUpdateManual](http://docs.oracle.com/cd/E14759_01/doc.32/e14143.pdf) See section 3.3.1, for unzipping patch, and section 4, for applying patch... – Adam M. Gamboa G. Jul 31 '12 at 22:11