| Author |
Cannot retrieve definition for form bean null
|
ashwin deshpande
Greenhorn
Joined: Jun 14, 2004
Posts: 6
|
|
hi, i had thought i had got the hang of struts, but maybe not 100%. here is my relevant code snippets: struts-config.xml <form-beans> <form-bean name="licenseInfoForm" type="...forms.LicenseInfoForm /> </form-beans> <action-mappings> <action path="/searchLicenses" type="org.....actions.SearchLicenseAction" name="licenseInfoForm" scope="session" validate="false" > <forward name="success" path="/pages/searchResults.jsp" /> </action> </action-mappings> search.jsp <%@ taglib .... %> <head> <html:base /> </head> <html:form method="POST" action="searchLicenses" focus="serialNumber" > <TABLE width=400 bgcolor="#FFFFFF" border=0 cellpadding=2 cellspacing=15> <TR> <TD colspan=1>Please enter serial number :</TD> <TD><input type="text" name="serialNumber" maxlength=10 size=12 > </TD> </TR> .. ...etc LicenseInfoForm.java private int serialNumber ; public int getSerialNumber() { return serialNumber; } public void setSerialNumber(int serialNumber) { this.serialNumber = serialNumber; } --------------------- i have other parts working, so i dont think i am making any basic mistakes, but i just dont know what to... all help appreciated ..... if u want i can post more code... thanks, ashwin
|
If at first you dont succeed, take the 5th !
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
You need to use a Struts tag for the input field, i.e. instead of
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
The input tag is legal, it just won't prepopulate your jsp. The error you described typically results when the controller can't find your ActionForm. Unfortunately, nothing jumps out as the problem. (method="POST" is not necessary with html:form by the way) Does your LicenseInfoForm extend ActionForm?
|
A good workman is known by his tools.
|
 |
ashwin deshpande
Greenhorn
Joined: Jun 14, 2004
Posts: 6
|
|
hi, thanks for the inputs, i still cant get it to work i made the changes from <input type="text" /> to <html:text /> my LicenseInfoForm extends ValidatorForm, is there anyway that i could debug the struts part ? i have been stuck on this for 2 days now and i feel like im up against a wall.... all help appreciated -ashwin
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
Could you describe the actual problem (symptoms) in more detail?
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
I'm not seeing anything. I may be mistaken, but I think that either 1) The code posted is not verbatim to what you're using or 2) The error isn't happening until AFTER clicking the submit button, in which case the problem is actually with searchResults.jsp
|
 |
ashwin deshpande
Greenhorn
Joined: Jun 14, 2004
Posts: 6
|
|
hi, I found one of the problems, i had copied the code from a previous (working) jsp, and it had a <javascript formName="someOtherForm" /> entry in it....i removed it from my current page....i still got the "cannot retrieve bean info" error message, so i added the following line <html:form action="searchLicenses" focus="serialNumber" name="licenseInfoForm" type="org.....LicenseInfoForm" scope="session" > after this the jsp page was shown correctly, but after i click the submit button, i got a NullPointerException. In my corresponding ActionClass, i check to see if i receive any "form" in my execute method and all im getting is NULL, i even tried to set the scope="session" in the html:form tag and also in the actionmapping in struts-config.xml..... i print out a message when the actionform is created and destroyed and when when i was using scope=request, i could see that the form is created before the action is called, but its also destroyed....hence i had tried using session scope.... btw i dont think that the next page searchResults.jsp is causing any error as i get this exception in the execute() method itself, before i can forward to the next page.... here is the new error message: license info form created ..................... license info form deleted ..................... entering searchlicense action <Jun 17, 2004 11:16:26 AM PDT> <Error> <HTTP> <BEA-101017> <[ServletContext(id=1 6352912,name=webapp,context-path=/bits)] Root cause of ServletException. java.lang.NullPointerException at org.lapd.bits.struts.actions.SearchLicenseAction.executeAction(Search LicenseAction.java:45) at org.lapd.bits.struts.actions.ActionBase.execute(ActionBase.java:32) -ashwin
|
 |
Ann Klein
Greenhorn
Joined: Sep 21, 2003
Posts: 12
|
|
I am working through a tutorial http://javaboutique.internet.com/tutorials/Struts/jsp_page.html and of course it does not work immediately so I am comparing the bits to struts-blank and struts-example as distributed. My error is: org.apache.jasper.JasperException: Cannot retrieve definition for form bean null at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) etc Here are my bits and pieces SubmitForm.java package playground; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; public final class SubmitForm extends ActionForm { ============ struts-config.xml <form-beans> <form-bean name="submitForm" type="playground.SubmitForm" /> </form-beans> <global-forwards> <forward name="submit" path="/submit.do"/> </global-forwards> <action-mappings> <action path="/submit" type="playground.SubmitAction" attribute="submitForm" scope="request" input="/submit.jsp" validate="false"> <forward name="success" path="/submit.jsp"/> <forward name="failure" path="/submit.jsp"/> </action> </action-mappings> ============ Submit.jsp <html:form action="submit" > Last Name: <html:text property="lastName"/><br> Address: <html:textarea property="address"/><br> Sex: <html:radio property="sex" value="M"/>Male <html:radio property="sex" value="F"/>Female<br> Married: <html:checkbox property="married"/><br> Age: <html:select property="age"> <html ption value="a">0-19</html ption> <html ption value="b">20-49</html ption> <html ption value="c">50-</html ption> </html:select><br> <html:submit/> </html:form> I enter http://localhost/strutsApp/index.jsp which does <%@ taglib uri="/tags/struts-logic" prefix="logic" %> <logic:redirect forward="submit"/> the URL changes to http://localhost/strutsApp/submit.do I tried adding some of the parameters mentioned above to the form but they all produced new errors. For example when I added attribute there was a message about the tld. I have not found discussion of when it is name="myform" and when it is attribute="myform". Also find the changes from dots to slashes in URL/ URI / directory description mysterious. Any wise words welcome.
|
 |
Ann Klein
Greenhorn
Joined: Sep 21, 2003
Posts: 12
|
|
more detail Tutorial shows <html:form action="submit.do"> org.apache.jasper.JasperException: Cannot retrieve definition for form bean null <html:form action="submit" name="submitForm"> org.apache.jasper.JasperException: Must specify type attribute if name is specified <html:form action="submit" name="submitForm" attribute="submitForm"> org.apache.jasper.JasperException: /submit.jsp(24,0) Attribute attribute invalid according to the specified TLD <html:form action="submitForm"> org.apache.jasper.JasperException: Cannot retrieve mapping for action /submitForm <html:form action="submit.do" name="submitForm" attribute="submitForm"> org.apache.jasper.JasperException: /submit.jsp(24,0) Attribute attribute invalid according to the specified TLD still wandering
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
<action-mappings> <action path="/submit" type="playground.SubmitAction" name="submitForm" scope="request" input="/submit.jsp" validate="false"> <forward name="success" path="/submit.jsp"/> <forward name="failure" path="/submit.jsp"/> </action> </action-mappings>
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Cannot retrieve definition for form bean null
|
|
|