You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Cowan <pa...@wishlist.com.au> on 2001/02/02 07:06:27 UTC

Reflection security problem

Hi all,

I'm having a problem under Allaire JRun 3.0 (Struts nightly build from last
week).

The following code works in our page:

	<bean:write name="sku" property="product">

and the following doesn't

	<bean:write name="sku" property="product.name">

When there is a perfectly valid getName() method in the corresponding
Product returned by sku.getProduct().

The exception given is

javax.servlet.jsp.JspException: IllegalAccessException accessing property
product.name of bean sku
	at
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:225)
	at
jrun__viewproduct2ejsp10._jspService(jrun__viewproduct2ejsp10.java:130)

etc.

I have traced into the org.apache.struts.util.PropertyUtils class, and it
seems to run fine to a point. It correctly splits the 'product.name' to get
the first method; invokes it, it returns an object of the correct type
(MutableProduct); iterates to "name", finds the getter method OK (as it
should), but fails on the above when invoking it.

As a test to see if it's some weird JRun security manager thing, I invoked
it in NetBeans, using the following test stub:

    Object o = org.apache.struts.util.PropertyUtils.getNestedProperty(sku,
"product.name");

and it does the same thing (no JRun code in the classpath).

Any ideas? Probably something really obvious, but I've just missed it.

Thanks for any help, it's a hair-tearer.

Cheers,

Paul Cowan

Re: Reflection security problem

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Paul Cowan wrote:

> Hi all,
>
> I'm having a problem under Allaire JRun 3.0 (Struts nightly build from last
> week).
>
> The following code works in our page:
>
>         <bean:write name="sku" property="product">
>
> and the following doesn't
>
>         <bean:write name="sku" property="product.name">
>
> When there is a perfectly valid getName() method in the corresponding
> Product returned by sku.getProduct().
>
> The exception given is
>
> javax.servlet.jsp.JspException: IllegalAccessException accessing property
> product.name of bean sku
>

One thing to double check is that your bean class has a public no-args
constructor, that the class itself is declared public, and (of course) that the
getter methods are public.  I've seen IllegalAccessException problems when any
of these three things is violated.

Craig