OK - I think I've found out what is happening, and I think that there may be
a bug in OGNL-2.7.3.

The error occurs when Struts/Ognl is trying to assign user entered values
back into a user object through the action.

When I try to process the jsp of the failing action, Ognl calls
getSetMethod(..) (OgnlRuntime 1436) which it ulimately tries to execute
against my user object. In turn, getSetMethod calls getDeclaredMethods(..)
in OgnlRunTime at line 1814. This returns a list of methods setXXXX found in
my user object - where XXXX is the name of the property being set. The list
contains one entry for each method(parameter Type) found. In my case I have
three candidate methods in my user class - setFoo(byte[]), setFoo(int) and
setFoo(String), so getDeclaredMethods() returns a list of 3 Method objects.

However, rather than then searching through the list of candidates to look
for a setFoo() with the  parameter type that matches the parameter type
being applied, OGNL ends up calling the first setFoo() method it found in
getDeclaredMethods() - so in my failing case it tries to call setFoo(byte[])
passing an object of type String (it's a return value via Html),  bombs and
issues the somewhat confusing message - NoSuchMethodException.

The reason that it works under Windows, Java 1.6.0_19 and doesn't under
Linux Java 1.6.0_12 is that the order of the methods returned by
getDeclaredMethods() is different in the two cases. On my Linux box,
getDeclaredMethods returns a list {setFoo(byte[]), setFoo(int),
setFoo(String)} whereas on the Windows box it returns {setFoo(String),
setFoo(byte[]), setFoo(int)}. So the windows version is working more by luck
than judgement.

So this is only going to bite when the underlying object has more than one
candidate method. Without digging further into Ognl, Struts and Xwork source
code I'm not sure exactly where the ultimate problem lies. Should I send
this to the developers list?

Regards

 
-- 
View this message in context: 
http://old.nabble.com/Webapp-runs-under-Windows%2C-throws-OGNL-error-under-Linux-tp28217837p28253488.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to