You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Satyanarayana M <sa...@infoglyptic.com> on 2002/12/09 13:56:36 UTC

No bean found under attribute key - any config problem?

Greetings,

I am new to Struts list
I am getting an exception with the message "No bean found under attribute key customerForm" when I am accessing the JSP where in which I am using the logic:equal tag. I am using this tag to check whether a formbean variable (called action) value is equal to "new" or not.
I have configured the formbean with the name customerForm in the config file. and I am sure that the bean is in classpath.
I am in need of the corrective action to solve the problem
The following are the details..

Thanks,
Satya
----------------

I have written an Action Form class called org.ig.shopone.web.CustomerForm that is having following 6 fields with public getter and setter methods (along with validate and reset methods).. 

    private String name;
    private String address;
    private String customerId;
    private String password;
    private String password2;
    private String action;

I am using the above Form in a JSP to check whether the action field value is "new" or "edit".

<html:html>
<head>
    <logic:equal name="customerForm" property="action" scope="request" value="new">
        <title><bean:message key="customer.new.title"/></title>
    </logic:equal>
    <logic:notEqual name="customerForm" property="action" scope="request" value="new">
        <title><bean:message key="customer.edit.title"/></title>
    </logic:notEqual>
    <html:base/>
</head>
<body bgcolor="white">
    <html:errors/>
...
..
When I am executing the above JSP file I am getting the following Exception

--------------------------------------------------------------------------------------------------------------
HTTP Status 500 - 
type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: No bean found under attribute key customerForm
void org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean)
JspServletWrapper.java:248
void org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean)
JspServlet.java:289
void org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
JspServlet.java:240
...........
....
--------------------------------------------------------------------------------------------------------------

The following is the configuration file 

<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
    <form-beans>
        <form-bean name="customerForm" type="org.ig.shopone.web.CustomerForm"/>
    </form-beans>
    <action-mappings>
        <action path="/customer" type="org.ig.shopone.web.actions.CustomerAction" name="customerForm" scope="request"/>
    </action-mappings>
    <message-resources parameter="ApplicationResources"/>
</struts-config>

--------------------------------------------------------------------------------------------------------------

RE: No bean found under attribute key - any config problem?

Posted by Justin Ashworth <ju...@ashworth.org>.
Hi Satya,

>From what you've included of your JSP file, it looks like the problem is
that the page has no reference to the customrForm bean by the time you
go to use it.  The <html:form.../> tag makes this bean available, but
since you are using the logic tags inside your header rather than within
an html:form, this bean is not available.  If the action property does
in fact belong in your form bean (as opposed to being its own request
attribute), then you can import the form bean with a <jsp:useBean.../>
tag at the top of your JSP.  I don't know how well jsp:useBean and
html:form play together when referencing the same bean, but give it a
try with something like this:

<jsp:useBean id="customerForm" scope="request"
type="org.ig.shopone.web.CustomerForm"/>

Just put that line at the top of your JSP and see what you get.

If the action property is never part of your form, then you might want
to consider making it its own request attribute, populated within the
Action class, and imported with a jsp:useBean tag similar to the one
above.

HTH,

Justin

> -----Original Message-----
> From: Satyanarayana M [mailto:satyanarayana@infoglyptic.com] 
> Sent: Monday, December 09, 2002 7:57 AM
> To: struts-user@jakarta.apache.org
> Subject: No bean found under attribute key - any config problem?
> 
> 
> Greetings,
> 
> I am new to Struts list
> I am getting an exception with the message "No bean found 
> under attribute key customerForm" when I am accessing the JSP 
> where in which I am using the logic:equal tag. I am using 
> this tag to check whether a formbean variable (called action) 
> value is equal to "new" or not. I have configured the 
> formbean with the name customerForm in the config file. and I 
> am sure that the bean is in classpath. I am in need of the 
> corrective action to solve the problem The following are the details..
> 
> Thanks,
> Satya
> ----------------
> 
> I have written an Action Form class called 
> org.ig.shopone.web.CustomerForm that is having following 6 
> fields with public getter and setter methods (along with 
> validate and reset methods).. 
> 
>     private String name;
>     private String address;
>     private String customerId;
>     private String password;
>     private String password2;
>     private String action;
> 
> I am using the above Form in a JSP to check whether the 
> action field value is "new" or "edit".
> 
> <html:html>
> <head>
>     <logic:equal name="customerForm" property="action" 
> scope="request" value="new">
>         <title><bean:message key="customer.new.title"/></title>
>     </logic:equal>
>     <logic:notEqual name="customerForm" property="action" 
> scope="request" value="new">
>         <title><bean:message key="customer.edit.title"/></title>
>     </logic:notEqual>
>     <html:base/>
> </head>
> <body bgcolor="white">
>     <html:errors/>
> ...
> ..
> When I am executing the above JSP file I am getting the 
> following Exception
> 
> --------------------------------------------------------------
> ------------------------------------------------
> HTTP Status 500 - 
> type Exception report
> 
> message 
> 
> description The server encountered an internal error () that 
> prevented it from fulfilling this request.
> 
> exception 
> 
> org.apache.jasper.JasperException: No bean found under 
> attribute key customerForm void 
> org.apache.jasper.servlet.JspServletWrapper.service(javax.serv
> let.http.HttpServletRequest, 
> javax.servlet.http.HttpServletResponse, boolean) 
> JspServletWrapper.java:248 void 
> org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.serv
> let.http.HttpServletRequest, 
> javax.servlet.http.HttpServletResponse, java.lang.String, 
> java.lang.Throwable, boolean) JspServlet.java:289 void 
> org.apache.jasper.servlet.JspServlet.service(javax.servlet.htt
> p.HttpServletRequest, javax.servlet.http.HttpServletResponse)
> JspServlet.java:240
> ...........
> ....
> --------------------------------------------------------------
> ------------------------------------------------
> 
> The following is the configuration file 
> 
> <?xml version = '1.0' encoding = 'windows-1252'?>
> <!DOCTYPE struts-config PUBLIC "-//Apache Software 
> Foundation//DTD Struts Configuration 1.1//EN" 
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
    <form-beans>
        <form-bean name="customerForm"
type="org.ig.shopone.web.CustomerForm"/>
    </form-beans>
    <action-mappings>
        <action path="/customer"
type="org.ig.shopone.web.actions.CustomerAction" name="customerForm"
scope="request"/>
    </action-mappings>
    <message-resources parameter="ApplicationResources"/>
</struts-config>

------------------------------------------------------------------------
--------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>