G'day,

I appear to have resolved this issue that I kept running into with the Jasper Reports plugin...

If I have an action defined as:

       <action name="foo_*" method="{1}" class="com.xxx.foo">
           <result name="success" type="jasper">
             <param name="location">WEB-INF/foo.jasper</param>
               <param name="format">${contentType}</param>
             <param name="dataSource">dataSource</param>
             <param name="imageServletUrl">/servlets/image?image=</param>
</result> </action>
Using the Jasper Reports plugin that ships with S2 current, I get:

16:02:13,220 WARN [OgnlUtil] Caught OgnlException while setting property 'imageServletUrl' on type 'org.apache.struts2.views.jasperreports.JasperReportsResult'. java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of class org.apache.struts2.views.jasperreports.JasperReportsResult with modifiers "protected"
   at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
   at java.lang.reflect.Field.doSecurityCheck(Field.java:960)
   at java.lang.reflect.Field.getFieldAccessor(Field.java:896)
   at java.lang.reflect.Field.set(Field.java:657)
   at ognl.OgnlRuntime.setFieldValue(OgnlRuntime.java:1140)
...

And the imageServletUrl param does not take effect.

The issue appears to be that all of the setters in JasperReportsResult return a JasperReportsResult. The JavaBeans spec identifies that the setter for a simple property must return void. As a result, BeanInfo.getPropertyDescriptors won't see these setters as write methods for properties. With the other props in this class, that's not a problem - since they don't have getters, we don't get any propertyDescriptors for the properties, and proceed to look for methods individually (OgnlRuntime.java:1296). For imageServletUrl, however, there _is_ a valid getter. BeanInfo sees this as a read-only prop and returns a property descriptor for it, showing exactly that. Back in OGNL code, we see that we got a PropertyDescriptor, and don't bother asking for all methods. getSetMethod says "I don't have a set method," so OGNL eventually tries to just poke the field, resulting in the above error because the field is protected.

Solution: modify the setters in JasperReportsResult to return void. This has been confirmed to fix the above problem.

PK

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to