You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Philippe Lagardere <ph...@gmail.com> on 2013/01/14 15:09:28 UTC

[2.3.8] Parameters interceptor tampering with file upload ?

Hello,

I've been trying to set up a form to upload a .txt file to the server,
and met a curious exception doing so. The exception implies Struts
expects the setter method to use a String array instead of a
java.io.File. Not that it would have been acceptable, but adding a
setter using a string array does not change anything (same exception
stack).
The action method itself is never reached, since the exception is
seemingly thrown during the ParametersInterceptor.doIntercept()
method.

I had a similar exception a couple of months ago, due to conversion
problems, since then solved by overriding Number and Date converters.
It is probably just a coincidence though - I can't see why type
conversion would relate here.

Here are some informations regarding the context.

[Form]

<s:form action="entreprise_charger_fichier" method="POST"
enctype="multipart/form-data">
   <s:file name="upload" label="Parcourir" accept="text/plain" />
   <s:submit value="Valider" />
</s:form>

[Action declaration in struts.xml] - nothing fancy here

<action name="entreprise_charger_fichier"	class="fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction"	method="chargerFichier">
   <result name="input" type="redirectAction">entreprise</result>
   <result type="redirectAction">entreprise</result>
</action>

[Miscellaneous information]

Interceptor stack is the default stack, with a couple custom
interceptors (the request goes through one, but the others aren't
reached).

The action class (DossiersEntrepriseAction) does have a field named
"upload", which is a java.io.File (as seen here :
http://struts.apache.org/2.3.8/docs/file-upload.html). The getter and
setter methods exist, but obviously they use or return a File, not a
String array.

Commons-IO and Commons-FileUpload are in the classpath, fetched as
transitive dependencies of the struts-core-2.3.8 artifact.

The problem also appears with Struts 2.3.7.


[Stack trace] - I trimmed it a bit but it's still not that edible, sorry

ognl.MethodFailedException: Method "setUpload" failed for object
fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction@1c803ae
[java.lang.NoSuchMethodException:
fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction.setUpload([Ljava.lang.String;)]
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1246)
    at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1494)
    at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
    at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
    at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
    at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
    at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:78)
    at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
    at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
    at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
    at ognl.SimpleNode.setValue(SimpleNode.java:301)
    at ognl.Ognl.setValue(Ognl.java:737)
    at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:218)
    at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
    at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
    at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:318)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:230)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    [INTERCEPTORS IN THE DEFAULT STACK KICK IN]
    [SERVER RELATED STUFF, CUSTOM INTERCEPTOR]

It is possible I missed something when setting up my classes/action,
but I can't find anything when double-checking.
At any rate, this doesn't explain why Struts (or OGNL) is asking for a
String[] at that point. I understand that strings are the standard way
to transfer data from a browser, but I can't see how it could apply to
file uploading.

Thank you in advance for your input,

PL

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [2.3.8] Parameters interceptor tampering with file upload ?

Posted by Lukasz Lenart <lu...@apache.org>.
Not a problem :-) Thanks to sharing your problem and solution :-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/1/17 Philippe Lagardere <ph...@gmail.com>:
> Hi again,
>
> I eventually solved the 'problem'. It turns out it had nothing to do
> with Struts, and everything to do with misplaced code.
>
> After searching for interference from Tiles, I realized the form for
> the file upload was included inside another form. After relocating the
> form, it works exactly as intended.
>
> I am a bit ashamed, and definitely sorry for using the mailing list
> because of such a silly mistake.
>
> Regards,
> PL
>
> 2013/1/16 Philippe Lagardere <ph...@gmail.com>:
>> Hello,
>>
>> The server was not a good track - apparently Tomcats can manage
>> multipart/form-data natively. The only configuration I could find
>> revolved around setting up the directory to send the file to, as well
>> as restricting the allowed file size or type.
>>
>> I tried setting up a file upload form on a mint project. That worked
>> straight away.
>> I added my custom converters, it still worked. I then added the custom
>> interceptor... still OK.
>>
>> At this point, there are a few things remaining to test, but I'm
>> sceptical as to how they could be related :
>>
>>    - Tiles integration (with struts-tiles-plugin in matching version
>> and StrutsTilesListener declared in web.xml)
>>    - Fiddling with other custom interceptors (but they are not reached
>> when the exception is raised)
>>    - Using the same form but in other JSP pages
>>
>> By any chance, does anyone have any clue concerning what could
>> interfere with Struts ?
>>
>> Thank you,
>> PL
>>
>> 2013/1/15 Philippe Lagardere <ph...@gmail.com>:
>>> I tried downgrading to 2.3.4.1, but the exception remains.
>>> I also get back my conversion errors on Number/Date fields (I
>>> mentionned them in the previous mail), but this was expected, as I did
>>> not remove the custom converters I use (see also :
>>> https://issues.apache.org/jira/browse/WW-3843 ).
>>>
>>> I haven't tried any older version, because that conversion issue is
>>> more critical than the file upload.
>>>
>>> My first suspect was Struts (probably because I had already met that
>>> exception for another Struts-related issue), but it just crossed my
>>> mind that the problem could come from something else, namely, the
>>> server. I used a Tomcat 6.0.32, more or less free of configuration.
>>> I'll dig into this and see if my troubles are server-related. I'll
>>> mail back if I find anything.
>>>
>>> But of course, any insight is more than welcome :)
>>>
>>> Thanks again,
>>>
>>> PL
>>>
>>> 2013/1/14 Lukasz Lenart <lu...@apache.org>:
>>>> Did you try to test with version prior to 2.3.7?
>>>>
>>>>
>>>> Regards
>>>> --
>>>> Łukasz
>>>> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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: [2.3.8] Parameters interceptor tampering with file upload ?

