I was able to find a workaround for my problem. The solution is in two parts:
1) This blog entry from Bruce Phillips who gives a walkthrough on solving exactly this problem: http://www.brucephillips.name/blog/index.cfm/2008/7/12/Using-The-JasperReports-Struts2-Plugin-A-Main-Report-And-A-Subreport 2) Unfortunately, the tutorial only works correctly for an older version of iReport. I'm using the newest, version 4.0.0 from January 2011 and I ran into a classDef exception that I couldn't resolve when I tried to compile the report from within iReport Designer: java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts2.views.jasperreports.ValueStackDataSource It is NOT complaining about finding the struts2 jasperreports plugin jar, that's already in the classpath. It's missing something else, and I couldn't figure out what. Luckily, I was able to work around this issue by compiling the report from within the Struts2 action, as described here: http://struts.apache.org/2.1.8/docs/jasperreports-tutorial.html Note that the comments in the sample code clearly (and correctly) warn against compiling on every action request, so I'll need to make sure I keep my app from executing that task every time the action runs. - Aaron On Wed, Feb 16, 2011 at 12:28 PM, Dave Newton <davelnew...@gmail.com> wrote: > That it works in JSP is meaningless--the two mechanisms are nothing > alike. The error message describes exactly what the problem is; you're > passing a list, not something that JR can use. > > Tragically, I don't actually remember what I did to fix this, although > I thought I had changed the plugin to handle that. Perhaps I never > checked it in, which would be too bad, because I no longer have access > to that code :( > > Dave > > On Wed, Feb 16, 2011 at 12:11 PM, Aaron Brown <aa...@thebrownproject.com> > wrote: >> I'm learning how to use Jasper reports, in this case as a result from >> a Struts2 (2.1.8) web app. I'm sending a List (ArrayList) of objects >> to a report and when the case is that simple, I have things working >> just fine. >> >> Next, I need to report a hierarchy of data like this example: >> List<Parent> parents; >> >> Parent: >> String name; >> List<Child> children; >> >> Child: >> String name; >> >> So I want to send the list of Parent objects to report A. This report >> includes a subreport, B, which should iterate over the list of Child >> objects for each Parent. Like: >> for (Parent p : parents) { >> for (Child c : p.children) { >> // report >> } >> } >> >> My problem is that my report, which compiles cleanly, cannot be >> "filled" by the Struts action. I instead get a stack trace about not >> being able to evaluate the expression $F{children}, and the end of the >> stack trace says: >> >> Caused by: java.lang.ClassCastException: >> org.apache.struts2.views.jasperreports.ValueStackDataSource >> incompatible with java.util.List >> >> I use hibernate and lazy loading on the back end, so I added a loop to >> pre-fetch and initialize all the "children" lists for each parent, >> just to make sure it wasn't an issue with lazy loading and sessions >> and such. The problem still occurs. >> >> I'm also making sure each "children" ArrayList is either full of data >> or initialized as an empty ArrayList, so there should not be any Null >> references. >> >> It appears from the stack trace error that Struts is not allowing >> Jasper to access the nested property of the Parent object. I'm doing >> the same kind of operation in a dozen places in .jsps, so I know my >> object model is solid. >> >> Does anyone have experience with this kind of Struts 2 reporting in >> Jasper who could lend me a hand learning how to do this? >> >> thanks, >> - Aaron >> >> -- >> Aaron Brown : aa...@thebrownproject.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > -- Aaron Brown : aa...@thebrownproject.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org