6 Replies Latest reply on Aug 25, 2008 5:58 AM by Julien Martin

    Problem with facelets and el!!!

    Julien Martin Expert

      Hello,
      I have the following problem with Richfaces + Facelets:

      java.lang.NullPointerException
       at javax.el.BeanELResolver$BeanProperty.read(BeanELResolver.java:259)
       at javax.el.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:209)
       at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
       at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
       at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
       at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
       at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:284)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:154)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:79)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.restfaces.application.RestViewHandler.renderView(RestViewHandler.java:148)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
       at org.restfaces.Filter.doFilter(Filter.java:210)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
       at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      
      


      I was told facelets provide useful debugging information. From what I have above, there's nothing much useful that can help me find out what the problem is. I have been struggling with this bug for two days.

      Can anyone help?

      Thanks in advance,

      Julien.

        • 1. Re: Problem with facelets and el!!!
          Julien Martin Expert

          What does this message mean? That there are no EL implementation available? This can't be the case since other pages display ok.
          Does anyone have any clue?
          Julien.

          • 2. Re: Problem with facelets and el!!!
            Daniel Soneira Novice

            Although this has NOTHING to do with RichFaces - have you thought about setting a breakpoint for that NullPointerException?

            As you can see in the stacktrace it is one of the children of an a4j:outputPanel.

            Try deleting some tags in your JSP to limit the possible offending control.
            First throw out all the outputPanels and then put one by one again in until the error reoccurs.

            • 3. Re: Problem with facelets and el!!!
              . . Newbie

              balteo,

              Could you send more code snippets about the Managed Bean and JSP page that are being used for?

              "balteo" wrote:
              What does this message mean? That there are no EL implementation available? This can't be the case since other pages display ok.
              Does anyone have any clue?
              Julien.


              • 4. Re: Problem with facelets and el!!!
                Julien Martin Expert

                rhancke,
                Will do when I get back home tonight.
                thanks,
                Julien.

                • 5. Re: Problem with facelets and el!!!
                  Julien Martin Expert

                  Hello again,
                  Here is the facelet page:

                   <ui:composition template="/template.xhtml">
                   <ui:define name="title">
                   <title><h:outputText value="todo: accueil" /></title>
                   </ui:define>
                   <ui:define name="body">
                   <a4j:outputPanel layout="block" styleClass="wrapper">
                   <h:outputText value="Date: " />
                   <h:outputText value="#{sculptureView.sculpture.annee}">
                   <f:convertDateTime dateStyle="full" />
                   </h:outputText>
                   <br />
                   <h:outputText value="#{sculptureView.sculpture.sculpturei18nMap[view.locale.language].titre}" />
                   <br />
                   <div id="imageflow">
                   <div id="loading"><b>Loading images todo</b><br />
                   <img src="/images/loading.gif" width="208" height="13" alt="loading" /></div>
                   <div id="images"><a4j:repeat value="#{sculptureView.sculpture.photoList}" var="photo" rendered="false">
                   <h:graphicImage styleClass="sculptureImg" alt="" value="/images/sculptures/#{sculptureView.sculpture.sculptureID}/#{photo.nom}.#{photo.format}" />
                   </a4j:repeat></div>
                   <div id="captions"></div>
                   <div id="scrollbar">
                   <div id="slider"></div>
                   </div>
                   </div>
                  
                  
                   <a4j:outputPanel id="composantSuggestions" rendered="#{!empty suggestionOeuvreView.sculpturesNonVisitees}">
                   <a4j:outputPanel id="sculptureSuggeree" ajaxRendered="true">
                   <rest:link id="goToSculpture" value="sculptureAction">
                   <f:param name="id" value="#{suggestionOeuvreView.sculptureSuggeree.sculptureID}" />
                   <h:outputText value="#{suggestionOeuvreView.sculptureSuggeree.sculpturei18nMap[view.locale.language].titre}" />
                   </rest:link>
                   <a4j:form reRender="poll,sculptureSuggeree">
                   <a4j:commandButton value="go" actionListener="#{suggestionOeuvreView.enable}" immediate="true" ajaxSingle="true" />
                   <a4j:commandButton value="stop" actionListener="#{suggestionOeuvreView.disable}" immediate="true" ajaxSingle="true" />
                   </a4j:form>
                   </a4j:outputPanel>
                   <a4j:region>
                   <a4j:outputPanel id="poll" ajaxRendered="true">
                   <a4j:form>
                   <a4j:poll actionListener="#{suggestionOeuvreView.trouverSculptureSuggeree}"
                   interval="5000"
                   reRender="sculptureSuggeree,poll"
                   ajaxSingle="true"
                   limitToList="true"
                   enabled="#{suggestionOeuvreView.enabled}"
                   immediate="true" ignoreDupResponses="true"/>
                   </a4j:form>
                   </a4j:outputPanel>
                   </a4j:region>
                   </a4j:outputPanel>
                   <a4j:outputPanel layout="block" styleClass="push" />
                   </a4j:outputPanel>
                   </ui:define>
                   </ui:composition>
                  


                  Here is the first managed bean:

                  @Component("sculptureView")
                  @Scope("request")
                  @HttpParentAction("rootAction")
                  public class SculptureView {
                  
                   private static transient Logger log = Logger.getLogger("com.jeanbaptistemartin.view");
                   private JbmService service;
                   private Sculpture sculpture;
                   private SuggestionOeuvreView suggestionOeuvreView;
                  
                  
                  
                   @Autowired
                   public SculptureView(JbmService service) {
                   log.info("SculptureView(JbmService service)");
                   this.service = service;
                   }
                  
                   public SuggestionOeuvreView getSuggestionOeuvreView() {
                   log.debug("getSuggestionOeuvreView");
                   return suggestionOeuvreView;
                   }
                  
                   @Autowired
                   @ScopedProxy
                   public void setSuggestionOeuvreView(SuggestionOeuvreView suggestionOeuvreView) {
                   log.warn("setSuggestionOeuvreView");
                   this.suggestionOeuvreView = suggestionOeuvreView;
                   }
                  
                   @Instance("#{sculptureView}")
                   @HttpAction(value = "sculptureAction", pattern = "sculpture/{id}")
                   public String getSculpture(@Param("id") int id) {
                   log.debug("getSculpture");
                   this.sculpture = service.findByID(id);
                   //todo: gestion du cas SculptureNonTrouveeException
                   etablirStatutVisiteSculpture(id);
                   return "/sculpture.xhtml";
                   }
                  
                   public Sculpture getSculpture() {
                   log.debug("getSculpture");
                   return sculpture;
                   }
                  
                   public void etablirStatutVisiteSculpture(int sculptureId) {
                   log.debug("etablirStatutVisiteSculpture");
                   suggestionOeuvreView.enleverSculptureDeListeNonVisitees(sculptureId);
                   }
                  }
                  


                  and the second managed bean:

                  @Component("suggestionOeuvreView")
                  @Scope("session")
                  public class SuggestionOeuvreView implements Serializable {
                  
                   private static transient Logger log = Logger.getLogger("com.jeanbaptistemartin.view");
                   private LinkedList<Integer> sculpturesNonVisitees;
                   private Sculpture sculptureSuggeree;
                   private transient JbmService jbmService;
                   private boolean enabled = true;
                  
                  
                   @Autowired
                   public SuggestionOeuvreView(JbmService jbmService) {
                   log.debug("SuggestionOeuvreView()");
                   this.jbmService = jbmService;
                   this.sculpturesNonVisitees = recupererSculpturesNonVisitees();
                   this.sculptureSuggeree = suggererSculpture();
                   }
                  
                   private Sculpture suggererSculpture() {
                   log.debug("suggererSculpture");
                   if (this.sculpturesNonVisitees.isEmpty() || this.sculpturesNonVisitees.peek() == null) {
                   log.error("problème");//todo
                   return null;
                   } else {
                   Integer identifiantSculptureSuggeree = this.sculpturesNonVisitees.poll();//todo rename
                   this.sculpturesNonVisitees.add(identifiantSculptureSuggeree);
                   log.debug("I suggest this sculpture: " + identifiantSculptureSuggeree);
                   return jbmService.findByID(identifiantSculptureSuggeree);
                   }
                   }
                  
                   public void trouverSculptureSuggeree(ActionEvent evt) {
                   log.debug("trouverSculptureSuggeree");
                   this.sculptureSuggeree = suggererSculpture();
                   }
                  
                   public void enable(ActionEvent evt) {
                   log.debug("enable");
                   this.enabled = true;
                   }
                  
                   public void disable(ActionEvent evt) {
                   log.debug("disable");
                   this.enabled = false;
                   }
                  
                   public LinkedList<Integer> recupererSculpturesNonVisitees() {
                   log.debug("recupererSculpturesNonVisitees() ");
                   return jbmService.findAllSculptureIDs();
                   }
                  
                   public void enleverSculptureDeListeNonVisitees(Integer sculptureId) {
                   log.debug("enleverSculptureDeListeNonVisitees");
                   this.sculpturesNonVisitees.remove(sculptureId);
                   log.debug(this.sculpturesNonVisitees.size());
                   }
                  
                   public Sculpture getSculptureSuggeree() {
                   log.debug("getSculptureSuggeree");
                   return sculptureSuggeree;
                   }
                  
                   public void setSculptureSuggeree(Sculpture sculptureSuggeree) {
                   log.debug("setSculptureSuggeree");
                   this.sculptureSuggeree = sculptureSuggeree;
                   }
                  
                   public void setJbmService(JbmService jbmService) {
                   log.debug("setJbmService");
                   this.jbmService = jbmService;
                   }
                  
                   public boolean isEnabled() {
                   log.debug("isEnabled");
                   return this.enabled;
                   }
                  
                   public void setEnabled(boolean enabled) {
                   log.debug("setEnabled");
                   this.enabled = enabled;
                   }
                  
                   public LinkedList<Integer> getSculpturesNonVisitees() {
                   log.debug("getSculpturesNonVisitees");
                   return sculpturesNonVisitees;
                   }
                  
                   public void setSculpturesNonVisitees(LinkedList<Integer> sculpturesNonVisitees) {
                   log.debug("setSculpturesNonVisitees");
                   this.sculpturesNonVisitees = sculpturesNonVisitees;
                   }
                  }
                  


                  Julien.

                  • 6. Re: Problem with facelets and el!!!
                    Julien Martin Expert

                    I managed to pinpoint the problem: I had to getSculpture overloaded methods: one with a return type of String, one with a return type of Sculpture.