ManagedBean methods are not processed

Asked

Viewed 354 times

0

Good morning, I am the following problem. I have an application that has several Managedbeans that are working normally. Today I went to create a new bean to do a test and this bean does not run nor the @Postconstruct and no other method; I created a new project, copied the bean and xhtml and the new project worked, but I wouldn’t want to recreate it all again. or still, I 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 the test 2.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:

  1. In a new project works normal.
  2. I’m using Eclipse Mars 2 and Tomcat 8
  3. 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 - It is normal from time to time to have to create a new project ?
2 - Why this happens ?

1 answer

0

Good morning guys, I’ve partly solved the problem

It was not working either in the eclipse or in Netbeans.

I had tried many things:

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

Nothing worked !!!

The path I took and solved was :

  • Check for dependency conflicts in pom.xml. and TINHA !!!
  • to know that I opened the pom in the eclipse and went on the guide dependency Hierarchy , it shows those who are in conflict. and I downgrade/upgrade the versions to make them compatible. even then it didn’t work in the eclipse.
  • I tested in the Netbeans and worked I believe it’s some eclipse problem

Thank you for your support and I hope I’ve helped someone by solving the same problem as mine.

OBS: if you know how to resolve this in the eclipse, please comment on this post

Browser other questions tagged

You are not signed in. Login or sign up in order to post.