ManagedBean methods are not processed

0

Good morning, I'm the following problem. I have an application that has several ManagedBeans that are working normally. Today I was creating a new bean for testing and this bean does not execute either @PostConstruct or any other method; I created a new project, copied the bean and xhtml and the new project worked, but I would not want to recreate everything again. or would like to know what happened.

Follow the bean:

    package teste;
    import java.io.Serializable;

    import javax.annotation.PostConstruct;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;

    @ManagedBean(name = "testeBean2")
    @ViewScoped
    public class TesteBean2 implements Serializable {
        private static final long serialVersionUID = 1L;

        @PostConstruct
        public void init() {
           System.out.println("aqui estou dentro do bean   ");
        }

        public String getMensagem() {
             System.out.println("chegou aqui ");
             return "bada bada";
        }
    }

Follow test2.xhtml:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"
        xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
    </h:head>
    <h:body>
        <h:form>
            <h:outputText value="aqui #{testeBean2.mensagem}" />
        </h:form>
    </h:body>
    </html>

Important:

  • In a new project it works normal.
  • I'm using Eclipse Mars 2 and Tomcat 8
  • Versions are:
    • javax.faces (Mojarra) = 2.2.8-02
    • javax.servlet-api = 3.1.0
    • primefaces = 5.3
    • primefaces-extensions = 3.2.0
  • Questions 1 - Is it normal from time to time to have to create a new project? 2 - Why does this occur?

        
    asked by anonymous 21.05.2016 / 15:30

    1 answer

    0

    Good morning, in parts I solved the problem

    It was not working in either eclipse or NetBeans.

    I've tried several things:

    • Projec / Build all
    • Project / clean
    • Remove the tomcat project
    • remove tomcat and install again

    Nothing worked!

    The path I made and resolved was:

    • Check for dependency conflict in pom.xml. AND HAD !!!
    • To know this I opened the pom in the eclipse and went to the dependency hierarchy tab, it shows the ones that are in conflict. and I was downgrade / upgrade the versions to make them compatible. Either way, it did not work in eclipse .
    • Test in NetBeans and worked I think it's some eclipse problem

    Thanks for the support and I hope that I have helped someone to solve the same problem as mine.

    If you know how to solve this in eclipse, please comment on this post

        
    22.05.2016 / 15:01