Posted by Philippe Lagardere <ph...@gmail.com>.
Hi again,

I eventually solved the 'problem'. It turns out it had nothing to do
with Struts, and everything to do with misplaced code.

After searching for interference from Tiles, I realized the form for
the file upload was included inside another form. After relocating the
form, it works exactly as intended.

I am a bit ashamed, and definitely sorry for using the mailing list
because of such a silly mistake.

Regards,
PL

2013/1/16 Philippe Lagardere <ph...@gmail.com>:
> Hello,
>
> The server was not a good track - apparently Tomcats can manage
> multipart/form-data natively. The only configuration I could find
> revolved around setting up the directory to send the file to, as well
> as restricting the allowed file size or type.
>
> I tried setting up a file upload form on a mint project. That worked
> straight away.
> I added my custom converters, it still worked. I then added the custom
> interceptor... still OK.
>
> At this point, there are a few things remaining to test, but I'm
> sceptical as to how they could be related :
>
>    - Tiles integration (with struts-tiles-plugin in matching version
> and StrutsTilesListener declared in web.xml)
>    - Fiddling with other custom interceptors (but they are not reached
> when the exception is raised)
>    - Using the same form but in other JSP pages
>
> By any chance, does anyone have any clue concerning what could
> interfere with Struts ?
>
> Thank you,
> PL
>
> 2013/1/15 Philippe Lagardere <ph...@gmail.com>:
>> I tried downgrading to 2.3.4.1, but the exception remains.
>> I also get back my conversion errors on Number/Date fields (I
>> mentionned them in the previous mail), but this was expected, as I did
>> not remove the custom converters I use (see also :
>> https://issues.apache.org/jira/browse/WW-3843 ).
>>
>> I haven't tried any older version, because that conversion issue is
>> more critical than the file upload.
>>
>> My first suspect was Struts (probably because I had already met that
>> exception for another Struts-related issue), but it just crossed my
>> mind that the problem could come from something else, namely, the
>> server. I used a Tomcat 6.0.32, more or less free of configuration.
>> I'll dig into this and see if my troubles are server-related. I'll
>> mail back if I find anything.
>>
>> But of course, any insight is more than welcome :)
>>
>> Thanks again,
>>
>> PL
>>
>> 2013/1/14 Lukasz Lenart <lu...@apache.org>:
>>> Did you try to test with version prior to 2.3.7?
>>>
>>>
>>> Regards
>>> --
>>> Łukasz
>>> + 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [2.3.8] Parameters interceptor tampering with file upload ?

Posted by Philippe Lagardere <ph...@gmail.com>.
Hello,

The server was not a good track - apparently Tomcats can manage
multipart/form-data natively. The only configuration I could find
revolved around setting up the directory to send the file to, as well
as restricting the allowed file size or type.

I tried setting up a file upload form on a mint project. That worked
straight away.
I added my custom converters, it still worked. I then added the custom
interceptor... still OK.

At this point, there are a few things remaining to test, but I'm
sceptical as to how they could be related :

   - Tiles integration (with struts-tiles-plugin in matching version
and StrutsTilesListener declared in web.xml)
   - Fiddling with other custom interceptors (but they are not reached
when the exception is raised)
   - Using the same form but in other JSP pages

By any chance, does anyone have any clue concerning what could
interfere with Struts ?

Thank you,
PL

