6 Replies Latest reply on Feb 12, 2009 4:35 PM by asaf sh

    Entity Query broken with Seam 2.1.0.GA

    Terry Apprentice
      Since upgrade to Seam 2.1.0.GA all my pages which use EntityQuery and "Restrictions" are broken. Is there is any recommended to fix this???

      There are two unwanted situations:

      1. If on search page I do not entery any values and hit Search; it query runs fine. But Query gets executes multiple times. It appears, EntityQuery's getResultList() executes new query each time 'resultList' is referenced in xhtml page.

      2. If on search page I enter any text for search and hit Search, runs query once, then crashes on second 'unwanted' run and throws exception down below.

      Sample MyList.java page
      -----------------------
      @Name("clientActivityLogList")
      public class ClientActivityLogList extends ListBase {

      private static final String[] RESTRICTIONS = new String[] {
              "lower(clientActivityLog.ipaddress) like concat(lower(#{clientActivityLogList.clientActivityLog.ipaddress}),'%')",
              "lower(clientActivityLog.action) like concat(lower(#{clientActivityLogList.clientActivityLog.action}),'%')",
              "lower(clientActivityLog.description) like concat(lower(#{clientActivityLogList.clientActivityLog.description}),'%')",};


          @Override
          public String getEjbql() {
              return "select clientActivityLog from ClientActivityLog clientActivityLog";
          }

          public ClientActivityLog getClientActivityLog() {
              return clientActivityLog;
          }

          @Override
          public List<Expressions.ValueExpression<String>> getRestrictions() {
              setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
              return super.getRestrictions();
          }
      }


      Exception mentioned in 2 above.
      -------------------------------

      16:29:25,754 INFO  [STDOUT] Hibernate:
          /* select
              organisationUserActivityLog
          from
              OrganisationUserActivityLog organisationUserActivityLog
          where
              subSystem='admin'
          order by
              organisationUserActivityLog.insertDate desc,
              organisationUser.username asc,
              organisationUserActivityLog.action asc */
      16:29:26,004 INFO  [STDOUT] Hibernate:
          /* select
              organisationUserActivityLog
          from
              OrganisationUserActivityLog organisationUserActivityLog
          where
              subSystem='admin'
          order by
              organisationUserActivityLog.insertDate desc,
              organisationUser.username asc,
              organisationUserActivityLog.action asc */
      16:29:26,270 WARN  [lifecycle] javax.el.ELException: /admin/licensee/organisation-user-activity-log-list.xhtml @100,136 rendered="#{empty organisationUserActivityLogList.resultList and organisationUserActivityLogList.executeSearch}": Error reading 'resultList' on type au.edu.tisc.home.OrganisationUserActivityLogList_$$_javassist_25
      16:29:26,270 WARN  [lifecycle] javax.el.ELException: /admin/licensee/organisation-user-activity-log-list.xhtml @100,136 rendered="#{empty organisationUserActivityLogList.resultList and organisationUserActivityLogList.executeSearch}": Error reading 'resultList' on type au.edu.tisc.home.OrganisationUserActivityLogList_$$_javassist_25
      16:29:26,411 ERROR [viewhandler] Error Rendering View[/admin/licensee/organisation-user-activity-log-list.xhtml]
      javax.faces.FacesException: javax.el.ELException: /admin/licensee/organisation-user-activity-log-list.xhtml @100,136 rendered="#{empty organisationUserActivityLogList.resultList and organisationUserActivityLogList.executeSearch}": Error reading 'resultList' on type au.edu.tisc.home.OrganisationUserActivityLogList_$$_javassist_25
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:393)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:276)
           at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
           at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:78)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
           at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:124)
           at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
           at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
           at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
           at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
           at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
           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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           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:182)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           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.valves.AccessLogValve.invoke(AccessLogValve.java:543)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
           at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:853)
           at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
           at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1513)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
           at org.jboss.seam.framework.Query.getRenderedEjbql(Query.java:252)
           at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:175)
           at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:73)
           at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:65)
           at au.edu.tisc.home.OrganisationUserActivityLogList.getResultList(OrganisationUserActivityLogList.java:108)
           at sun.reflect.GeneratedMethodAccessor382.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:40)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:34)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
           at au.edu.tisc.home.OrganisationUserActivityLogList_$$_javassist_25.getResultList(OrganisationUserActivityLogList_$$_javassist_25.java)
           at sun.reflect.GeneratedMethodAccessor381.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
           at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
           at org.jboss.el.parser.AstEmpty.getValue(AstEmpty.java:29)
           at org.jboss.el.parser.AstAnd.getValue(AstAnd.java:21)
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
           ... 60 more
      16:29:26,630 ERROR [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /admin/licensee/organisation-user-activity-log-list.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@15c9915]
      16:29:26,645 ERROR [viewhandler] Error Rendering View[/admin/licensee/organisation-user-activity-log-list.xhtml]
      javax.faces.FacesException: javax.el.ELException: /admin/licensee/organisation-user-activity-log-list.xhtml @100,136 rendered="#{empty organisationUserActivityLogList.resultList and organisationUserActivityLogList.executeSearch}": Error reading 'resultList' on type au.edu.tisc.home.OrganisationUserActivityLogList_$$_javassist_25
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:393)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:276)
           at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
      ...


        • 1. Re: Entity Query broken with Seam 2.1.0.GA
          Ingo Jobling Master

          Caused by: java.lang.NullPointerException
           at org.jboss.seam.framework.Query.getRenderedEjbql(Query.java:252)



          Try setting a breakpoint here to get some idea of what is going wrong.

          • 2. Re: Entity Query broken with Seam 2.1.0.GA
            Terry Apprentice
            The exception was caused by scenario described in my 1 situation. Resolving that fixed the exception.

            To stop getResultList() to fire new query everytime it is referenced, I had to put logic in my List Action bean to 'only call EntityQuery's getResultList() once'.


            However, Im not sure if this is the right way to do it. OR whether some tweak is required in Seam's EntityQuery to stop it executing query multiple times.


            public abstract class ClientList extends EntityQuery {

                private static final List<String> RESTRICTIONS = Arrays.asList(new String[]{
                  "lower(client.id) like concat('%',lower(#{clientList.client.id}),'%')",
                  "lower(client.username) like concat('%',lower(#{clientList.client.username}),'%')",
                  "lower(application.paymentReceipt) like concat('%',lower(#{clientList.receiptNumber}),'%')",
                });


                @Override
                @SuppressWarnings("unchecked")
                public List<ValueExpression> getRestrictions() {
                    if (super.getRestrictions().isEmpty()) {
                        super.setRestrictionExpressionStrings(RESTRICTIONS);
                    }
                    return super.getRestrictions();
                }


                @SuppressWarnings("unchecked")
                public String executeSearchAction() throws ApplicationException {

                    super.executeSearch = true;
                    super.setFirstResult(0);
                    super.setOrder(null);

                    if (this.clientListStore == null) {
                        this.clientListStore = super.getResultList();
                    }
                    return Constant.EMPTY_STRING;
                }


                @Override
                public String getEjbql() {

                    String ejbql = "select new " + ClientListStore.class.getName() +
                            "(client.id, client.username, client.status, " +
                    ....     
                 }

            }
            • 3. Re: Entity Query broken with Seam 2.1.0.GA
              Dan Allen Master

              I have mentioned elsewhere that you should not be building the restrictions list in teh getRestrictions() method as this method is consulted often to determine if the restrictions have changed. Instead, you should set the resrictions in the constructor or @PostConstruct method. You will see that seam-gen applications now work this way.

              • 4. Re: Entity Query broken with Seam 2.1.0.GA
                asaf sh Expert

                Hey,


                Is there any sample that works with entityQuery and search fields?


                SeamGen in ver 2.1 generates list code (class / xhtml) without search params,



                Thanks.

                • 5. Re: Entity Query broken with Seam 2.1.0.GA
                  Terry Apprentice
                  Asaf I haven't seen code generated by seam Gen, but if all you wanna  do is get user input and apply to query results then here is what you do in simplest form:

                  assume you wanna filter query by IP address supplierd by user.

                  in .xhtml, speccify search input field.

                  <h:form or a4j:form...>
                  <h:outputText value=#{yourBackingBeanComponent.ipAddress}

                  <h:commandButton or a4j:commandButton action="#{yourBackingBeanComponent.searchAction()}" ...../>
                  </h:form>

                  In your backing bean, pass ipAddress to query restrictions, see code in above post.

                  hope this helps.
                  • 6. Re: Entity Query broken with Seam 2.1.0.GA
                    asaf sh Expert

                    Hello,


                    I have to build the query based on the class properties,



                    Is there any other place to set the restrictions except via @PostConstruct or Constructor? both are executed before the values are attached to the class properties after form submission,




                    Many thanks,



                    Asaf.