In following code the <bean:write> tag fails with message: "org.apache.jasper.JasperException: Cannot find bean error in any scope "
<logic:messagesPresent> <UL> <html:messages id="error"> <LI><bean:write name="error" /></LI> </html:messages> </UL> </logic:messagesPresent> I thought this was faily standard code to display messages. Did I miss something? Thanks for any hints, Rich
posted 17 years ago
To answer my own question. The code I posted was OK. The problem was that one of the keys used to create an ActionError had a typo and therefore did not exist in my resource bundle. The <html:messsages> tag will set the variable defined by the tag's 'id' attribute ("error" in my case)to null if it cannot find the key in the resources. In such a case bean 'error' cannot be found because it has been set to null.
I had the same problem and have spent 3 days trying to solve it. Thanks to Rich for pointing me in the right direction.
My problem was complicated because I was using the Commons Validator. For the benefit of anyone else who has the same problem, you have to ensure not only that the keys associated with the field in the form are correctly set, but also the resource key associated with the particular validator (in my case, "required" needs a key "errors.required").