You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Searle <ch...@ovitas.no> on 2006/11/28 09:44:32 UTC
File upload using DynaActionForm/SynaValidatorForm
Struts 1.2
I need to try to get file upload to work for an existing struts app.
I was reading through the following:
http://wiki.apache.org/struts/StrutsFileUpload
where it mentions the following for Dyna action forms:
<form-bean name="myForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="myFile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
So - based on this - I ended up with the following for a DynaValidatorForm:
<form-bean name="uploadFile"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="title" type="java.lang.String"/>
<form-property name="revdate" type="java.lang.String"/>
<form-property name="revinfo" type="java.lang.String"/>
<form-property name="documentfile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
However - when the form POSTs to this action - I get the following in
the log:
2006-11-28 09:35:52,986 ERROR [org.apache.struts.util.RequestUtils]
Error creating form bean of class
org.apache.struts.validator.DynaValidatorForm
java.lang.NullPointerException: The type for property documentfile is
invalid
at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:415)
at
org.apache.struts.action.DynaActionFormClass.newInstance(DynaActionFormClass.java:184)
at
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:294)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:193)
at
org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:321)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
Does the DynaValidatorForm support FormFile? Is there some jar
dependency I need in place - maybe something from commons? I have the
following at present:
commons-beanutils.jar
commons-collections.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload.jar
commons-lang.jar
commons-logging.jar
commons-pool.jar
commons-resources.jar
commons-validator.jar
Have I missed some other obvious item? Made some really simple mistake?
For info - the form for submission looks like (formatting removed):
<form method="post" action="/admin/saveFile.do"
enctype="multipart/form-data">
<input type="text" size="30" name="title" id="title" value=""/>
<input type="text" size="30" name="revdate" id="revdate" value=""/>
<input type="text" size="30" name="revinfo" id="revinfo" value=""/>
<input type="file" size="30" name="manual" id="manual" value=""/>
<input type="submit" size="30" name="submit" id="submit" value="Save"/>
</form>
(note - this is generated using the velocity-tools for struts rather
than the standard jsp libraries).
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload using DynaActionForm/DynaValidatorForm
Posted by Chris Searle <ch...@ovitas.no>.
Mano Chinthaka Dasanayaka wrote:
> Hi,
> As per my knowledge Your Libraries are Ok...any way ,
> Have you set the
> <html:form action="/youraction" method="post"
> enctype="multipart/form-data">
I generate the form using velocity-tools support for struts rather than
JSP. The created form once displayed to the user has this html:
<form method="post" action="/admin/saveFile.do"
enctype="multipart/form-data">
<input type="text" size="30" name="title" id="title" value=""/>
<input type="text" size="30" name="revdate" id="revdate" value=""/>
<input type="text" size="30" name="revinfo" id="revinfo" value=""/>
<input type="file" size="30" name="manual" id="manual" value=""/>
<input type="submit" size="30" name="submit" id="submit" value="Save"/>
</form>
So - the action is correct, the method is post and the enctype is
multipart/form-data
If I understand the error log correctly - it is falling over when trying
to create an instance of the DynaValidatorForm to use for processing the
request - which makes me suspect that the error is either in the struts
form config xml or a missing dependency or similar.
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload using DynaActionForm/SynaValidatorForm
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mano,
Mano Chinthaka Dasanayaka wrote:
> Try Using
> <form-bean name="uploadFile"
> type="org.apache.struts.validator.DynaValidatorActionForm">
> <form-property name="title" type="java.lang.String"/>
> <form-property name="revdate" type="java.lang.String"/>
> <form-property name="revinfo" type="java.lang.String"/>
> <form-property name="documentfile"
> type="org.apache.struts.upload.FormFile"/>
> </form-bean>
>
> "org.apache.struts.validator.DynaValidatorActionForm"
Are you sure this is the problem? DynaValidatorForm is a valid form-bean
type, and it's the one I use, in fact. The error message indicates that
the type name for "documentFile" is unusable:
> Error creating form bean of class
> org.apache.struts.validator.DynaValidatorForm
> java.lang.NullPointerException: The type for property documentfile is
> invalid
Is this because DynaValidatorForm does not support
org.apache.struts.upload.FormFile properties? The documentation for this
form suggests that the only difference is that DynaValidatorActionForm
uses a separate XML file to define field validation rules. I'm not sure
how that's different than using commons-validator, though...
I think the problem is more likely that
org.apache.struts.upload.FormFile is not a class -- it's an interface.
Struts can't create a new object because Java can't create a new
instance of an interface.
The HOWTO Chris mentions instructs you to add this to your <controller>
configuration:
> multipartClass - The fully qualified Java class name of the multipart
> request handler class to be used with this module. Defaults is
> org.apache.struts.upload.CommonsMultipartRequestHandler.
Have you configured your <controller> element in this way? It appears
that there is a default, but that could be part of the problem.
I'm interested in the fact that a switch to DynaValidatorActionForm
fixed your problem; are you sure that you didn't change anything else?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFbFSD9CaO5/Lv0PARAmAIAJ4knbM0fRFLB5EgndwBO6+xMBAL6wCgwrlC
CEKS/pLVh2jjW5I6AerLCNA=
=uJGh
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload using DynaActionForm/SynaValidatorForm
Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,
With this DynaValidatorActionForm, you can have individual action mappings
validation in the validation.xml file
Regards,
Nuwan
----- Original Message -----
From: "Chris Searle" <ch...@ovitas.no>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, November 28, 2006 9:16 AM
Subject: Re: File upload using DynaActionForm/SynaValidatorForm
> Mano Chinthaka Dasanayaka wrote:
>> Try Using
>> <form-bean name="uploadFile"
>> type="org.apache.struts.validator.DynaValidatorActionForm">
>> <form-property name="title" type="java.lang.String"/>
>> <form-property name="revdate" type="java.lang.String"/>
>> <form-property name="revinfo" type="java.lang.String"/>
>> <form-property name="documentfile"
>> type="org.apache.struts.upload.FormFile"/>
>> </form-bean>
>>
>> "org.apache.struts.validator.DynaValidatorActionForm"
>
> Ah - now that was it. I will now have to go do some reading on what the
> difference is between DynaValidatorForm and DynaValidatorActionForm -
> since the app uses mostly DynaValidatorForm elsewhere. But - it did
> solve this issue. Many thanks.
>
> --
> Chris Searle
> chris@ovitas.no
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: File upload using DynaActionForm/SynaValidatorForm
Posted by Mano Chinthaka Dasanayaka <ma...@mubasher.net>.
HI,
Ok...But I'm Using IBM Web sphere 5.1 Server..
So is there any server specific settings to enable file uploading via
SSL...??
Thanks In advance
Regards,
Mano
-----Original Message-----
From: Chris Searle [mailto:chris@ovitas.no]
Sent: Tuesday, November 28, 2006 7:50 PM
To: Struts Users Mailing List
Subject: Re: File upload using DynaActionForm/SynaValidatorForm
Mano Chinthaka Dasanayaka wrote:
> Hi,
>
> Any way ...this will not work through SSL
>
> I used this to an APP and worked fine in HTTP
>
> But failed when HTTPS...
>
> Can you please have a look into this too...Thanks.
Worked fine for me. We have apache2 sitting serving via SSL and talking
AJP13 to jboss on localhost (well - the tomcat instance inside jboss) -
and it uploads the file just fine.
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload using DynaActionForm/SynaValidatorForm
Posted by Chris Searle <ch...@ovitas.no>.
Mano Chinthaka Dasanayaka wrote:
> Hi,
>
> Any way ...this will not work through SSL
>
> I used this to an APP and worked fine in HTTP
>
> But failed when HTTPS...
>
> Can you please have a look into this too...Thanks.
Worked fine for me. We have apache2 sitting serving via SSL and talking
AJP13 to jboss on localhost (well - the tomcat instance inside jboss) -
and it uploads the file just fine.
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: File upload using DynaActionForm/SynaValidatorForm
Posted by Mano Chinthaka Dasanayaka <ma...@mubasher.net>.
Hi,
Any way ...this will not work through SSL
I used this to an APP and worked fine in HTTP
But failed when HTTPS...
Can you please have a look into this too...Thanks.
Regards,
Mano
-----Original Message-----
From: Chris Searle [mailto:chris@ovitas.no]
Sent: Tuesday, November 28, 2006 2:47 PM
To: Struts Users Mailing List
Subject: Re: File upload using DynaActionForm/SynaValidatorForm
Mano Chinthaka Dasanayaka wrote:
> Try Using
> <form-bean name="uploadFile"
> type="org.apache.struts.validator.DynaValidatorActionForm">
> <form-property name="title" type="java.lang.String"/>
> <form-property name="revdate" type="java.lang.String"/>
> <form-property name="revinfo" type="java.lang.String"/>
> <form-property name="documentfile"
> type="org.apache.struts.upload.FormFile"/>
> </form-bean>
>
> "org.apache.struts.validator.DynaValidatorActionForm"
Ah - now that was it. I will now have to go do some reading on what the
difference is between DynaValidatorForm and DynaValidatorActionForm -
since the app uses mostly DynaValidatorForm elsewhere. But - it did
solve this issue. Many thanks.
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload using DynaActionForm/SynaValidatorForm
Posted by Chris Searle <ch...@ovitas.no>.
Mano Chinthaka Dasanayaka wrote:
> Try Using
> <form-bean name="uploadFile"
> type="org.apache.struts.validator.DynaValidatorActionForm">
> <form-property name="title" type="java.lang.String"/>
> <form-property name="revdate" type="java.lang.String"/>
> <form-property name="revinfo" type="java.lang.String"/>
> <form-property name="documentfile"
> type="org.apache.struts.upload.FormFile"/>
> </form-bean>
>
> "org.apache.struts.validator.DynaValidatorActionForm"
Ah - now that was it. I will now have to go do some reading on what the
difference is between DynaValidatorForm and DynaValidatorActionForm -
since the app uses mostly DynaValidatorForm elsewhere. But - it did
solve this issue. Many thanks.
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: File upload using DynaActionForm/SynaValidatorForm
Posted by Mano Chinthaka Dasanayaka <ma...@mubasher.net>.
Try Using
<form-bean name="uploadFile"
type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="title" type="java.lang.String"/>
<form-property name="revdate" type="java.lang.String"/>
<form-property name="revinfo" type="java.lang.String"/>
<form-property name="documentfile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
"org.apache.struts.validator.DynaValidatorActionForm"
Regards,
Mano
-----Original Message-----
From: Mano Chinthaka Dasanayaka [mailto:mano@mubasher.net]
Sent: Tuesday, November 28, 2006 2:32 PM
To: 'Struts Users Mailing List'
Subject: RE: File upload using DynaActionForm/SynaValidatorForm
Hi,
As per my knowledge Your Libraries are Ok...any way ,
Have you set the
<html:form action="/youraction" method="post"
enctype="multipart/form-data">
??
Regards,
Mano
-----Original Message-----
From: Chris Searle [mailto:chris@ovitas.no]
Sent: Tuesday, November 28, 2006 2:15 PM
To: user@struts.apache.org
Subject: File upload using DynaActionForm/SynaValidatorForm
Struts 1.2
I need to try to get file upload to work for an existing struts app.
I was reading through the following:
http://wiki.apache.org/struts/StrutsFileUpload
where it mentions the following for Dyna action forms:
<form-bean name="myForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="myFile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
So - based on this - I ended up with the following for a DynaValidatorForm:
<form-bean name="uploadFile"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="title" type="java.lang.String"/>
<form-property name="revdate" type="java.lang.String"/>
<form-property name="revinfo" type="java.lang.String"/>
<form-property name="documentfile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
However - when the form POSTs to this action - I get the following in
the log:
2006-11-28 09:35:52,986 ERROR [org.apache.struts.util.RequestUtils]
Error creating form bean of class
org.apache.struts.validator.DynaValidatorForm
java.lang.NullPointerException: The type for property documentfile is
invalid
at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:415)
at
org.apache.struts.action.DynaActionFormClass.newInstance(DynaActionFormClass
.java:184)
at
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java
:212)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:294)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:193)
at
org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor
.java:321)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
Does the DynaValidatorForm support FormFile? Is there some jar
dependency I need in place - maybe something from commons? I have the
following at present:
commons-beanutils.jar
commons-collections.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload.jar
commons-lang.jar
commons-logging.jar
commons-pool.jar
commons-resources.jar
commons-validator.jar
Have I missed some other obvious item? Made some really simple mistake?
For info - the form for submission looks like (formatting removed):
<form method="post" action="/admin/saveFile.do"
enctype="multipart/form-data">
<input type="text" size="30" name="title" id="title" value=""/>
<input type="text" size="30" name="revdate" id="revdate" value=""/>
<input type="text" size="30" name="revinfo" id="revinfo" value=""/>
<input type="file" size="30" name="manual" id="manual" value=""/>
<input type="submit" size="30" name="submit" id="submit" value="Save"/>
</form>
(note - this is generated using the velocity-tools for struts rather
than the standard jsp libraries).
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: File upload using DynaActionForm/SynaValidatorForm
Posted by Mano Chinthaka Dasanayaka <ma...@mubasher.net>.
Hi,
As per my knowledge Your Libraries are Ok...any way ,
Have you set the
<html:form action="/youraction" method="post"
enctype="multipart/form-data">
??
Regards,
Mano
-----Original Message-----
From: Chris Searle [mailto:chris@ovitas.no]
Sent: Tuesday, November 28, 2006 2:15 PM
To: user@struts.apache.org
Subject: File upload using DynaActionForm/SynaValidatorForm
Struts 1.2
I need to try to get file upload to work for an existing struts app.
I was reading through the following:
http://wiki.apache.org/struts/StrutsFileUpload
where it mentions the following for Dyna action forms:
<form-bean name="myForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="myFile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
So - based on this - I ended up with the following for a DynaValidatorForm:
<form-bean name="uploadFile"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="title" type="java.lang.String"/>
<form-property name="revdate" type="java.lang.String"/>
<form-property name="revinfo" type="java.lang.String"/>
<form-property name="documentfile"
type="org.apache.struts.upload.FormFile"/>
</form-bean>
However - when the form POSTs to this action - I get the following in
the log:
2006-11-28 09:35:52,986 ERROR [org.apache.struts.util.RequestUtils]
Error creating form bean of class
org.apache.struts.validator.DynaValidatorForm
java.lang.NullPointerException: The type for property documentfile is
invalid
at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:415)
at
org.apache.struts.action.DynaActionFormClass.newInstance(DynaActionFormClass
.java:184)
at
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java
:212)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:294)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:193)
at
org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor
.java:321)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
Does the DynaValidatorForm support FormFile? Is there some jar
dependency I need in place - maybe something from commons? I have the
following at present:
commons-beanutils.jar
commons-collections.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload.jar
commons-lang.jar
commons-logging.jar
commons-pool.jar
commons-resources.jar
commons-validator.jar
Have I missed some other obvious item? Made some really simple mistake?
For info - the form for submission looks like (formatting removed):
<form method="post" action="/admin/saveFile.do"
enctype="multipart/form-data">
<input type="text" size="30" name="title" id="title" value=""/>
<input type="text" size="30" name="revdate" id="revdate" value=""/>
<input type="text" size="30" name="revinfo" id="revinfo" value=""/>
<input type="file" size="30" name="manual" id="manual" value=""/>
<input type="submit" size="30" name="submit" id="submit" value="Save"/>
</form>
(note - this is generated using the velocity-tools for struts rather
than the standard jsp libraries).
--
Chris Searle
chris@ovitas.no
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org