5 Replies Latest reply on Dec 26, 2007 1:06 PM by pmuir

    Ajax and Pageflow very slow

    pietermartin

      Hi,

      I am using the pageflow and normal s:decorate with ajax pattern as in the examples.

      On the onblur event huge amounts of code seems to execute (seen in server.log) which takes so long that subsequest onblur events gets a concurrent problem


      summary=(The conversation ended, timed out or was processing another request), detail=(The conversation ended, timed out or was processing another request)


      Here is some of the logs from server.log generated on a single onblur ajax event.

      
      2007-11-28 12:24:16,052 DEBUG [org.ajax4jsf.webapp.BaseFilter] Filter start request processing at 11/28/07 12:24 PM for uri:
      /web/signyouup/capturePhoneDetails.seam
      2007-11-28 12:24:16,052 DEBUG [org.ajax4jsf.webapp.BaseFilter] Incoming request has Content-Type header with character encodin
      g UTF-8
      2007-11-28 12:24:16,052 DEBUG [org.ajax4jsf.webapp.BaseFilter] Filter request output to XML
      2007-11-28 12:24:16,052 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] XML filter service start processing request
      2007-11-28 12:24:16,053 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase RESTORE_VIEW 1
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.contexts.FacesLifecycle] >>> Begin JSF request
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.transaction.transaction
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.transaction.transaction
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.transaction.transaction
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
      2007-11-28 12:24:16,053 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.trans
      action.transaction
      
      
      .... same output for hundreds of lines
      
      
      2007-11-28 12:24:16,110 DEBUG [org.jboss.seam.Component] seam component not found: org.jboss.seam.transaction.required
      2007-11-28 12:24:16,110 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,110 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,110 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,110 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp
      .interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp
      .interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] seam component not found: org.jboss.seam.framework.required
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp
      .interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp
      .interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] seam component not found: org.jboss.seam.web.required
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.bpm.processInstance
      2007-11-28 12:24:16,111 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp
      .interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      
      
      .... same output for hundreds of lines
      
      
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.Services] executing default save operations
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.HibernateSaveOperation] saving process instance
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.SaveLogsOperation] flushing logs to logging service.
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@9
      05b91'
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.Services] executing default save operations
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.HibernateSaveOperation] saving process instance
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.SaveLogsOperation] flushing logs to logging service.
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.save.CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@9
      05b91'
      2007-11-28 12:24:16,751 DEBUG [org.jbpm.svc.Services] executing default save operations
      2007-11-28 12:24:16,752 DEBUG [org.jbpm.svc.save.HibernateSaveOperation] saving process instance
      2007-11-28 12:24:16,752 DEBUG [org.jbpm.svc.save.SaveLogsOperation] flushing logs to logging service.
      2007-11-28 12:24:16,752 DEBUG [org.jbpm.svc.save.CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@9
      05b91'
      
      
      .... same output for hundreds of lines
      
      
      2007-11-28 12:24:19,225 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase RENDER_RESPONSE 6
      2007-11-28 12:24:19,225 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] Process response to well-formed XML for AJAX XMLHttpRequest
      parser
      2007-11-28 12:24:19,226 DEBUG [org.ajax4jsf.webapp.tidy.TidyParser] Print output as XML
      2007-11-28 12:24:19,226 DEBUG [org.ajax4jsf.webapp.tidy.TidyParser] Message for HTML parsing : missing <!DOCTYPE> declaration
      2007-11-28 12:24:19,226 DEBUG [org.ajax4jsf.webapp.tidy.TidyParser] Message for HTML parsing : inserting missing 'title' eleme
      nt
      2007-11-28 12:24:19,226 DEBUG [org.ajax4jsf.webapp.tidy.TidyParser] Message for HTML parsing : meta isn't allowed in <body> el
      ements
      2007-11-28 12:24:19,227 DEBUG [org.ajax4jsf.webapp.tidy.TidyParser] Message for HTML parsing : meta isn't allowed in <body> el
      ements
      2007-11-28 12:24:19,228 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] Parsing html total time 2ms
      2007-11-28 12:24:19,228 DEBUG [org.ajax4jsf.webapp.BaseFilter] Finished request processing total time 721ms for uri: /web/sign
      youup/capturePhoneDetails.seam
      
      
      


      This single ajax onblur request took 721ms.

      It seems that Seam needs to work far to hard during the ajax request. Going to the bpm hundreds of times instantiating components hundreds of time etc.

      I note that the dvd example does not use ajax.

      Is this a know issue?

      I am using seam-2.0.0.GA and jboss-4.2.2.GA

      Cheers
      Pieter

        • 1. Re: Ajax and Pageflow very slow
          pmuir

          You need to tell us a bit more about your page and backing beans and how jbpm comes into it.

          • 2. Re: Ajax and Pageflow very slow
            pietermartin

            Here is is my components.xml

             <bpm:jbpm>
             <bpm:process-definitions>
             </bpm:process-definitions>
             <bpm:pageflow-definitions>
             <value>signUpCustomer.jpdl.xml</value>
             </bpm:pageflow-definitions>
             </bpm:jbpm>
            


            I start the pagefloe from capturePhoneDetails.page.xml with
            <begin-conversation join="true" pageflow="signupCustomer"/>


            here is the pageflow

            <?xml version="1.0"?>
            
            <pageflow-definition xmlns="http://jboss.com/products/seam/pageflow"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-2.0.xsd"
             name="signupCustomer">
            
             <start-page name="capturePhoneDetails" view-id="/signyouup/capturePhoneDetails.xhtml">
             <transition name="next" to="captureContactDetails">
             <action
             expression="#{webCustomerAction.moveTokenToCreateContact}" />
             </transition>
             </start-page>
             <page name="captureContactDetails" view-id="/signyouup/captureContactDetails.xhtml" no-conversation-view-id="/home.xhtml">
             <transition name="back" to="capturePhoneDetails">
             <action expression="#{webCustomerAction.moveTokenToChoosePhone}" />
             </transition>
             <transition name="next" to="captureContactSuccessful">
             <action expression="#{webCustomerAction.persistContact}" />
             <exception-handler exception-class="org.jbpm.JbpmException">
             <action expression="#{webCustomerAction.handleException}" />
             </exception-handler>
             </transition>
             </page>
             <decision name="captureContactSuccessful" expression="#{webCustomerAction.success}">
             <transition name="true" to="creditCheck"></transition>
             <transition name="false" to="failure"></transition>
             </decision>
             <page name="creditCheck" view-id="/signyouup/creditCheck.xhtml" no-conversation-view-id="/home.xhtml">
             <transition name="next" to="creditCheckSuccessful">
             <action expression="#{webCustomerAction.doCreateAccount}" />
             <action expression="#{webCustomerAction.doCreditCheck}" />
             <exception-handler exception-class="org.jbpm.JbpmException">
             <action expression="#{webCustomerAction.handleException}" />
             </exception-handler>
             </transition>
             </page>
             <decision name="creditCheckSuccessful" expression="#{webCustomerAction.success}">
             <transition name="false" to="failure"></transition>
             <transition name="true" to="capturePaymentDetails"></transition>
             </decision>
             <page name="capturePaymentDetails" view-id="/signyouup/capturePayment.xhtml" no-conversation-view-id="/home.xhtml">
             <redirect />
             <transition name="next" to="captureDeliveryDetails">
             <action expression="#{webCustomerAction.moveTokenToCaptureDeliveryDetails}" />
             </transition>
             </page>
             <page name="captureDeliveryDetails" view-id="/signyouup/captureDeliveryDetails.xhtml" no-conversation-view-id="/home.xhtml">
             <transition name="next" to="confirmTakePayment">
             <action expression="#{webCustomerAction.moveTokenToTakePayment}" />
             </transition>
             <transition name="back" to="capturePaymentDetails">
             <action expression="#{webCustomerAction.moveTokenToCaptureBankDetails}" />
             </transition>
             </page>
             <page name="confirmTakePayment" view-id="/signyouup/confirmTakePayment.xhtml" no-conversation-view-id="/home.xhtml">
             <transition name="next" to="salesOrderSuccessful">
             <action expression="#{webCustomerAction.doSalesOrder}" />
             <exception-handler exception-class="org.jbpm.JbpmException">
             <action expression="#{webCustomerAction.handleException}" />
             </exception-handler>
             </transition>
             <transition name="back" to="captureDeliveryDetails">
             <action expression="#{webCustomerAction.moveTokenToCaptureDeliveryDetails}" />
             </transition>
             </page>
             <decision name="salesOrderSuccessful" expression="#{webCustomerAction.success}">
             <transition name="false" to="failure"></transition>
             <transition name="true" to="success"></transition>
             </decision>
             <page name="success" view-id="/signyouup/success.xhtml" no-conversation-view-id="/home.xhtml">
             <end-conversation />
             <transition name="toBeginning" to="capturePhoneDetails" />
             </page>
             <page name="failure" view-id="/error.xhtml">
             <end-conversation />
             </page>
            </pageflow-definition>
            


            Here is my backing bean
            package com.yannitech.virgin.selfcare.customer.manager;
            
            import java.text.SimpleDateFormat;
            import java.util.Date;
            
            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.Factory;
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Out;
            import org.jboss.seam.annotations.Scope;
            import org.jboss.seam.faces.FacesMessages;
            import org.jboss.seam.log.Log;
            import org.jbpm.graph.action.SeamedAction;
            import org.jbpm.graph.exe.ExecutionContext;
            
            import com.yannitech.virgin.selfcare.common.enums.Contact_TypeEnum;
            import com.yannitech.virgin.selfcare.customer.entity.Contact;
            
            @Name("webCustomerAction")
            @Scope(ScopeType.CONVERSATION)
            public class WebCustomerAction extends SeamedAction {
            
             @Logger
             private Log log;
            
             @In
             private FacesMessages facesMessages;
            
             @In(create=true)
             private ContactManager contactManager;
            
             @In(create=true)
             @Out
             private Contact newContact;
            
             private boolean success = Boolean.TRUE;
            
            // @CreateProcess(definition="SignUpCustomerBP", processKey="syu#{syuProcessKey}")
             public void startBusinessProcess() {
             log.info("startBusinessProcess SignUpCustomerBP");
             }
            
            // @Transition("toCreateContact")
             public void moveTokenToCreateContact() {
             log.info("moveTokenToCreateContact");
             }
            
            // @Transition("toChoosePhone")
             public void moveTokenToChoosePhone() {
            
             }
            
            // @Transition("toFailure")
             public void moveTokenToFailure() {
            
             }
            
             public void persistContact() {
             log.info("persistContact");
             newContact.setType(Contact_TypeEnum.CONSUMER);
            // contactManager.persist(newContact);
            // BusinessProcess.instance().transition("toCreateAccount");
             }
            
             public void doCreateAccount() {
             log.info("doCreateAccount");
            // BusinessProcess.instance().transition("toCreditCheckContact");
             }
            
             public void doCreditCheck() {
             log.info("doCreditCheck");
            // BusinessProcess.instance().transition("toCaptureBankDetails");
             }
            
             public void moveTokenToCaptureDeliveryDetails() {
             log.info("moveTokenToCaptureDeliveryDetails");
            // BusinessProcess.instance().transition("toCaptureDelivery");
             }
            
            // @Transition("toCaptureBankDetails")
             public void moveTokenToCaptureBankDetails() {
             log.info("moveTokenToCaptureBankDetails");
             }
            
            // @Transition("toTakePayment")
             public void moveTokenToTakePayment() {
             log.info("moveTokenToTakePayment");
             }
            
             public void doSalesOrder() {
             log.info("doSalesOrder");
            // BusinessProcess.instance().transition("toComplete");
             }
            
             public Contact getNewContact() {
             return newContact;
             }
            
             public void setNewContact(Contact newContact) {
             this.newContact = newContact;
             }
            
             @Factory(value="syuProcessKey",scope=ScopeType.EVENT)
             public String getProcessKey() {
             SimpleDateFormat sdf = new SimpleDateFormat();
             return sdf.format(new Date());
             }
            
             public void handleException() {
             ExecutionContext executionContext = ExecutionContext.currentExecutionContext();
             facesMessages.add(executionContext.getException().getCause().getMessage());
             success=false;
            // BusinessProcess.instance().transition("toFailure");
             }
            
             public boolean isSuccess() {
             return success;
             }
            
             public void setSuccess(boolean success) {
             this.success = success;
             }
            
            }
            


            my jsf page

             <ui:composition xmlns="http://www.w3.org/1999/xhtml"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:rich="http://richfaces.ajax4jsf.org/rich"
             xmlns:a="https://ajax4jsf.dev.java.net/ajax"
             template="../layout/template.xhtml">
            
             <ui:define name="body">
             <h:messages globalOnly="true" styleClass="message" />
             <h:form>
             <a:outputPanel id="phoneOutput">
             <s:decorate id="phoneMakeDecorate" template="../layout/edit.xhtml">
             <ui:define name="label">Phone Make:</ui:define>
             <h:selectOneMenu value="#{selectedPhoneMake}" converter="#{phoneManager.phoneMakeConverter}">
             <s:selectItems value="#{phoneMakes}" var="phoneMake"
             label="#{phoneMake.name}" noSelectionLabel="Please select" />
             <a:support event="onchange"
             actionListener="#{phoneManager.findWebPhoneModelsForMake}"
             reRender="phoneOutput" requestDelay="500" />
             </h:selectOneMenu>
             </s:decorate>
             <s:decorate id="phoneModelDecorate" template="../layout/edit.xhtml">
             <ui:define name="label">Phone Model:</ui:define>
             <h:selectOneMenu value="#{selectedPhoneSalesChannel}" converter="#{phoneManager.phoneConverter}">
             <s:selectItems value="#{phoneSalesChannels}" var="phoneSalesChannel"
             label="#{phoneSalesChannel.phone.phoneModel.name} #{phoneSalesChannel.phone.pack}"
             noSelectionLabel="Please select" />
             <a:support event="onchange"
             actionListener="#{phoneManager.selectPhoneSalesChannel}"
             reRender="phoneOutput" requestDelay="500" />
             </h:selectOneMenu>
             </s:decorate>
             <s:decorate id="phonePriceDecorate" template="../layout/display.xhtml">
             <ui:define name="label">Price:</ui:define>
             <h:outputText value="#{selectedPhoneSalesChannel.price}" />
             </s:decorate>
             <s:graphicImage rendered="#{picture ne null}" value="#{picture}">
             <s:transformImageSize width="200" maintainRatio="true" />
             </s:graphicImage>
             </a:outputPanel>
             <s:decorate id="installmentTermDecorate" template="../layout/edit.xhtml">
             <ui:define name="label">Installment Term:</ui:define>
             <h:selectOneMenu value="#{webSalesOrderManager.webProductOrderIssue.vm_Installment_TermEnum}">
             <s:selectItems value="#{vmInstallment_TermEnums}" var="installment" label="#{installment.name}" noSelectionLabel="Please select" />
             <s:convertEnum />
             <a:support event="onblur" reRender="installmentTermDecorate" requestDelay="500" />
             </h:selectOneMenu>
             </s:decorate>
             <s:decorate id="ratePlanDecorate" template="../layout/edit.xhtml">
             <ui:define name="label">Rate Plan:</ui:define>
             <h:selectOneMenu value="#{webSalesOrderManager.webProductOrderIssue.ratePlan}">
             <s:selectItems value="#{ratePlans}" var="ratePlan" label="#{ratePlan.name}" noSelectionLabel="Please select" />
             <s:convertEntity />
             <a:support event="onblur" reRender="ratePlanDecorate" requestDelay="500" />
             </h:selectOneMenu>
             </s:decorate>
             <s:decorate id="upfrontAmountDecorate1" template="../layout/edit.xhtml">
             <ui:define name="label">Upfront Amount:</ui:define>
             <h:inputText id="upfrontAmountId1" value="#{webSalesOrderManager.webProductOrderIssue.upfrontAmount}">
             <a:support event="onblur" reRender="upfrontAmountDecorate1" requestDelay="500" />
             </h:inputText>
             </s:decorate>
             <s:decorate id="upfrontAmountDecorate" template="../layout/edit.xhtml">
             <ui:define name="label">Upfront Amount:</ui:define>
             <h:inputText id="upfrontAmountId" value="#{webSalesOrderManager.webProductOrderIssue.upfrontAmount}">
             <a:support event="onblur" reRender="upfrontAmountDecorate" requestDelay="500" />
             </h:inputText>
             </s:decorate>
             <h:commandButton id="next" value="Next" action="next" />
             </h:form>
             </ui:define>
             </ui:composition>
            


            I have removed all busines process stuff. The behavior is the same with or without the business process code.

            The slowness is on any of the jsf elements with an ajax onblur event.

            I changed the dvd example app to use some ajax and I see the same behavior there.

            It is a lot faster though probably due to the db being in memory hypersonic whereas I am using mysql in my app.

            Cheers
            Pieter

            • 3. Re: Ajax and Pageflow very slow
              pietermartin

              While I'm at it might as well mention another bug/feature I have encoutered. When an exception is thrown from a method called by an expresion in the page-definition, then it swallowed by the SeamExpression in its

              return new Expression()
               {
               private MethodExpression me;
               private ValueExpression ve;
              
               private void initMethodExpression()
               {
               me = EL.EXPRESSION_FACTORY.createMethodExpression(EL.EL_CONTEXT, expression, returnType, new Class[0]);
               }
              
               private void initValueExpression()
               {
               ve = EL.EXPRESSION_FACTORY.createValueExpression(EL.EL_CONTEXT, expression, returnType);
               }
              
               @Override
               public Object evaluate(VariableResolver resolver) throws ELException
               {
               try {
               try {
               if (me==null && ve==null)
               {
               initMethodExpression();
               }
               if (me!=null && ve==null)
               {
               return me.invoke(createELContext(resolver, mapper), new Object[0]);
               }
               }
               catch (javax.el.ELException e)
               {
               if (ve==null)
               {
               initValueExpression();
               }
               if (ve!=null)
               {
               return ve.getValue(createELContext(resolver, mapper));
               }
               }
               throw new ELException();
               }
               catch (javax.el.ELException e)
               {
               throw new ELException(e);
               }
               }
               };
              


              I then catch a JbpmException but there is no access to the original exception anymore.

              I am also not sure whether an exception element in pages.xml is suppose to work during a page flow. I can not get it to work and am forced to put decision nodes for every action I call from the page flow.

              Any help appreciated.

              Pieter

              • 4. Re: Ajax and Pageflow very slow
                pietermartin

                The exception issue is dealt with at http://jira.jboss.com/jira/browse/JBSEAM-2152

                Still not sure about the ajax during pageflows.

                Thanks
                Pieter

                • 5. Re: Ajax and Pageflow very slow
                  pmuir

                  Did you solve your problems? Sorry for the late reply.