Can anyone help solve an exception being thrown in my application?
I'm developing a Java web application, I put only a input
and a selectonemenu
in the application to try to save the data, the moment I click the save button it generates the following exception:
javax.el.PropertyNotFoundException: /pages/private/message/insert_message.xhtml @ 34,104 value="# {messageBean.message.name}": Target Unreachable, 'null' returned null at com.sun.faces.facelets.el.TagValueExpression.getType (TagValueExpression.java:100) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue (HtmlBasicInputRenderer.java:95) at javax.faces.component.UIInput.getConvertedValue (UIInput.java:1045) at javax.faces.component.UIInput.validate (UIInput.java:975) at javax.faces.component.UIInput.executeValidate (UIInput.java:1248) at javax.faces.component.UIInput.processValidators (UIInput.java:712) at javax.faces.component.UIForm.processValidators (UIForm.java:253) at javax.faces.component.UIComponentBase.processValidators (UIComponentBase.java:1258) at javax.faces.component.UIComponentBase.processValidators (UIComponentBase.java:1258) at javax.faces.component.UIViewRoot.processValidators (UIViewRoot.java:1195) at com.sun.faces.lifecycle.ProcessValidationsPhase.execute (ProcessValidationsPhase.java:76) at com.sun.faces.lifecycle.Phase.doPhase (Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute (LifecycleImpl.java:198) at javax.faces.webapp.FacesServlet.service (FacesServlet.java:646) at org.apache.catalina.core.StandardWrapper.service (StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke (WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService (CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable.call (ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service (ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService (HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle (HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead (HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver $ 9.execute (ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter (DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart (DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute (DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process (DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute (ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent (TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent (AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0 (WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100 (WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork (AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run (AbstractThreadPool.java:545) at java.lang.Thread.run (Thread.java:745) Caused by: javax.el.PropertyNotFoundException: Target Unreachable, 'null' returned null at com.sun.el.parser.AstValue.getTarget (AstValue.java:192) at com.sun.el.parser.AstValue.getType (AstValue.java:86) at com.sun.el.ValueExpressionImpl.getType (ValueExpressionImpl.java:201) at org.jboss.weld.el.WeldValueExpression.getType (WeldValueExpression.java:93) at com.sun.faces.facelets.el.TagValueExpression.getType (TagValueExpression.java:98) ... 41 more
Here is my xhtml page:
<div class="row">
<div class="col-sm-12">
<label class="control-label">#{bundle['system.ui.label.name']}</label>
<h:inputText id="message" styleClass="form-control"
value="#{messageBean.message.name}" />
</div>
</div>
And here's my managedBean:
@ManagedBean(name = "messageBean")
@SessionScoped
public class MessageBean {
private List<Message> listMessage;
private Message message;
private List<Category> listCategory;
private List<Type> listType;
@EJB
private MessageFacade messageFacade;
@EJB
private CategoryFacade categoryFacade;
@EJB
private TypeFacade typeFacade;
@PostConstruct
public void init(){
listAllMessage();
listAllCategory();
listAllType();
}
public void insert(){
try {
message.getUser().getDsUsername();
System.out.println("Usuario: "+message.getUser().getDsUsername());
messageFacade.save(message);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Nome" +message.getName());
System.out.println("Categoria"+ message.getCategory().getName());
System.out.println("Tipo"+ message.getType().getName());
System.out.println("Data"+ message.getRegistrationInstant());
System.out.println("Usuario"+ message.getUser().getDsUsername());
}
public void listAllMessage() {
listMessage = messageFacade.listAllMessage();
}
public void listAllCategory() {
listCategory = categoryFacade.listAllCategory();
}
public void listAllType(){
listType = typeFacade.listAllType();
}
public List<Category> getListCategory() {
listAllCategory();
return listCategory;
}
public void setListCategory(List<Category> listCategory) {
this.listCategory = listCategory;
}
public List<Message> getListMessage() {
listAllMessage();
return listMessage;
}
public void setListMessage(List<Message> listMessage) {
this.listMessage = listMessage;
}
public List<Type> getListType() {
listAllType();
return listType;
}
public void setListType(List<Type> listType) {
this.listType = listType;
}
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
}