This discussion is archived
8 Replies Latest reply: Apr 19, 2012 1:05 AM by 164415 RSS

WebLogic 12c don't call @PostContruct method at JSF2 ManagedBeans

AdamM. Newbie
Currently Being Moderated
Greetings...

I'm developing J6EE + JSF2 + CDI application.
In summary, the ManagedBean has a method with annotation @PostConstruct, but these are never called.
After of doing several test, i found that if the project have the beans.xml archive in WEB-INF/ directory, the app when create the managedBean then don't call the method with @PostConstruct.
If remove the beans.xml archive the app, behave normally and call method with @PostConstruct.


I need to use beans.xml always, because i use others CDI capabilities in the project.

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.

I develop a very basic web app, for doing test.

XHTML
    <h:head>
        <title>Prueba</title>
    </h:head>
    <h:body>
        #{beanPrueba.hola_mundo}
    </h:body>
ManagedBean
@ManagedBean
@ViewScoped
public class BeanPrueba implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private String hola_mundo;
    
    public BeanPrueba(){
        this.inicializar();
    }
    
    private void inicializar(){
        hola_mundo =" Enter to construct - ";
    }
    
    
    @PostConstruct
    public void inicializarPostConstruct(){
        this.hola_mundo +=" Enter to PostConstruct :D ";
    }

    public String getHola_mundo() {
        return hola_mundo;
    }

    public void setHola_mundo(String hola_mundo) {
        this.hola_mundo = hola_mundo;
    }
}
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.


Why bean.xml file that causes this behavior in JSF ManagedBeans on WebLogic??????

Someone, any idea???

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points