10 Replies Latest reply on Jan 25, 2007 5:15 AM by Pete Muir

    Using Jasper Reports with Seam/JBoss

    Tom Blockley Newbie


      I'm trying to integrate JasperReports with a Seam application. I can compile and fill the reports, but I can't find any documentation on how to return the generated report to a web-page, especially using the Seam forwarding methods.

      Can anybody please advise? I feel like I'm punching around in the dark a bit here.

        • 2. Re: Using Jasper Reports with Seam/JBoss
          Tom Blockley Newbie

          That looks like it may just work. Don't want to return a pdf though - ideally I want to just return a HTML/jsf page that displays the report.

          Could I just use the same method but return a HTML version? Or is there a simpler way?

          • 3. Re: Using Jasper Reports with Seam/JBoss
            Pete Muir Master

            For an HTML doccument yes, AFAICS. If you have a (generated?) JSF view, then you would need to run it through the correct (JSP/facelets) renderer first - which the example resource loader won't do.

            Set the disposition to INLINE, the type to text/html, and don't override the filename and your browser should interpret it properly.

            • 4. Re: Using Jasper Reports with Seam/JBoss
              Norman Richards Master


              "petemuir" wrote:

              or better, consider using Seam's built in PDF generation.

              We're not there yet, but I am planning to add charting to the PDF generation.

              • 5. Re: Using Jasper Reports with Seam/JBoss
                Tom Blockley Newbie


                Been working on this, and can create the filled in html report, and load it to a byte[] in the Resource, but I keep hitting this error:

                javax.faces.el.EvaluationException: Exception while invoking expression #{reporting.file.render}
                 at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
                 at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:59)
                 at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
                 at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:98)
                 at org.jboss.seam.core.Pages.callAction(Pages.java:343)
                 at org.jboss.seam.core.Pages.callActions(Pages.java:322)
                Caused by: javax.faces.el.EvaluationException: Exception getting value of property file of base of type : org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$99e6343c
                 at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:96)
                Caused by: javax.faces.el.EvaluationException: Bean: org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$99e6343c, property: file
                 at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
                Caused by: java.lang.reflect.InvocationTargetException
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                Caused by: java.lang.RuntimeException: org.hibernate.TransactionException: Could not register synchronization
                 at org.jboss.ejb3.stateful.StatefulBeanContext.remove(StatefulBeanContext.java:273)
                 at org.jboss.ejb3.AbstractPool.remove(AbstractPool.java:171)
                 at org.jboss.ejb3.cache.simple.SimpleStatefulCache.remove(SimpleStatefulCache.java:299)

                The reporting bean is session scoped, and stateful. The Resource is (I think) working fine, I can create the new one, and print the contents to my log, but it fails when I try access it through pages.xml wiring.

                I'm fairly new to seam so apologies if this is a stupid question.

                • 6. Re: Using Jasper Reports with Seam/JBoss
                  Pete Muir Master

                  Looks like there is some transaction related problem going on. My best guess would to try marking the render method @Transactional. Or, better yet, do it in a JavaBean as a Seam component

                  • 7. Re: Using Jasper Reports with Seam/JBoss
                    Tom Blockley Newbie

                    hmm. I think the transaction exception is a bit of a red herring - it seems to appear at the bottom of all stack traces now.

                    I'm getting the same error now even when trying to access a simple string in my reporting bean:


                    public class ReportManager implements ReportManagerI {
                    public String hello="hello";

                    <h:outputText value="#{reporting.hello}" />

                    Is also giving me:
                    javax.faces.el.PropertyNotFoundException: /reporting.xhtml @37,53 value="#{reporting.hello}": Bean: org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$3196fd0, property: hello
                     at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
                     at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
                     at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
                     at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:69)
                     at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)

                    I think maybe there's something wrong with my bean?

                    • 8. Re: Using Jasper Reports with Seam/JBoss
                      Gavin King Master

                      What version of JBoss or EJB3 are you using. This is a bug in EJB3/Hibernate that was fixed a while ago. It just hides the real exception.

                      • 9. Re: Using Jasper Reports with Seam/JBoss
                        Tom Blockley Newbie

                        I'm using:
                        Jboss IDE 2.0.0.Beta2
                        JBoss Server 4.0.5.GA
                        JBoss Seam 1.0.1.GA2

                        Is that the appropriate setup to encounter this bug?

                        • 10. Re: Using Jasper Reports with Seam/JBoss
                          Pete Muir Master

                          Yes. Get Seam 1.1.1.GA - which is the latest release :)