Hi, thanks for your comment. 2007/8/17, Rene Gielen <[EMAIL PROTECTED]>: > It's no bug, it's a feature... > > The policy for model access (e.g. property calls) via expression > evaluation is fail silent. It would cause tons of exceptions if ognl > expression evaluation / property access would not swallow them.
I feel it is overkill. The property getters in action classes may throw RuntimeException because of programming bugs. Even in this case, the current implementation just ignore the exception and the shown page will be just corrupted. We cannot show user friendly 'sorry page' because the Struts exception handler cannot get exception. > Most likely, you are doing business logic calls in your model access > domain and you should think of moving any call with the possibility to get > service relevant exceptions to the described business logic domain access > methods. No, it is not 'business logc'. In 'open session in view' pattern, the db transaction is kept open until the view rendering finishies. If you call the property access method of the acction class, it calls the getter method of tne entity class. It triggers O/R mapping layer invocation and lazily accesses the database. As a result, some kind of system exception (such as SQLException) may be thrown while view rendering. > Am Do, 16.08.2007, 17:01, schrieb Ruimo Uno: > > Hi, > > > > I have submitted this to user list a few hours ago but finally, I > > found the root cause of this issue. So, here I report it to dev list. > > If an exception is thrown while OGNL expression evaluation such as in > > the following scenario: > > > > XXXAction > > public String getMessage() { > > throw new NullPointerException(); > > } > > > > XXX.jsp > > <s:property value="message"/> > > > > The exception is wrapped in an OgnlException and re-thrown. It is > > caught in com.opensymphony.xwork2.util.CompoundRootAccessor.getProperty() > > and wrapped in a XWorkException() and re-thrown. > > > > } catch (OgnlException e) { > > if (e.getReason() != null) { > > final String msg = "Caught an Ognl exception while getting > > property " + name; > > throw new XWorkException(msg, e); > > } > > } catch (IntrospectionException e) { > > > > Finally, it is caught in > > com.opensymphony.xwork2.util.OgnlValueStack.findValue(String, Class) > > and swallowed. > > > > } catch (Exception e) { > > logLookupFailure(expr, e); > > > > return findInContext(expr); > > } finally { > > > > As a result, the upper layer does not receive any exception. So, no > > exception handler is invoked even if it is registered. Moreover, in > > 'open session in view' pattern, since the upper layer are not notified > > any error, the transaction is wrongly committed and it causes serious > > problem. > > > > I tried to add a catch clause for RuntimeException: > > > > } catch (RuntimeException e) { > > logLookupFailure(expr, e); > > throw e; > > } catch (Exception e) { > > logLookupFailure(expr, e); > > > > return findInContext(expr); > > } finally { > > > > Yes, the exception is successfully thrown to the upper layer with this > > code change. However, Struts shows 'java.io.IOException: Stream > > closed:' on the browser. This message seems a bit confusing. and > > difficult to realize what is actually happening (NPE is thrown). Does > > anybody have better solution on this? > > > > Thanks, > > > > -- > > Ruimo Uno > > (Shisei Hanai) > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Rene Gielen | http://it-neering.net/ > Aachen | PGP-ID: BECB785A > Germany | gielen at it-neering.net > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Ruimo Uno (Shisei Hanai) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]