0

im using

  • RichFaces 4.5.1.Final
  • Weld 2.2.8.Final
  • Mojarra 2.1.29
  • JSF 2.1

The problem is when im starting to use template with Facelets and an exception is thrown in this case obviously NullPointerException but if you see the stacktrace is wrapping the exception into another exception and i cant see the real cause of the problem, the original exception. Is important to say that if i coment the NPE code works perfectly. Any ideas that was causing the issue, Facelets, JSF or Weld. this happen with all exception

I have this structure:

Controller

@Named(value="productoController")
@ConversationScoped
public class ProductoController {

    public void alta(){
        String test = null;

        //Throw NPE
        test.concat("");
    }

}

Page:

<!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>

Templates:

<!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>

Template 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>

stacktrace:

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)

Thanks Ignacio

Response for User BalusC, i attached the screen and receive the same result with FullAjaxExceptionHandler.

enter image description here

I saw this in the console maybe you can use (this doesnt reflect in the view):

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
Tiny
  • 27,221
  • 105
  • 339
  • 599
Ignacio
  • 121
  • 3
  • 10
  • As you're using OmniFaces already, have you tried using its `FullAjaxExceptionHandler` and/or `FacesExceptionFilter`? It internally also unwraps any `FacesException` and `ELException`. I could answer how to create a custom one, but that's cumbersome if you're using OmniFaces already ... – BalusC Dec 23 '14 at 17:49
  • I configured the FullAjaxExceptionHandler and i receiving the same error, i attached the printscreen. – Ignacio Dec 23 '14 at 18:26
  • At first glance, I'd say that this is just a Mojarra bug in combination with nested composite components. I'd have to explore its source first. On the other hand, be careful that you don't "overuse" composite components just because of its zero-configuration nature as compared to tagfiles. See also this related answer and links therein: http://stackoverflow.com/questions/26017598/cc-clientid-evalutated-in-wrong-composite-after-upgrading-to-jsf-2-2/26507917#26507917 – BalusC Dec 23 '14 at 18:39
  • you check the last post i did about this: 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 – Ignacio Dec 23 '14 at 18:49

0 Answers0