Cannot find bean error in any scope

Discussions

Web tier: servlets, JSP, Web frameworks: Cannot find bean error in any scope

  1. Cannot find bean error in any scope (1 messages)

    I am using the Validator framework for a Struts 1.2.7 app. I have a login page for which I am validating for required fields (username & password). When I hit the submit button, I get an error message saying "Cannot find bean error in any scope". Doesn't this error bean get created by the validator framework? What is the problem?

    Here is my Login.jsp -
    <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
    <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
    <%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>

    <html:html>
    <head>
    <link href="<html:rewrite page="/css/argenerator.css" />" rel="stylesheet" type="text/css">
    <title>AR# Generator - Login</title>
    <html:base/>
    </head>
    <body topmargin="0">
    <!--<table width="790" cellspacing="0" cellpadding="0">
    <tr height="8"><td width="100%" bgcolor="#e6e6c7" valign="middle">&nbsp;</td></tr>-->
    <html:img page="/img/banner.jpg" />

    <br><br><br><br>
    <table width="790" cellspacing="0" cellpadding="0">
    <tr><td align="center">
    <h3>Login</h3>
    </td></tr>

    <logic:messagesPresent>
    <tr><td align="center">
    <span id="errorsHeader"><bean:message key="errors.validation.header"/></span><br>
    <html:messages id="error">
    <bean:write name="error"/><br>
    </html:messages>
    </td></tr>
    </logic:messagesPresent>

    <tr><td>&nbsp;</td></tr>

    <html:form action="login.do" focus="username">
    <tr><td align="center">
    Username: <html:text property="username" size="15" maxlength="20" styleClass="cool"/>
    </td></tr>
    <tr><td align="center">
    Password : <html:password property="password" size="15" maxlength="20" styleClass="cool"/>
    </td></tr>
    <tr><td align="center" height="50">
    <html:submit><bean:message key="button.login" /></html:submit>
    </td></tr>
    </html:form>

    <%@include file="Contact.jsp"%>

    </table>
    </body>
    </html:html>
  2. Cannot find bean error in any scope[ Go to top ]

    I figured out what the problem is. I had provided the incorrect message property name in the validation-rules.

    My validation-rules.xml had -
    <validator name="required"
                classname="org.apache.struts.validator.FieldChecks"
                   method="validateRequired"
             methodParams="java.lang.Object,
                           org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionMessages,
                           org.apache.commons.validator.Validator,
                           javax.servlet.http.HttpServletRequest"
                      msg="errors.required"/>

    But I had "error.required" in my message properties file.