1 Reply Latest reply on May 16, 2006 11:50 AM by gavin.king

    Extended Context EM class cast exception with non Stateful B

    zakkk

      I'm adapting the seam-messages example for my own application. I am NOT using a stateful bean since my message list has no need to be selectable - I'm simply trying to dump my message list to HTML in a datatable.

      The only differences between the example and my app is that I uses a stateless bean and a non-extended EM. When I use am extended persistence context I get this error:

      
      3:34:12,858 ERROR [STDERR] java.lang.ClassCastException: org.jboss.ejb3.stateless.StatelessBeanContext
      13:34:12,863 ERROR [STDERR] at org.jboss.ejb3.injection.ExtendedPersistenceContextInjector.inject(ExtendedPersistenceContextInjector.java:57)
      13:34:12,866 ERROR [STDERR] at org.jboss.ejb3.injection.ExtendedPersistenceContextInjector.inject(ExtendedPersistenceContextInjector.java:52)
      13:34:12,869 ERROR [STDERR] at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:88)
      13:34:12,872 ERROR [STDERR] at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
      13:34:12,878 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:51)
      13:34:12,881 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      13:34:12,886 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      13:34:12,889 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      13:34:12,892 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      13:34:12,895 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      13:34:12,898 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      13:34:12,903 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      13:34:12,906 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
      13:34:12,909 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
      13:34:12,913 ERROR [STDERR] at $Proxy392.getMobileGatewayRequests(Unknown Source)
      13:34:12,916 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      13:34:12,919 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      13:34:12,922 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      13:34:12,925 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      13:34:12,928 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      13:34:12,931 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
      13:34:12,935 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:1182)
      13:34:12,938 ERROR [STDERR] at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1141)
      13:34:12,947 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1104)
      13:34:12,950 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1090)
      13:34:12,953 ERROR [STDERR] at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:44)
      13:34:12,956 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:569)
      13:34:12,973 ERROR [STDERR] at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
      13:34:12,977 ERROR [STDERR] at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
      13:34:12,980 ERROR [STDERR] at org.apache.commons.el.ExpressionString.evaluate(ExpressionString.java:114)
      13:34:12,984 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378)
      13:34:12,991 ERROR [STDERR] at javax.faces.component.UIOutput.getValue(UIOutput.java:75)
      13:34:12,995 ERROR [STDERR] at org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
      13:34:12,998 ERROR [STDERR] at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:65)
      13:34:13,001 ERROR [STDERR] at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
      13:34:13,005 ERROR [STDERR] at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
      13:34:13,008 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
      13:34:13,011 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
      13:34:13,049 ERROR [STDERR] at org.apache.jsp.mobilerequestlist_jsp._jspx_meth_h_outputText_0(mobilerequestlist_jsp.java:184)
      13:34:13,056 ERROR [STDERR] at org.apache.jsp.mobilerequestlist_jsp._jspx_meth_h_form_0(mobilerequestlist_jsp.java:152)
      13:34:13,059 ERROR [STDERR] at org.apache.jsp.mobilerequestlist_jsp._jspx_meth_f_view_0(mobilerequestlist_jsp.java:119)
      13:34:13,062 ERROR [STDERR] at org.apache.jsp.mobilerequestlist_jsp._jspService(mobilerequestlist_jsp.java:84)
      13:34:13,065 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      13:34:13,068 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      13:34:13,071 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      13:34:13,084 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      13:34:13,087 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      13:34:13,088 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      13:34:13,101 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      13:34:13,104 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      13:34:13,107 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
      13:34:13,110 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
      13:34:13,113 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
      13:34:13,116 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      13:34:13,122 ERROR [STDERR] at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
      13:34:13,125 ERROR [STDERR] at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
      13:34:13,128 ERROR [STDERR] at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
      13:34:13,156 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
      13:34:13,156 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      13:34:13,157 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      13:34:13,157 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      13:34:13,158 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      13:34:13,159 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      13:34:13,159 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      13:34:13,159 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      13:34:13,159 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      13:34:13,159 ERROR [STDERR] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
      13:34:13,160 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
      13:34:13,160 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      13:34:13,160 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      13:34:13,160 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      13:34:13,160 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      13:34:13,161 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      13:34:13,161 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      13:34:13,161 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      13:34:13,161 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      13:34:13,161 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      13:34:13,162 ERROR [STDERR] at java.lang.Thread.run(Thread.java:613)
      13:34:13,313 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      javax.faces.el.EvaluationException: Cannot get value for expression 'Num messages: #{mobileGatewayRequestList.rowCount}'
      
      


      Because of this:

      
      public class ExtendedPersistenceContextInjector implements Injector, PojoInjector
      {
       // bits skipped
       public void inject(BeanContext beanContext, Object instance)
       {
       StatefulBeanContext ctx = (StatefulBeanContext)beanContext;
       EntityManager pc = ctx.getExtendedPersistenceContext(factory.getKernelName());
       if (pc == null)
       {
       pc = factory.createEntityManager();
       ctx.addExtendedPersistenceContext(factory.getKernelName(), pc);
       }
       }
      
      }
      


      Am I miss understanding something?

      When I am using a non-extened EM I get bizzare results, my table of results does not render due to
       <h:outputText value="No messages to display" rendered="#{mobileGatewayRequestList.rowCount==0}"/>
      


      BUT the following does not render either:

      <h:outputText value="Num messages: #{mobileGatewayRequestList.rowCount}"/>
      


      Which makes no sense,