Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Cannot Retrieve Definition for Form Bean Null

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have problem with displaying my JSP. The error message is:


'[ServletException in:/frame/content/messageForm.jsp] Cannot retrieve definition for form bean null'


1. I click on this link:


2. the action mapping in struts-config.xml is:

3. the tile piece .message.Form in the tiles-def.xml:

4. And my messageForm.jsp has:

<%@ taglib uri="/tags/struts-html" prefix="html" %>

<html:form action="/message/SendMessage">

all <html: .... and HTML tags for a form. The
code behaves well because I am able to see the
form in IDE view.

</html:form>

5. the action mapping in struts-config.xml:

6. the 'SendMessage.java' that is supposed to retrieve
the information in the form upon submit has not yet
been prepared yet.

7. close to the top of the struts-config.xml file, I
have:

What am I missing?
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I experimented a little bit:

1. I changed all struts tags to html tags in my messageForm.jsp and I also excluded the opening <html:form> and closing </html:form> tag.

The action mapping shown below works fine. I am able to see the form that I want to display in the browser.

<action
path="/MailMessage"
parameter=".message.Form"
type="org.apache.struts.actions.ForwardAction"/>

2. I then added the opening <html:form> in the beginning of the messageForm.jsp and the closing </html:form> tag at the end of the messageForm.jsp.

I got the error message 'cannot retrieve definition for form bean null'

3. the <html:form> tag looks like (copied from my
code):

<html:form action="/message/SendMessage">

4. the action mapping in the struts-config.xml looks
like (copied from my code):

<action
path="/message/SendMessage"
type="org.dhsinfo.message.SendMessage"
name="messageForm"
scope="request"
validate="false"
input=".message.Form">
<forward
name="success"
path="/confirmation/messageForwarded.jsp"/>
</action>

5. I have not yet prepared the SendMessage.java in the AppRoot/org/dhsinfo/message folder yet.

What could be the cause of the problem?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> > From: Caroline Jen
> > Sent: Friday, September 10, 2004 12:37 PM
> > To: Struts Users Mailing List
> > Subject: RE: [SOLVED]Cannot retrieve definition
> for form bean null
> >
> >
> > Hi, I have found the mistake.
> >
> > The mistake is that <html:textarea> is not a
> struts
> > tag equivalent to HTML <textarea> tag.
>
 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is an old post...has your problem been solved yet? If not I just wanted to let you know that I had the same problem and I found the following explanation doing a google search:

Exception org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
Probable Cause


This exception typically occurs because Struts cannot find the form bean it expects for a specific action according to the mapping in the struts-config.xml file. Most often, this is probably because the name given to the form in the name attribute of the form-bean element does not match the name attribute of the associated action's action element. In other words, the action and form should each have a name attribute that matches exactly, including case. It has been reported that this error has been seen when no name attribute is associated with the action. If there is no name attribute in an action element, no form is associated with the action. Others have reported this error as merely a symptom of something completely unrelated (all too common), but the mismatch of name attributes in the form-bean and action elements in the struts-config.xml file is the usual culprit.



My problem was that I had left the "name" attribute out of some of the tags in my struts-config.xml.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ronnie,

Read the posts carefully. The form-bean-null problem was fixed when she added the html:form tags to her page.

This worked for her because it sets up a default bean to be used by the enclosed html: tags so that the name attribute becomes unnecessary.
 
This will take every ounce of my mental strength! All for a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic