I'm having trouble accessing methods and attributes on a Managedbean. I'm using JSF and the Glassfish server, I've already used a similar architecture that I'm using however on a Tomcat server.
I would like to know if anyone has ever had a problem of the type and how to solve it, remembering that for reasons of confidentiality, I omitted some attribute names by putting Object
in place.
Error Message:
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: /index.xhtml @ 61,185 value="# {controller.object.name}": Target Unreachable, 'null' returned null root cause
javax.el.PropertyNotFoundException: /index.xhtml @ 61,185 value="# {controller.object.name}": Target Unreachable, 'null' returned null root cause
javax.el.PropertyNotFoundException: Target Unreachable, 'null' returned null note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1 logs.
GlassFish Server Open Source Edition 4.1
Website:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:pt="http://xmlns.jcp.org/jsf/passthrough">
<h:head>
<meta charset="utf-8"> </meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> </meta>
<meta name="viewport" content="width=device-width, initial-scale=1"> </meta>
<link rel="icon" href="assets/img/favicon.png"> </link>
<title>titulo</title>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css"> </link>
<link rel="stylesheet" type="text/css" href="assets/css/styles.css"> </link>
<link rel="stylesheet" type="text/css" href="assets/css/media.css"> </link>
</h:head>
<h:body>
<div id="top">
<div id="logo">
<a href="#">
<img src="assets/img/logo.png" title=""> </img>
</a>
</div>
<div id="menu">
<ul>
<li>
<a href="#" id="group-menu">
<img src="assets/img/menu-list.png" alt="" title=""> </img>
</a>
</li>
</ul>
</div>
</div>
<div id="container">
<div id="second">
<div id="right">
<img src="assets/img/background.png"> </img>
</div>
</div>
<div id="first">
<div id="left">
<h:form class="cmxform" id="formContato" method="post" action="" onsubmit="updateButtonValue()">
<h:inputText id="fName" value="#{controller.object.nome}" title="Nome: " tabindex="1" required="true" requiredMessage="O Nome é Obrigatório" pt:placeholder="Nome: "/>
<h:inputText id="fMail" value="#{controller.object.mail}" title="Email: " tabindex="1" required="true" requiredMessage="O E-mail é Obrigatório" pt:placeholder="E-mail: "/>
<h:inputText id="fPhone" value="#{controller.object.telefone}" title="Telefone: " tabindex="1" required="true" requiredMessage="O Telefone é Obrigatório" pt:placeholder="Telefone: "/>
<h:inputText id="fInterest" value="#{controller.object.area}" title="Área de Interesse: " tabindex="1" required="true" requiredMessage="A área de Interesse é Obrigatória" pt:placeholder="Área de Interesse: "/>
<div id="mensagem">
</div>
<h:commandButton value="Salvar" action="#{controller.salvar()}" ></h:commandButton>
</h:form>
</div>
</div>
</div>
</h:body>
</html>
Controller:
package web.controller;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import application.factory.ApplicationFactory;
import application.interfaces.IContatoApplication;
import business.Contato;
@ManagedBean
@ViewScoped
public class Controller implements Serializable
{
private static final long serialVersionUID = 1L;
private Object object = new Object();
private List<Object> objects = new ArrayList<Object>();
private IApplication application = ApplicationFactory.getInstance().getApplication();
public void salvar()
{
Set<String> erros = application.salvar(object);
}
public Contato getObject() {
if(this.object == null)
this.object = new Object();
return object;
}
public void setObject(Object object)
{
if(this.object == null)
this.object = new Object();
this.object = object;
}
public List<Object> getObjects() {
return objects;
}
public void setObjects(List<Object> objects) {
this.objects = objects;
}
}