6 Replies Latest reply on Apr 26, 2007 10:38 AM by Brian Smith

    Exception when using entity-query CRUD framework

    Brian Smith Apprentice

      This is my first attempt at using parts of the CRUD framework. I am getting an exception when trying to access the results of an entity query.

      Here is the query defined in components.xml

      <framework:entity-query name="allCustomers"
       ejbql="select u from User u"/>


      I am trying to use this as a part of the Trinidad Dialog framework but I don't think the problem is tied to Trinidad since the same exception occurs when I try to place my dataTable that shows the results from the query inline with my main page.

      Here is how I am using the query
      <tr:table value="#{allCustomers.resultList}" var="customer">
       <tr:column>
       <f:facet name="header">
       <tr:outputText value="Customer"/>
       </f:facet>
       <tr:commandLink text="#{customer.userName}" action="#{attachCustomer.select}"/>
       </tr:column>
       </tr:table>


      Here is the exception
      2007-04-26 08:20:03,228 ERROR [STDERR] Apr 26, 2007 8:20:03 AM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/AttachCustomer.xhtml]
      javax.faces.el.EvaluationException: /AttachCustomer.xhtml @23,69 value="#{allCustomers.resultList}": org.jboss.seam.framework.EntityQuery_$$_javassist_44
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
       at org.apache.myfaces.trinidad.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:68)
       at org.apache.myfaces.trinidad.component.UIXComponentBase.getProperty(UIXComponentBase.java:1119)
       at org.apache.myfaces.trinidad.component.UIXIterator.getValue(UIXIterator.java:397)
       at org.apache.myfaces.trinidad.component.UIXCollection._flushCachedModel(UIXCollection.java:1086)
       at org.apache.myfaces.trinidad.component.UIXCollection.encodeBegin(UIXCollection.java:511)
       at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:247)
       at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:280)
       at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent(PanelPartialRootRenderer.java:73)
       at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.renderContent(BodyRenderer.java:137)
       at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll(PanelPartialRootRenderer.java:153)
       at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.BodyRenderer.encodeAll(BodyRenderer.java:79)
       at org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(CoreRenderer.java:297)
       at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.DocumentRenderer.encodeAll(DocumentRenderer.java:81)
       at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:184)
       at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:704)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:252)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:573)
       at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:182)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:210)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:167)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:140)
       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:93)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: Bean: org.jboss.seam.framework.EntityQuery_$$_javassist_44, property: resultList
       at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:404)
       at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:71)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:118)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
       ... 57 more
      Caused by: java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:400)
       ... 63 more
      Caused by: java.lang.NullPointerException
       at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:104)
       at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:41)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
       at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.pr
      2007-04-26 08:20:03,228 ERROR [STDERR] oceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
       at org.jboss.seam.framework.EntityQuery_$$_javassist_44.getResultList(EntityQuery_$$_javassist_44.java)
       ... 68 more


        • 1. Re: Exception when using entity-query CRUD framework
          Pete Muir Master

          How is your entityManager defined in components.xml?

          • 2. Re: Exception when using entity-query CRUD framework
            Brian Smith Apprentice

            I don't think it is, I am using JBoss 4.0.4 with the EJB3 profile

            Here is my components.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <components xmlns="http://jboss.com/products/seam/components"
             xmlns:core="http://jboss.com/products/seam/core"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:framework="http://jboss.com/products/seam/framework"
             xmlns:security="http://jboss.com/products/seam/security"
             xsi:schemaLocation=
             "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
             http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
            
             <core:init
             jndi-pattern="CSB_SRMS/#{ejbName}/local"
             debug="true"/>
            
             <!--<core:pages no-conversation-view-id="/main.xhtml"/>-->
            
             <core:manager conversation-timeout="120000"
             concurrent-request-timeout="500"
             conversation-id-parameter="cid"
             conversation-is-long-running-parameter="clr"/>
            
             <core:resource_bundle>
             <core:bundle_names>
             <!--
             <value>com.stlouiscity.csb.jsf.messages.Messages</value>
             <value>com.stlouiscity.csb.jsf.messages.ErrorMessages</value>
             -->
             </core:bundle_names>
             </core:resource_bundle>
             <framework:entity-query name="allCustomers"
             ejbql="select u from User u"/>
            
            
             <core:jbpm>
             <core:pageflow-definitions>
             <value>pageflow.jpdl.xml</value>
             </core:pageflow-definitions>
             </core:jbpm>
            
            </components>


            • 3. Re: Exception when using entity-query CRUD framework
              Pete Muir Master

              The framework needs a SMPC, so you'll need to define one in components.xml. If you call it entityManager then the framework will pick it up automatically.

              • 4. Re: Exception when using entity-query CRUD framework
                Brian Smith Apprentice

                So something like this?

                <taken from your seamdiscs example>

                <core:managed-persistence-context name="entityManager"
                 auto-create="true"
                 persistence-unit-jndi-name="java:/csbEntityManagerFactory" />


                So the CRUD framework uses a different entity manager than my Session Beans?

                Also, since you are adding the seamdiscs example to Seam 1.3 and now that Trinidad has an official release, would it be possible to include more of Trinidad's features like PPR and the Dialog framework in your example so there is the some concrete example of these things working with Seam? It would be highly beneficial to me as well as others I am sure.



                • 5. Re: Exception when using entity-query CRUD framework
                  Pete Muir Master

                  Yes, thats the one. Well I would always use a SMPC in my session beans as well by doing @In EntityManager entityManager - there's no example of that in seamdiscs as I'm using the framework which makes (an SMPC) entityManager available via getEntityManager()

                  There is (some) PPR in the example - e.g. the tables all use PPR to page and sort (look at the Ajax4jsf and Trinidad link on the footer bar). I'll try to add some explicit PPR (for refreshing components when others change) in. I'll also try to add some dialog stuff - but I'm quite sure what it's aimed at, to me it looks like a Seam pageflow would be better if using a Seam applicaiton.

                  • 6. Re: Exception when using entity-query CRUD framework
                    Brian Smith Apprentice

                    Thanks Pete,

                    so instead of just letting EJB inject my entity manager automatically

                    private EntityManager em


                    I should let Seam do it instead?

                    @In
                    private EntityManager em


                    By specifying @In it will always know to get the Seam EntityManager from the EntityManagerFactory?

                    As far as the Dialog stuff, what I like about Trinidad is the built in tr:inputListOfValues control which displays a popup to get values from. It is useful when a Select/DropDown box just won't do. It also does PPR to issue a refresh when the value returns to the calling page.

                    In Seam I can use an s:link to propagate the conversation to the popup and I guess some JavaScript to make it a new window (Trinidad has an attribute useWindow that does this). How would I go about getting the value back to the calling page? Bijection? How does the calling page know to refresh/ppr?

                    Thanks again!