4 Replies Latest reply on Oct 25, 2011 8:55 AM by edilmar

    RF4 a4j:mediaOutput x CDI ConversationScoped

    edilmar

      Hi,

       

      Environment: NetBeans7.0 + GlassFish 3.1 + CDI 1.1 + JSF2.1 + RichFaces4.0.0-Final.

       

      I tried to use a4j:mediaOutput to show a graphic generated by JFreeChart, like this:

       

        <a4j:mediaOutput element="img" cacheable="false" session="false" id="graficoTotais"

                  createContent="#{bean.criarGraficoTotais}"

                  mimeType="image/jpeg" alt="img" standby="Carregando gráfico..."

                  />

      I tried with session=false and session=true.

       

      The code for the bean is here:

       

        public void criarGraficoTotais(OutputStream out, Object data) throws Exception {

          JFreeChart chart = criarGrafico(criarDataSet());

          BufferedImage buffImg = chart.createBufferedImage(500, 375, BufferedImage.TYPE_INT_RGB, null);

          ImageIO.write(buffImg, "jpeg", out);

        }

      If I configure the bean like ConversationScoped, GF arises this error:

      GRAVE: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped

       

      If I use SessionScoped, all works fine. Then, the problem here I think is that the "ImageIO.write(buffImg, "jpeg", out);" writes the image after the page was processed, there is no context conversation available at this moment.

       

      Is there some work around to allow a4j:mediaOutput + bean ConversationScoped?

        • 1. Re: RF4 a4j:mediaOutput x CDI ConversationScoped
          lucaster

          I'm struggling against the same issue.

           

          I'm using JBoss AS 7.0.1.Final + RichFaces 4.1.0-SNAPSHOT

           

          I basically copied the rich:fileUpload example from the showcase (which contains also a4j:mediaOutput).

           

          If I change the scope of the bean to @ConversationScoped, I get the same exception you get:

           

          17:34:07,265 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/security-idmconsole].[Faces Servlet]] (http--0%3A0%3A0%3A0%3A0%3A0%3A0%3A0-8080-3) Servlet.service() for servlet Faces Servlet threw exception: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped

              at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:667) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:77) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:87) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.lucasterdev.test.RichFileUploadBean$Proxy$_$$_WeldClientProxy.paint(RichFileUploadBean$Proxy$_$$_WeldClientProxy.java) [classes:]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_22]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_22]

              at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_22]

              at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

              at org.richfaces.resource.MediaOutputResource.encode(MediaOutputResource.java:62) [richfaces-components-ui-4.1.0-SNAPSHOT.jar:]

              at org.richfaces.resource.UserResourceWrapperImpl.encode(UserResourceWrapperImpl.java:188) [richfaces-core-impl-4.1.0-SNAPSHOT.jar:]

              at org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:222) [richfaces-core-impl-4.1.0-SNAPSHOT.jar:]

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [solder-impl-3.1.0.Beta3.jar:]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72) [solder-impl-3.1.0.Beta3.jar:]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]

              at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.1.Final]

              at java.lang.Thread.run(Thread.java:679) [:1.6.0_22]

           

           

          I initially thought that the conversation got ended for some reason, but after adding the following:

          <h:outputText value="#{javax.enterprise.context.conversation}"/><br/>

           

          I noticed that the conversation works fine.

           

          The problem must reside in the I/O objects such as OutputStream.

          • 2. Re: RF4 a4j:mediaOutput x CDI ConversationScoped
            edilmar

            Hi,

             

            I did what you said like below, but the same error occurs. My app server is with GlassFish 3.1.

             

             

            <p>

              <h:outputText value="#{javax.enterprise.context.conversation}"/><br/>

              <a4j:mediaOutput element="img" cacheable="false" session="false" id="graficoTotais"

                        createContent="#{controller.criarGraficoTotais}"

                        mimeType="image/jpeg" alt="img" standby="Carregando gráfico..."

                        />

            </p>

            • 3. Re: RF4 a4j:mediaOutput x CDI ConversationScoped
              lucaster

              Sorry for being unclear.

               

              By "the conversation works fine" I only meant that the conversation was still alive and long running.

               

              As for now, it seems the only way to get rich:mediaOutput to work is to set the bean scope to @SessionScoped

              • 4. Re: RF4 a4j:mediaOutput x CDI ConversationScoped
                edilmar

                You are right. With @SessionScoped it really works.

                What I did was to save the image in a temporary web dir, and use h:graphicImage instead of mediaOutput.

                 

                I registered this issue in JIRA: https://issues.jboss.org/browse/RF-11585