You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/07/01 14:25:03 UTC

Re: Struts ActionForm InstantiationException...? New Question

Subject: Re: Struts ActionForm InstantiationException...? New Question
From: "Scott Curtis" <sc...@smart421.com>
 ===
It turns out that the problem was caused by my Form class having a
constructor with two parameters of type String. As soon as I removed this
constructor the code worked.

Therefore, I have a new question. Can anyone tell me why my ActionForm class
can't have a non-default constructor?

thanks
 - scott

"Scott Curtis" <sc...@smart421.com> wrote in message
news:afpfqv$npd$1@basebeans.com...
> Hi,
>
> I have written a Form class that extends ActionForm, called LoginForm.java
> I have also written an Action class called LoginAction.java
> I have written an ActionMapping as follows:
>
> <action path="/login"
>     type="com.scurtis.web.action.LoginAction"
>     name="loginForm"
>     scope="request"
>     input="/login.jsp">
>     <forward name="success" path="/feedback.jsp" />
> </action>
>
> <form-beans type="org.apache.struts.action.ActionFormBean">
>     <form-bean name="loginForm"
>     type="com.scurtis.web.forms.LoginForm" />
> </form-beans>
>
> In my jsp I am have the following:
>
> <html:form action="login.do">
>     <html:text property="loginName" maxlength="60" size="40" />
>     <html:text property="password" maxlength="60" size="40" />
> </html:form>
>
> For some reason when I try to load the jsp I get the following error:
>
> javax.servlet.jsp.JspException: Exception creating bean of class
> com.scurtis.web.forms.LoginForm: java.lang.InstantiationException:
> com/scurtis/web/forms/LoginForm
>
> I would really appreciate if someone could shed some light onto why this
> might be happening and how to fix it. I have written a lot of forms (all
in
> the same project) and they all work.
>
> Many thanks in advance.
>  -scott
>
>
>



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


Re: Struts ActionForm InstantiationException...? New Question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 1 Jul 2002, Struts Newsgroup wrote:

> Date: Mon, 1 Jul 2002 05:25:03 -0700
> From: Struts Newsgroup <st...@basebeans.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: Re: Struts ActionForm InstantiationException...? New Question
>
> Subject: Re: Struts ActionForm InstantiationException...? New Question
> From: "Scott Curtis" <sc...@smart421.com>
>  ===
> It turns out that the problem was caused by my Form class having a
> constructor with two parameters of type String. As soon as I removed this
> constructor the code worked.
>
> Therefore, I have a new question. Can anyone tell me why my ActionForm class
> can't have a non-default constructor?
>

Because Struts requires that you follow the standard JavaBean convention
of having a zero-arguments constructor.  Any configuration of your bean
should be done through property setters (or the reset() method, in the
case of a form bean).

> thanks
>  - scott
>

Craig


> "Scott Curtis" <sc...@smart421.com> wrote in message
> news:afpfqv$npd$1@basebeans.com...
> > Hi,
> >
> > I have written a Form class that extends ActionForm, called LoginForm.java
> > I have also written an Action class called LoginAction.java
> > I have written an ActionMapping as follows:
> >
> > <action path="/login"
> >     type="com.scurtis.web.action.LoginAction"
> >     name="loginForm"
> >     scope="request"
> >     input="/login.jsp">
> >     <forward name="success" path="/feedback.jsp" />
> > </action>
> >
> > <form-beans type="org.apache.struts.action.ActionFormBean">
> >     <form-bean name="loginForm"
> >     type="com.scurtis.web.forms.LoginForm" />
> > </form-beans>
> >
> > In my jsp I am have the following:
> >
> > <html:form action="login.do">
> >     <html:text property="loginName" maxlength="60" size="40" />
> >     <html:text property="password" maxlength="60" size="40" />
> > </html:form>
> >
> > For some reason when I try to load the jsp I get the following error:
> >
> > javax.servlet.jsp.JspException: Exception creating bean of class
> > com.scurtis.web.forms.LoginForm: java.lang.InstantiationException:
> > com/scurtis/web/forms/LoginForm
> >
> > I would really appreciate if someone could shed some light onto why this
> > might be happening and how to fix it. I have written a lot of forms (all
> in
> > the same project) and they all work.
> >
> > Many thanks in advance.
> >  -scott
> >
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


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