6 Replies Latest reply on Apr 1, 2008 6:55 AM by Kerdudou Ronan

    3.2.0-20080323 a4j:keepAlive JspValueExpression bug

    Kerdudou Ronan Apprentice

      seems like other bug already corrected on 3.2.0 :

      i have

      2008-03-25 11:22:48,765 109375 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MonitorMakerWeb].[jsp]] (ajp-127.0.0.1-8009-2:) - "Servlet.service()" pour la servlet jsp a lance une exception
      org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP:
      
      Une erreur s'est produite a la ligne: 9 dans le fichier jsp: /reporter/saisie_projet/liste_projets.inc.jspThe method setBeanName(String) in the type KeepAliveTag is not applicable for the arguments (JspValueExpression)6: <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      7: <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
      8:
      9: <a4j:keepAlive beanName="liste_projets" />
      10:
      11: <vc:cadre titre="#{libelles.LBL_LISTE_PROJETS}">
      
      
      Stacktrace:
       at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
       at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
       at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
       at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
       at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
       at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:590)
       at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:505)
       at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
       at org.apache.jsp.reporter.saisie_005fprojet.saisie_005fVLM_jsp._jspx_meth_h_005fform_005f2(saisie_005fVLM_jsp.java:665)
       at org.apache.jsp.reporter.saisie_005fprojet.saisie_005fVLM_jsp._jspx_meth_f_005ffacet_005f2(saisie_005fVLM_jsp.java:622)
       at org.apache.jsp.reporter.saisie_005fprojet.saisie_005fVLM_jsp._jspx_meth_vg_005fbodyTemplate_005f0(saisie_005fVLM_jsp.java:263)
       at org.apache.jsp.reporter.saisie_005fprojet.saisie_005fVLM_jsp._jspx_meth_f_005fview_005f0(saisie_005fVLM_jsp.java:189)
       at org.apache.jsp.reporter.saisie_005fprojet.saisie_005fVLM_jsp._jspService(saisie_005fVLM_jsp.java:142)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
       at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
       at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
       at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
       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:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       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:147)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at com.vc.mm.servlets.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:92)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       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:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)
       at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:381)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)


        • 1. Re: 3.2.0-20080323 a4j:keepAlive JspValueExpression bug
          Kerdudou Ronan Apprentice

          It's like the keepAliveTag is still in jsp 1.2 but the TLD is now all jsp 2.1

          this tag is quite unusual as from the begining it takes a string to make an expresions with it...

          it seems that in jsp 2.1 we can't have just a string, it's always wraped into a
          valueExpression object...

          then, it'll be a valueExpression containing a string to make a new valueExpression... and if the first valueExpression contains an EL, then we should throw an exception... i think... (if i understand well why this param is a string instead of an EL)

          i'm waiting next snapshot to be able to test 3.2...

          • 2. Re: 3.2.0-20080323 a4j:keepAlive JspValueExpression bug
            Kerdudou Ronan Apprentice

            Tested on RC8 and not yet corrected...

            how is it possible ? can anybody explain me where i'm wrong ? or perhaps nobody uses keepalive ?

            i'm using bundled JSF of :
            INFO [Server] Release ID: JBoss [Trinity] 4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)

            all is working fine whith RF 3.1.4.
            but with RF 3.2, a4j:keepAlive doesn't work as in JSF 2.1 we can't call setBeanName() with a String parameter, it must be a valueExpression that contains only a String.

            the code of keepAliveTag should be adapted...

            • 3. Re: 3.2.0-20080323 a4j:keepAlive JspValueExpression bug
              Kerdudou Ronan Apprentice

              keepAliveTag should be :

              /**
               * Edited by RonanKer from VirageGroup on 2008-03-31 11:20 GMT+1 (Paris)
               *
               * License Agreement.
               *
               * Rich Faces - Natural Ajax for Java Server Faces (JSF)
               *
               * Copyright (C) 2007 Exadel, Inc.
               *
               * This library is free software; you can redistribute it and/or
               * modify it under the terms of the GNU Lesser General Public
               * License version 2.1 as published by the Free Software Foundation.
               *
               * This library is distributed in the hope that it will be useful,
               * but WITHOUT ANY WARRANTY; without even the implied warranty of
               * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
               * Lesser General Public License for more details.
               *
               * You should have received a copy of the GNU Lesser General Public
               * License along with this library; if not, write to the Free Software
               * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
               */
              
              package org.ajax4jsf.taglib.html.jsp;
              
              import javax.el.ELContext;
              import javax.el.ExpressionFactory;
              import javax.el.ValueExpression;
              import javax.faces.application.Application;
              import javax.faces.context.FacesContext;
              import javax.servlet.jsp.JspException;
              import javax.servlet.jsp.tagext.Tag;
              import javax.servlet.jsp.tagext.TagSupport;
              
              import org.ajax4jsf.Messages;
              import org.ajax4jsf.event.AjaxPhaseListener;
              
              /**
               * @author shura
               *
               */
              public class KeepAliveTag extends TagSupport {
              
               /**
               *
               */
               private static final long serialVersionUID = 4322021112358067548L;
              
              //RonanKER : from String to ValueExpression
               private ValueExpression beanName = null;
              
               private ValueExpression ajaxOnly = null;
              
               /**
               * @return the ajaxOnly
               */
               public ValueExpression getAjaxOnly() {
               return ajaxOnly;
               }
              
               /**
               * @param ajaxOnly the ajaxOnly to set
               */
               public void setAjaxOnly(ValueExpression ajaxOnly) {
               this.ajaxOnly = ajaxOnly;
               }
              
               /**
               * @return the name
               */
              //RonanKER : from String to ValueExpression
               public ValueExpression getBeanName() {
               return beanName;
               }
              
               /**
               * @param name the name to set
               */
              //RonanKER : from String to ValueExpression
               public void setBeanName(ValueExpression name) {
               this.beanName = name;
               }
              
               /* (non-Javadoc)
               * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
               */
               public int doStartTag() throws JspException {
               if (beanName == null) {
               throw new JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
               }
              
               FacesContext facesContext = FacesContext.getCurrentInstance();
               Application application = facesContext.getApplication();
               ExpressionFactory factory = application.getExpressionFactory();
               ELContext elContext = facesContext.getELContext();
              //RonanKER
               //- ValueExpression beanNameEL =
               //- factory.createValueExpression(elContext, beanName, String.class);
               //- if(!beanNameEL.isLiteralText()){
               //+ if(!beanName.isLiteralText()){
               if(!beanName.isLiteralText()){
               throw new JspException(Messages.getMessage(Messages.NAME_MUST_BE_LITERAL));
               }
               boolean isAjaxOnly = false;
               if (null != ajaxOnly) {
               if (ajaxOnly.isLiteralText())
               {
               //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
               isAjaxOnly = Boolean.parseBoolean(ajaxOnly.getExpressionString());
               }
               else
               {
               isAjaxOnly = Boolean.TRUE.equals(ajaxOnly.getValue(elContext));
               }
              
               }
               // Get bean instance from EL expression.
              //RonanKER : get the String from the ValueExpression
               String beanExpression = "#{"+beanName.getExpressionString()+"}";
               ValueExpression valueExpression =
               factory.createValueExpression(elContext, beanExpression, Object.class);
               Object bean = valueExpression.getValue(elContext);
               // Put bean instance to ViewRoot.
               String beanAttributeName = isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+beanName;
               facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
               return Tag.SKIP_BODY;
               }
              
               /* (non-Javadoc)
               * @see javax.servlet.jsp.tagext.TagSupport#release()
               */
               public void release() {
               beanName = null;
               ajaxOnly = null;
               super.release();
               }
              
              
              }
              

              with this fix, all seems ok for me, so now i'm able to test more V.3.2.RC8 ...

              • 4. Re: 3.2.0-20080323 a4j:keepAlive JspValueExpression bug
                Kerdudou Ronan Apprentice

                well, i don't know why, but keepAlive doesn't keeps the handler alive... the constructor is called each times...

                going from 3.1.4 to 3.2 seems really an headache to me...

                • 5. Re: 3.2.RC8 a4j:keepAlive bug (URGENT)
                  Kerdudou Ronan Apprentice

                   

                  "RonanKER" wrote:
                  keepAliveTag should be :
                  [...]
                   // Get bean instance from EL expression.
                  //RonanKER : get the String from the ValueExpression
                   String beanExpression = "#{"+beanName.getExpressionString()+"}";
                   ValueExpression valueExpression =
                   factory.createValueExpression(elContext, beanExpression, Object.class);
                   Object bean = valueExpression.getValue(elContext);
                   // Put bean instance to ViewRoot.
                   String beanAttributeName = isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+beanName;
                   facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
                   return Tag.SKIP_BODY;
                   }
                  
                   [...]
                  



                  just a little mistake...
                  // Get bean instance from EL expression.
                  //RonanKER : get the String from the ValueExpression
                   String beanExpression = "#{"+beanName.getExpressionString()+"}";
                   ValueExpression valueExpression =
                   factory.createValueExpression(elContext, beanExpression, Object.class);
                   Object bean = valueExpression.getValue(elContext);
                   // Put bean instance to ViewRoot.
                  //RonanKER : get the String from the ValueExpression
                   String beanAttributeName = isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+beanName.getExpressionString();
                   facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
                   return Tag.SKIP_BODY;
                   }

                  Now this works perfectly !

                  Will you correct all this for tomorow release ?

                  • 6. Re: 3.2.0-20080323 a4j:keepAlive JspValueExpression bug
                    Kerdudou Ronan Apprentice

                    LLOOLL
                    reading your fix... just modify the tld : delete the <deferred-value> attribute...
                    it was so simple...
                    thanks :-)