2013/1/15 Philippe Lagardere <ph...@gmail.com>:
> I tried downgrading to 2.3.4.1, but the exception remains.
> I also get back my conversion errors on Number/Date fields (I
> mentionned them in the previous mail), but this was expected, as I did
> not remove the custom converters I use (see also :
> https://issues.apache.org/jira/browse/WW-3843 ).
>
> I haven't tried any older version, because that conversion issue is
> more critical than the file upload.
>
> My first suspect was Struts (probably because I had already met that
> exception for another Struts-related issue), but it just crossed my
> mind that the problem could come from something else, namely, the
> server. I used a Tomcat 6.0.32, more or less free of configuration.
> I'll dig into this and see if my troubles are server-related. I'll
> mail back if I find anything.
>
> But of course, any insight is more than welcome :)
>
> Thanks again,
>
> PL
>
> 2013/1/14 Lukasz Lenart <lu...@apache.org>:
>> Did you try to test with version prior to 2.3.7?
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [2.3.8] Parameters interceptor tampering with file upload ?

Posted by Philippe Lagardere <ph...@gmail.com>.
I tried downgrading to 2.3.4.1, but the exception remains.
I also get back my conversion errors on Number/Date fields (I
mentionned them in the previous mail), but this was expected, as I did
not remove the custom converters I use (see also :
https://issues.apache.org/jira/browse/WW-3843 ).

I haven't tried any older version, because that conversion issue is
more critical than the file upload.

My first suspect was Struts (probably because I had already met that
exception for another Struts-related issue), but it just crossed my
mind that the problem could come from something else, namely, the
server. I used a Tomcat 6.0.32, more or less free of configuration.
I'll dig into this and see if my troubles are server-related. I'll
mail back if I find anything.

But of course, any insight is more than welcome :)

Thanks again,

PL

2013/1/14 Lukasz Lenart <lu...@apache.org>:
> Did you try to test with version prior to 2.3.7?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [2.3.8] Parameters interceptor tampering with file upload ?

Posted by Lukasz Lenart <lu...@apache.org>.
Did you try to test with version prior to 2.3.7?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/1/14 Philippe Lagardere <ph...@gmail.com>:
> Hello,
>
> I've been trying to set up a form to upload a .txt file to the server,
> and met a curious exception doing so. The exception implies Struts
> expects the setter method to use a String array instead of a
> java.io.File. Not that it would have been acceptable, but adding a
> setter using a string array does not change anything (same exception
> stack).
> The action method itself is never reached, since the exception is
> seemingly thrown during the ParametersInterceptor.doIntercept()
> method.
>
> I had a similar exception a couple of months ago, due to conversion
> problems, since then solved by overriding Number and Date converters.
> It is probably just a coincidence though - I can't see why type
> conversion would relate here.
>
> Here are some informations regarding the context.
>
> [Form]
>
> <s:form action="entreprise_charger_fichier" method="POST"
> enctype="multipart/form-data">
>    <s:file name="upload" label="Parcourir" accept="text/plain" />
>    <s:submit value="Valider" />
> </s:form>
>
> [Action declaration in struts.xml] - nothing fancy here
>
> <action name="entreprise_charger_fichier"       class="fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction"     method="chargerFichier">
>    <result name="input" type="redirectAction">entreprise</result>
>    <result type="redirectAction">entreprise</result>
> </action>
>
> [Miscellaneous information]
>
> Interceptor stack is the default stack, with a couple custom
> interceptors (the request goes through one, but the others aren't
> reached).
>
> The action class (DossiersEntrepriseAction) does have a field named
> "upload", which is a java.io.File (as seen here :
> http://struts.apache.org/2.3.8/docs/file-upload.html). The getter and
> setter methods exist, but obviously they use or return a File, not a
> String array.
>
> Commons-IO and Commons-FileUpload are in the classpath, fetched as
> transitive dependencies of the struts-core-2.3.8 artifact.
>
> The problem also appears with Struts 2.3.7.
>
>
> [Stack trace] - I trimmed it a bit but it's still not that edible, sorry
>
> ognl.MethodFailedException: Method "setUpload" failed for object
> fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction@1c803ae
> [java.lang.NoSuchMethodException:
> fr.insee.resane.pro.ihm.controleur.actions.DossiersEntrepriseAction.setUpload([Ljava.lang.String;)]
>     at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1246)
>     at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1494)
>     at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
>     at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
>     at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
>     at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
>     at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:78)
>     at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
>     at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
>     at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
>     at ognl.SimpleNode.setValue(SimpleNode.java:301)
>     at ognl.Ognl.setValue(Ognl.java:737)
>     at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:218)
>     at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
>     at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
>     at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
>     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:318)
>     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:230)
>     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
>     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
>     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
>     [INTERCEPTORS IN THE DEFAULT STACK KICK IN]
>     [SERVER RELATED STUFF, CUSTOM INTERCEPTOR]
>
> It is possible I missed something when setting up my classes/action,
> but I can't find anything when double-checking.
> At any rate, this doesn't explain why Struts (or OGNL) is asking for a
> String[] at that point. I understand that strings are the standard way
> to transfer data from a browser, but I can't see how it could apply to
> file uploading.
>
> Thank you in advance for your input,
>
> PL
>
> ---------------------------------------------------------------------
> 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