我正在使用
问题是当我开始使用带有Facelets的模板并且在这种情况下抛出异常显然是NullPointerException但是如果你看到stacktrace将异常包装到另一个异常并且我无法看到问题的真正原因,那么原始例外。重要的是,如果我实践NPE代码完美的工作。导致问题的任何想法,Facelets,JSF或Weld。所有异常都会发生这种情况
我有这个结构:
控制器
@Named(value="productoController")
@ConversationScoped
public class ProductoController {
public void alta(){
String test = null;
//Throw NPE
test.concat("");
}
}
页:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:templates="http://java.sun.com/jsf/composite/templates">
<ui:composition template="/templates/TemplateABM.xhtml">
<ui:define name="title">
#{msgs['producto.abm.alta.pagina.titulo']}
</ui:define>
<ui:define name="top">
<h1>#{msgs['producto.abm.alta.titulo']}</h1>
</ui:define>
<ui:define name="content">
<templates:productos id="templateProductos"
page="alta"
disableComponents="false"
btnAccionText="#{msgs['comun.abm.boton.guardar']}"
btnAccion="#{productoController.alta()}"
/>
</ui:define>
</ui:composition>
</html>
模板:
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:templates="http://java.sun.com/jsf/composite/templates"
>
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="page" required="true" />
<composite:attribute name="btnAccionText" required="true" />
<composite:attribute name="btnAccion" method-signature="java.lang.String action()" required="true" />
<composite:attribute name="disableComponents" required="true" />
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<f:metadata>
<f:event type="preRenderView" listener="{productoController.iniciarConversacion}" />
</f:metadata>
<h:form id="formABMProducto">
<templates:botonera id="templateBotonera"
margen="8%"
page="#{cc.attrs.page}"
btnAccionText="#{cc.attrs.btnAccionText}"
btnAccion="#{cc.attrs.btnAccion}"
/>
</h:form>
</composite:implementation>
</html>
模板Botonera.xhtml
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="margen" required="true" />
<composite:attribute name="page" required="true" />
<composite:attribute name="btnAccionText" required="false" />
<composite:attribute name="btnAccion" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="btnExportar" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="disabled" required="false" />
<composite:attribute name="execute" required="false" />
<composite:attribute name="oncompleteValue" required="false" />
<composite:attribute name="deshabilitarBotonAccion" required="false" />
<composite:attribute name="habilitarBotonSeguir" required="false" />
<composite:attribute name="habilitarBotonExportar" required="false" />
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<div id="botonera">
<a4j:commandButton
id="btnAccion"
value="#{cc.attrs.btnAccionText}"
action="#{cc.attrs.btnAccion}"
disabled="#{cc.attrs.disabled}"
execute="#{cc.attrs.execute}"
render="@form"
oncomplete="#{cc.attrs.oncompleteValue}"
rendered="#{!cc.attrs.deshabilitarBotonAccion}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnSeguir"
value="#{msgs['comun.abm.boton.seguir']}"
action="/abm/servicios/alta"
immediate="true"
disabled="#{titularController.deshabilitarBotonSeguir}"
rendered="#{cc.attrs.page eq 'alta' and cc.attrs.habilitarBotonSeguir}" style="margin:0px #{cc.attrs.margen};"/>
<a4j:commandButton
id="btnExportar"
value="#{msgs['facturacion.abm.generacion.padron.boton.exportar']}"
action="#{cc.attrs.btnExportar}"
execute="#{cc.attrs.execute}"
render="@form"
rendered="#{cc.attrs.habilitarBotonExportar}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnCancelar"
action="#{commonController.reset(cc.attrs.page)}"
immediate="true"
value="#{msgs['comun.abm.boton.cancelar']}"
style="margin:0px #{cc.attrs.margen};" />
<h:commandButton
id="btnAyuda"
value="#{msgs['comun.abm.boton.ayuda']}"
style="margin:0px #{cc.attrs.margen};" />
<a4j:commandButton
id="btnSalir"
value="#{msgs['comun.abm.boton.salir']}"
onclick="#{rich:component('popupConfirmacionSalida')}.show();"
style="margin:0px #{cc.attrs.margen};"
immediate="true" />
</div>
<ui:include src="/templates/common/popup_salida.xhtml" />
</composite:implementation>
</html>
堆栈跟踪:
GRAVE: javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Método no hallado: com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap@33704fed.btnAccion()
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
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)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at ar.com.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.el.MethodNotFoundException: Método no hallado: com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap@33704fed.btnAccion()
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:259)
at org.apache.el.parser.AstValue.invoke(AstValue.java:271)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
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.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:187)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:450)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
由于 伊格纳西奥
用户BalusC的响应,我附加了屏幕并使用FullAjaxExceptionHandler接收相同的结果。
我在控制台中看到这个可能你可以使用(这在视图中没有反映):
dic 23, 2014 3:45:06 PM com.sun.faces.facelets.el.ContextualCompositeMethodExpression invoke
ADVERTENCIA: jsf.facelets.el.method.expression.invoke.error:javax.el.ELException: java.lang.NullPointerException
dic 23, 2014 3:45:06 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute