I was trying to implement a command button with f:ajax and f:param in my project, but I'm not being successfull.
I have one Bean called "disciplinaMBean" that have a #SessionScoped. In the respective JSF (let's say, index.xhtml) I have one p:dataTable showing some disciplines (this is what "disciplina" means in English :P). When I click in one row, a modal is opened showing to user options to "edit" or "delete" discipline. The selected object is stored in "disciplinaSelecionada" by selection attribute of Primefaces dataTable. See by yourself:
The code of this modal is inside "edit.xhtml" file. See the code below:
<h:form>
<label for="nome">Nome:</label>
<h:inputText styleClass="form-control adicionar" id="nome"
value="#{disciplinaMBean.disciplinaSelecionada.nome}">
</h:inputText>
<h:commandButton id="excluir" styleClass="btn btn-md btn-danger pull-left" value="Excluir" >
<f:param name="idDisciplina" value="#{disciplinaSelecionada.id}" />
<f:ajax event="click" listener="#{disciplinaMBean.deletar}" />
</h:commandButton>
</h:form>
And the method "Deletar" (means delete) in disciplineMBean:
public void deletar(){
String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("idDisciplina");
System.out.println("Disciplina deletada: " + param1);
int idDisciplina = Integer.parseInt(param1);
controleDisciplina.remover(idDisciplina);
}
I know I called the method because the log of console, but I can't delete the discipline because I have one error (a empty string is stored in "idDisciplina" param).
Following is the error:
Disciplina deletada:
Nov 01, 2013 10:26:31 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: /edit.xhtml #31,72 listener="#{disciplinaMBean.deletar}": java.lang.NumberFormatException: For input string: ""
javax.el.ELException: /edit.xhtml #31,72 listener="#{disciplinaMBean.deletar}": java.lang.NumberFormatException: For input string: ""
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:791)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1256)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at mbeans.DisciplinaMBean.deletar(DisciplinaMBean.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 27 more
What can I do to solve this issue?
If you have EL 2.2, you can do it like this (assuming disciplinaSelecionada.id is an int)
<h:commandButton id="excluir" action="#{disciplinaMBean.deletar(disciplinaSelecionada.id)}" styleClass="btn btn-md btn-danger pull-left" value="Excluir" />
....
public void deletar(int idDisciplina)
{
System.out.println("Disciplina deletada: " + idDisciplina);
controleDisciplina.remover(idDisciplina);
}
Related
I studied some similar questions here on stackoverflow, but none of them seem to nail my problem...
I wrote a (kind of simple) composite component:
<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:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="buttonValue" />
<composite:attribute name="ajaxExecute" />
<composite:attribute name="ajaxRender" />
<composite:attribute name="ajaxListener" />
</composite:interface>
<composite:implementation>
<h:commandButton value="#{cc.attrs.buttonValue}">
<f:ajax execute="#{cc.attrs.ajaxExecute}"
render="#{cc.attrs.ajaxRender}" listener="#{cc.attrs.ajaxListener}" />
</h:commandButton>
</composite:implementation>
</html>
And included this one into my view like so:
<my:ajaxCommandButton
buttonValue="foo"
ajaxExecute=""
ajaxRender=""
ajaxListener="#{viewBacking.resend()}"></my:ajaxCommandButton>
The interesting thing is - this guy works like a champ (!) - every time I click on it, the bean method is called and all seems to be wonderful.
Unfortunately I get this stuff logged out with every click on the button:
20160229:143610.598 [http-/0.0.0.0:8080-2] WARNING javax.enterprise.resource.webcontainer.jsf.lifecycle - Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}': javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UICommand.broadcast(UICommand.java:300) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
[...]
20160229:143610.600 [http-/0.0.0.0:8080-2] SEVERE javax.enterprise.resource.webcontainer.jsf.context - javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
Anyone with an idea for me? Thanks a lot in advance!
Just an idea - add the method-signature attribute to:
<composite:attribute name="ajaxListener" />
This is my flow (simplified):
<view-state id="create" view="createCustomer.xhtml">
<transition on="create" to="end">
<evaluate expression="controller.validateCustomerFilled(customer)"/>
</transition>
</view-state>
<end-state id="end" view="customerCreated.xhtml">
<on-entry>
<evaluate expression="controller.createCustomer(customer)"/>
</on-entry>
</end-state>
and my Facelet (also simplified):
<p:commandButton value="Test Ajax" action="create" update="content, messages"/>
<p:commandButton value="Test No Ajax" action="create" ajax="false"/>
As long as "customerCreated.xhtml" doesn't contain a h:form, everything seems to work fine. But if it does exist, the following exception gets thrown:
java.lang.IllegalStateException: The current state 'end' of this flow 'customer/create' is not a view state - view scope not accessible
at org.springframework.webflow.engine.impl.FlowSessionImpl.getViewScope(FlowSessionImpl.java:119)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.getViewScope(RequestControlContextImpl.java:130)
at org.springframework.faces.webflow.FlowResponseStateManager.saveState(FlowResponseStateManager.java:106)
at org.springframework.faces.webflow.FlowResponseStateManager.getViewState(FlowResponseStateManager.java:100)
at javax.faces.application.StateManager.getViewState(Unknown Source)
at javax.faces.application.StateManagerWrapper.getViewState(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.renderState(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.processPartial(Unknown Source)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.context.PartialViewContextWrapper.processPartial(Unknown Source)
at javax.faces.component.UIViewRoot.encodeChildren(Unknown Source)
at javax.faces.component.UIComponent.encodeAll(Unknown Source)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
at com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
at javax.faces.application.ViewHandlerWrapper.renderView(Unknown Source)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at org.springframework.faces.support.LifecycleWrapper.render(LifecycleWrapper.java:54)
at org.springframework.faces.webflow.JsfView.render(JsfView.java:87)
at org.springframework.webflow.action.ViewFactoryActionAdapter.doExecute(ViewFactoryActionAdapter.java:40)
at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
at org.springframework.webflow.engine.EndState.doEnter(EndState.java:100)
at org.springframework.webflow.engine.State.enter(State.java:194)
at org.springframework.webflow.engine.Transition.execute(Transition.java:228)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:395)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214)
at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:116)
at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:547)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:390)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:231)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:195)
at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:228)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:57)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1285)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:473)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1143)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:927)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
This doesn't happen when using a regular h:commandButton without Ajax (when using f:ajax, simply nothing happens on the client side).
Using:
- Spring 4.2.0
- Spring Webflow 2.4.2
- Primefaces 5.2
- Mojarra 2.2.9
You a clearly performing an 'Action' with controller.createCustomer(customer)
<end-state id="end" view="customerCreated.xhtml">
<on-entry>
<evaluate expression="controller.createCustomer(customer)"/>
</on-entry>
</end-state>
Therefore, this is not really an end-state. Change this to an action-state then transition to a blank/dummy end-state.
Development Environment
1.8.0_45 JDK
Glassfish 4.1 (latest)
Maven 3.3.3
NetBeans 8.0.2
MS SQL 2012
Project Details
Maven Enterprise Application
2 EJBs
1 WAR (JSF 2.2 Library from Glassfish)
EAR Deployment
Problem Statement
When I use standard <head></head> tags, everything works properly. My CDI works, values are processed, and the site does what it is supposed to do. If, however, I use the intended <h:head></h:head> tags, my code does not execute and I receive a javax.faces.FacesException: #{loginController.logUserIn()}: javax.ejb.EJBException.
Faces Template
<?xml version='1.0' encoding='UTF-8' ?>
<!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:ui="http://xmlns.jcp.org/jsf/facelets">
<head>
<title>Learning Resource Mapping Utility</title>
... <!-- stylesheets loaded here -->
</head>
<body>
<ui:insert name="left_side"></ui:insert>
<ui:insert name="right_side"></ui:insert>
</body>
</html>
Faces Template Client
<?xml version='1.0' encoding='UTF-8' ?>
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<ui:composition template="./layouts/anonymous.xhtml">
<ui:define name="left_side">
<h:form>
<div>
<h:inputText class="form-control" id="username" value="#{loginController.username}" />
<h:outputLabel value="User Name:" />
</div>
<div class="form-group">
<h:inputSecret class="form-control" id="password" value="#{loginController.password}" />
<h:outputLabel value="Password:" />
</div>
<br />
<div>
<h:commandButton class="btn btn-primary btn-raised" action="#{loginController.logUserIn()}" value="Login" >
<f:ajax />
</h:commandButton>
</div>
</h:form>
</ui:define>
<ui:define name="right_side">
<h:messages />
</ui:define>
</ui:composition>
</body>
</html>
Controller Code
package org.eta.lrm.controllers;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
import javax.persistence.PersistenceException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.eta.lrm.entities.Person;
import org.eta.web.util.JsfUtil;
#Named(value = "loginController")
#SessionScoped
public class LoginController implements Serializable {
private static final long serialVersionUID = 2701463947668608540L;
#EJB
private org.eta.lrm.models.PersonFacadeLocal userFacade;
private String username;
private String password;
private Person user;
private boolean authenticated = false;
//<editor-fold defaultstate="collapsed" desc="PROPERTIES">
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Person getUser() {
return user;
}
public void setUser(Person user) {
this.user = user;
}
public boolean isAuthenticated() {
return authenticated;
}
public void setAuthenticated(boolean authenticated) {
this.authenticated = authenticated;
}
//</editor-fold>
public String logUserIn() {
// set a default result to return
String result = "/login";
try {
this.user = userFacade.findByUsername(username);
} catch (PersistenceException pEx) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, pEx);
JsfUtil.addErrorMessage("Username not found, please try again.");
return result;
}
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
try {
request.login(this.getUsername(), this.getPassword());
this.authenticated = true;
result = "/staff/dashboard?faces-redirect=true";
} catch (ServletException ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
JsfUtil.addErrorMessage("Login failed, please try again.");
result = "/login";
}
// redirect user to the result destination
return result;
}
}
Stack Trace on Error
Warning: #{loginController.logUserIn()}: javax.ejb.EJBException
javax.faces.FacesException: #{loginController.logUserIn()}: javax.ejb.EJBException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.jav a:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
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.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:412)
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.faces.el.EvaluationException: javax.ejb.EJBException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 37 more
Caused by: javax.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy280.findByUsername(Unknown Source)
at org.eta.lrm.controllers.LoginController.logUserIn(LoginController.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 38 more
Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
at org.eclipse.persistence.internal.jpa.QueryImpl.throwNoResultException(QueryImpl.java:972)
at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:522)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400)
at org.eta.lrm.models.PersonFacade.findByUsername(PersonFacade.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
... 54 more
Severe: javax.faces.el.EvaluationException: javax.ejb.EJBException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
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.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:412)
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.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy280.findByUsername(Unknown Source)
at org.eta.lrm.controllers.LoginController.logUserIn(LoginController.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 38 more
Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
at org.eclipse.persistence.internal.jpa.QueryImpl.throwNoResultException(QueryImpl.java:972)
at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:522)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400)
at org.eta.lrm.models.PersonFacade.findByUsername(PersonFacade.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
... 54 more
None of this Stack Trace happens when using the <head> tags. only the <h:head> tags.
The lackof an h:head makes the ajax tag give warning. It needs script to be added to the head which only workswith h:head, nota plain head. When this starts working, most likely one of the inputs is not send to the server when the button is pressed, resulting in execptions in your code. The cause of the error is clearly visible so please investigate why noresults are returned in
Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
at org.eclipse.persistence.internal.jpa.QueryImpl.throwNoResultException(QueryImpl.java:972)
at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:522)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400)
at org.eta.lrm.models.PersonFacade.findByUsername(PersonFacade.java:40)
Most likely correcting the ajax tag (making sure it 'executes' other inputs (default is #this afaik)) will make it work
Your problem is in fact a duplicate of Submitted form values not updated in model when adding <f:ajax> to <h:commandButton> afaics (which you could have found ifyou tried to find out why this specific exception happend (and we are back to reading stacktraces ;-)))
I have in my JSF 2 app on JBoss AS 7.1 a PrimeFaces 5.1 datatable with lazy loading and it sorts on page load, so I know my sorting implementation works, but when I click the column to sort it throws the below exception.
17:48:34,855 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/feenix].[Faces Servlet]] (http-/0:0:0:0:0:0:0:0:8080-6) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception:
java.lang.NullPointerException
at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:469) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:76) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:603) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:152) [primefaces-5.1.jar:5.1]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:201) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:126) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]
My data table:
<p:dataTable var="registroD" value="#{reportes.diario}" paginator="true" rows="10" rowsPerPageTemplate="10,20,40,80" id="registroDiarioTable" lazy="true"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">
<p:column headerText="Fecha">
<h:outputText value="#{registroD.fechaRegistro}">
<f:convertDateTime pattern="yyyy/MM/dd" type="date"/>
</h:outputText>
</p:column>
<p:column headerText="Nombre Asesor" sortBy="#{registroD.idTrabajo.idUsuario.nombres}" filterBy="#{registroD.idTrabajo.idUsuario.nombres}">
<h:outputText value="#{registroD.idTrabajo.idUsuario.nombres}"/>
</p:column>
<p:column headerText="Apellido Asesor" sortBy="#{registroD.idTrabajo.idUsuario.apellidos}" filterBy="#{registroD.idTrabajo.idUsuario.apellidos}">
<h:outputText value="#{registroD.idTrabajo.idUsuario.apellidos}"/>
</p:column>
<p:column headerText="Lugar entrega" sortBy="#{registroD.idTrabajo.idUbicacion.direccion}" filterBy="#{registroD.idTrabajo.idUbicacion.direccion}">
<h:outputText value="#{registroD.idTrabajo.idUbicacion.direccion}"/>
</p:column>
<p:column headerText="Hora entrega">
<h:outputText value="#{registroD.fechaRegistro}">
<f:convertDateTime pattern="HH:mm:ss" type="time"/>
</h:outputText>
</p:column>
<p:column headerText="Nombre" sortBy="#{registroD.numero.nombres}" filterBy="#{registroD.numero.nombres}">
<h:outputText value="#{registroD.numero.nombres}"/>
</p:column>
<p:column headerText="Apellido" sortBy="#{registroD.numero.apellidos}" filterBy="#{registroD.numero.apellidos}">
<h:outputText value="#{registroD.numero.nombres}"/>
</p:column>
<p:column headerText="Numero Celular" sortBy="#{registroD.numero.numero}" filterBy="#{registroD.numero.numero}">
<h:outputText value="#{registroD.numero.numero}" />
</p:column>
<p:column headerText="Producto" sortBy="#{registroD.producto}" filterBy="#{registroD.producto}">
<h:outputText value="#{registroD.producto}"/>
</p:column>
</p:dataTable>
This error has nothing to do (seems to me that way) with the actions I do.
What is going on?
The stack trace tells that this exception occurred while handling an exception during restore view phase of an ajax request. This is a second problem which has unfortunately hidden away all detail about the underlying exception which JSF was trying to handle, so this question can't be answered by just looking at the stack trace until you fix/replace the standard exception handler.
If upgrading to latest Mojarra version doesn't solve it, then you can (temporarily) use the one shown in this answer to print the stack trace of the real underlying exception: Exception handling in JSF ajax requests. That should in turn give sufficient clues about the real underlying problem.
I have two h:selectManyCheckBox with the required attribute set to true.
What I want is that the required attribute of both of the components work together.
Only display the error message if and only if both of the selected items list are empty.
Right now my problem is that the message displays if either one of them is empty. Here's my code:
<rich:panel>
<f:facet name="header">
<h:outputText value="Actualización de catálogos"/>
</f:facet>
<h:panelGrid columns="4">
<h:outputLabel for="actualizarCatalogoPEC"
value="Actualizar catálogos PEC"/>
<h:selectBooleanCheckbox id="actualizarCatalogoPEC"
value="#{administrationBean.actualizaTodosPecChecked}">
<f:ajax event="click"
render="todosCatalogosPEC"/>
</h:selectBooleanCheckbox>
<h:outputLabel for="actualizarCatalogoSAGARPA"
value="Actualizar catálogos SAGARPA"/>
<h:selectBooleanCheckbox id="actualizarCatalogoSAGARPA"
value="#{administrationBean.actualizaTodosSagarpaChecked}">
<f:ajax event="click"
render="todosCatalogosSAGARPA"/>
</h:selectBooleanCheckbox>
<a4j:outputPanel id="todosCatalogosPEC">
<h:selectManyCheckbox id="selectCatalogosPEC"
disabled="#{administrationBean.actualizaTodosPecChecked}"
required="true"
value="#{administrationBean.catalogosPecSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection">
<f:selectItems value="#{administrationBean.catalogosPecOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<a4j:outputPanel id="todosCatalogosSAGARPA">
<h:selectManyCheckbox id="selectCatalogosSAGARPA"
disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
required="true"
value="#{administrationBean.catalogosSagarpaSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection" >
<f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<rich:message id="messageCatalogosPEC"
for="selectCatalogosPEC"/>
<h:panelGroup/>
<rich:message id="messageCatalogosSAGARPA"
for="selectCatalogosSAGARPA"/>
<h:panelGroup/>
<a4j:commandButton value="Actualizar catálogos"
render="messageCatalogosPEC"
action="#{administrationBean.doActualizaCatalogos}"/>
</h:panelGrid>
</rich:panel>
Cheers
UPDATE
I've changed my code as follows: (just added binding and modified required)
<a4j:outputPanel id="todosCatalogosPEC">
<h:selectManyCheckbox id="selectCatalogosPEC"
disabled="#{administrationBean.actualizaTodosPecChecked}"
binding="selectCatalogosPEC"
required="#{empty selectCatalogosSAGARPA.value}"
value="#{administrationBean.catalogosPecSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection">
<f:selectItems value="#{administrationBean.catalogosPecOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
<h:panelGroup/>
<a4j:outputPanel id="todosCatalogosSAGARPA">
<h:selectManyCheckbox id="selectCatalogosSAGARPA"
binding="selectCatalogosSAGARPA"
disabled="#{administrationBean.actualizaTodosSagarpaChecked}"
required="#{empty selectCatalogosPEC.value}"
value="#{administrationBean.catalogosSagarpaSeleccionados}"
requiredMessage="Seleccione al menos un catálogo"
layout="pageDirection" >
<f:selectItems value="#{administrationBean.catalogosSagarpaOptions}"/>
</h:selectManyCheckbox>
</a4j:outputPanel>
but got this error:
jun 01, 2012 10:31:37 AM org.apache.catalina.core.StandardWrapperValve invoke
Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/SRC_RichFaces] threw exception [java.lang.String cannot be cast to javax.faces.component.UIComponent] with root cause
java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1941)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1144)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:504)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:157)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:774)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
You need to bind them both to the view and in the required attribute of the first one, check if the UIInput#getSubmittedValue() of the second one is empty and in the required attribute of the second one, check if the UIInput#getValue() of the first one is empty.
<h:selectManyCheckbox
binding="#{selectCatalogosPEC}"
required="#{empty selectCatalogosSAGARPA.submittedValue}"
>
...
</h:selectManyCheckbox>
<h:selectManyCheckbox
binding="#{selectCatalogosSAGARPA}"
required="#{empty selectCatalogosPEC.value}"
>
....
</h:selectManyCheckbox>
See also:
JSF two required h:inputText (exclusive or)