• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot retrieve definition for form bean null

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to use a Struts tag for the input field, i.e.

instead of
 
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
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?
 
ashwin deshpande
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you describe the actual problem (symptoms) in more detail?
 
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
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
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
<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>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic