You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Magnus Haraldsen Amundsen <Ma...@computas.com> on 2008/07/15 13:08:17 UTC
Apache commons-fileupload returns an empty list
Hi,
I want to use commons-fileupload to handle fileupload in my webapp. I've
followed the tutorial at http://commons.apache.org/fileupload/using.html
<http://commons.apache.org/fileupload/using.html> but line
List /* FileItem */ items =
upload.parseRequest(request.getCocoonRequest());
always gives me an empty list. items.size() == 0.
I suspect that this is because the HttpServletRequest is already parsed
somewhere within Cocoon. Is there a workaround for this problem?
-Magnus
IMPORTANT NOTICE:
This message may contain confidential information.
If you have received this e-mail in error, do not use, copy or
distribute it. Do not open any attachments. Delete it immediately from
your system and notify the sender promptly by e-mail that you
have done so. Thank you.
Re: Apache commons-fileupload returns an empty list
Posted by Robin Wyles <ro...@robinwyles.com>.
Hi Magnus,
I ran into this recently too... It might help if you understand the
relevant part of Cocoon's request processing...
1. By default all requests are passed through the servlet filter
org.apache.cocoon.servlet.multipart.MultipartFilter.
2. MultipartFilter calls
org.apache.cocoon.servlet.multipart.RequestFactory
3. If the request is of type multipart/form-data, RequestFactory
uses org.apache.cocoon.servlet.multipart.MultipartParser to parse
the request into a
org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest
4. MultipartHttpServletRequest or HttpServletRequest is passed up the
filter chain.
The MultipartHttpServletRequest that is created provides direct
access to the uploaded Parts as if they were request parameters,
usually negating the need for commons-fileupload.
I've never done it myself, but I guess if you wanted to handle the
request directly you could try removing the MultipartFilter
configuration from your web.xml.
Hope this helps,
Robin
at
org.apache.cocoon.servlet.multipart.RequestFactory.getServletRequest
to see how uploaded files are parsed automatically by Cocoon
On 15 Jul 2008, at 12:08, Magnus Haraldsen Amundsen wrote:
> Hi,
>
> I want to use commons-fileupload to handle fileupload in my webapp.
> I’ve followed the tutorial at http://commons.apache.org/fileupload/
> using.html but line
>
> List /* FileItem */ items = upload.parseRequest
> (request.getCocoonRequest());
>
> always gives me an empty list. items.size() == 0.
>
> I suspect that this is because the HttpServletRequest is already
> parsed somewhere within Cocoon. Is there a workaround for this
> problem?
>
> -Magnus
>
>
>
> IMPORTANT NOTICE: This message may contain confidential
> information. If you have received this e-mail in error, do not use,
> copy or distribute it. Do not open any attachments. Delete it
> immediately from your system and notify the sender promptly by e-
> mail that you have done so. Thank you.
>
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by David Legg <da...@searchevent.co.uk>.
Hi Grek,
>> Unfortunately, it's not fixed in trunk. Take a look at the history of
>> this file[1] and you will see that is has not changed for more than a
>> year now.
>>
>> The problem we see here is that archetype plug-in for Maven tries to
>> find all expressions in files that it creates...
>> Unfortunately, #{message} is treated as an expression too but it
>> shouldn't. It's [not] aimed at archetype plug-in but Cocoon's
>> template generator.
>>
>> According to this[2] page (archetype uses velocity) the fix should be
>> easy: we need to escape "#" character using "\#" and everything
>> should work just fine...
Aha! Well spotted ;-)
>> I'll try to fix this issue ASAP.
Thanks. As this is may be someone's very first close encounter with
Cocoon 2.2 we want to set a good example.
Regards,
David Legg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Grzegorz Kossakowski pisze:
> David Legg pisze:
>> Ken,
>>> Thankyou very much, David. I can confirm that the spring-bean now
>>> does work properly.
>>
>> Thanks for confirming that.
>>
>>> How do we report this to the developers?
>>
>> Normally, you would open a new item in the bugs database (called JIRA)
>> [1].
>>
>> However, I've just looked at the latest version of that file in the
>> SVN repository and it looks like it is fixed already. I think it is
>> in the 'trunk' at this location: -
>>
>> [svn
>> trunk]\tools\archetypes\cocoon-22-archetype-block\src\main\resources\archetype-resources\src\main\resources\COB-INF\demo\spring-bean.jx.xml
>>
>>
>> The code looks like this: -
>>
>> <demo>
>> <module>${groupId}:${artifactId}</module>
>> <spring>#{message}</spring>
>> </demo>
>>
>> I suspect though that getting this change incorporated into the wide
>> world is a little more involved than just issuing a new release of
>> Cocoon because someone has to upload the new version to the official
>> maven site I think.
>
> Unfortunately, it's not fixed in trunk. Take a look at the history of
> this file[1] and you will see that is has not changed for more than a
> year now.
>
> The problem we see here is that archetype plug-in for Maven tries to
> find all expressions in files that it creates and tries to resolve these
> expressions to correct values. The good example is ${artifactId}
> expression that we see above. Archetype plug-in will resolve it to
> artifactId of the block that it prepares.
>
> Unfortunately, #{message} is treated as an expressions too but it
> shouldn't. It's aimed at archetype plug-in but Cocoon's template generator.
>
> According to this[2] page (archetype uses velocity) the fix should be
> easy: we need to escape "#" character using "\#" and everything should
> work just fine...
>
>> Anyhow... the main thing is it has been covered and at some point the
>> corrected version will be available. In the meantime we can sit back;
>> smug in the knowledge that we know the answer ;-)
>
> As you see, there is a bug here so one should create a JIRA report. :-)
>
> I'll try to fix this issue ASAP.
Argh...
Forgot to provide links:
[1]
http://svn.eu.apache.org/viewvc/cocoon/trunk/tools/archetypes/cocoon-22-archetype-block/src/main/resources/archetype-resources/src/main/resources/COB-INF/demo/spring-bean.jx.xml?view=log
[2] http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#getting_literal
--
Grzegorz Kossakowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
David Legg pisze:
> Ken,
>> Thankyou very much, David. I can confirm that the spring-bean now does
>> work properly.
>
> Thanks for confirming that.
>
>> How do we report this to the developers?
>
> Normally, you would open a new item in the bugs database (called JIRA) [1].
>
> However, I've just looked at the latest version of that file in the SVN
> repository and it looks like it is fixed already. I think it is in the
> 'trunk' at this location: -
>
> [svn
> trunk]\tools\archetypes\cocoon-22-archetype-block\src\main\resources\archetype-resources\src\main\resources\COB-INF\demo\spring-bean.jx.xml
>
>
> The code looks like this: -
>
> <demo>
> <module>${groupId}:${artifactId}</module>
> <spring>#{message}</spring>
> </demo>
>
> I suspect though that getting this change incorporated into the wide
> world is a little more involved than just issuing a new release of
> Cocoon because someone has to upload the new version to the official
> maven site I think.
Unfortunately, it's not fixed in trunk. Take a look at the history of this file[1] and you will see
that is has not changed for more than a year now.
The problem we see here is that archetype plug-in for Maven tries to find all expressions in files
that it creates and tries to resolve these expressions to correct values. The good example is
${artifactId} expression that we see above. Archetype plug-in will resolve it to artifactId of the
block that it prepares.
Unfortunately, #{message} is treated as an expressions too but it shouldn't. It's aimed at archetype
plug-in but Cocoon's template generator.
According to this[2] page (archetype uses velocity) the fix should be easy: we need to escape "#"
character using "\#" and everything should work just fine...
> Anyhow... the main thing is it has been covered and at some point the
> corrected version will be available. In the meantime we can sit back;
> smug in the knowledge that we know the answer ;-)
As you see, there is a bug here so one should create a JIRA report. :-)
I'll try to fix this issue ASAP.
--
Best regards,
Grzegorz Kossakowski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by David Legg <da...@searchevent.co.uk>.
Ken,
> Thankyou very much, David. I can confirm that the spring-bean now does
> work properly.
Thanks for confirming that.
> How do we report this to the developers?
Normally, you would open a new item in the bugs database (called JIRA) [1].
However, I've just looked at the latest version of that file in the SVN
repository and it looks like it is fixed already. I think it is in the
'trunk' at this location: -
[svn
trunk]\tools\archetypes\cocoon-22-archetype-block\src\main\resources\archetype-resources\src\main\resources\COB-INF\demo\spring-bean.jx.xml
The code looks like this: -
<demo>
<module>${groupId}:${artifactId}</module>
<spring>#{message}</spring>
</demo>
I suspect though that getting this change incorporated into the wide
world is a little more involved than just issuing a new release of
Cocoon because someone has to upload the new version to the official
maven site I think.
Anyhow... the main thing is it has been covered and at some point the
corrected version will be available. In the meantime we can sit back;
smug in the knowledge that we know the answer ;-)
Regards,
David Legg
[1] https://issues.apache.org/jira/browse/COCOON
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by Ken Starks <ke...@lampsacos.demon.co.uk>.
Thankyou very much, David. I can confirm that the spring-bean now does
work properly.
How do we report this to the developers?
David Legg wrote:
> Hi Ken,
>
>> It depends which way I do things, but I am still having
>> problems with 'Your first Cocoon 2.2 Application'
>> because the Java Bean doesn't work.
>>
>> Can anyone explain this behaviour, in terms that a
>> non-java-speaker might understand?
>
> I think the problem is that the
> 'src/main/resources/COB-INF/demo/spring-bean.jx.xml' file contains an
> old version of the JX syntax for getting hold of a javabean's property.
>
> Try editing the file so that instead of: -
>
> <spring>#message</spring>
>
> It should say this: -
>
> <spring>#{message}</spring>
>
>
> Regards,
> David Legg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by David Legg <da...@searchevent.co.uk>.
Hi Ken,
> It depends which way I do things, but I am still having
> problems with 'Your first Cocoon 2.2 Application'
> because the Java Bean doesn't work.
>
> Can anyone explain this behaviour, in terms that a
> non-java-speaker might understand?
I think the problem is that the
'src/main/resources/COB-INF/demo/spring-bean.jx.xml' file contains an
old version of the JX syntax for getting hold of a javabean's property.
Try editing the file so that instead of: -
<spring>#message</spring>
It should say this: -
<spring>#{message}</spring>
Regards,
David Legg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by David Legg <da...@searchevent.co.uk>.
> Anyone else see this too? I've tried both approaches and have the same results.
>
Yes I see it too. I haven't looked too closely at the cause yet.
David Legg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by Ken Starks <ke...@lampsacos.demon.co.uk>.
I'm pretty sure the artifacts are not different, having done a 'compare'
of the POMs in eclipse.
I don't know what an OSGi is, can you tell me how to check whether i
have one?
Jeff Caldwell wrote:
> Anyone else see this too? I've tried both approaches and have the same results.
>
> The only thing I can think is that there is not an OSGi running when we start jetty
> with "mvn jetty:run". Or perhaps the artifacts are actually different when running
> from command line as opposed to running via the eclipse plug-in for maven?
>
> On Tue, Jul 15, 2008 at 09:25:56PM +0100, Ken Starks wrote:
>
>> It depends which way I do things, but I am still having
>> problems with 'Your first Cocoon 2.2 Application'
>> because the Java Bean doesn't work.
>>
>> But while experimenting with the Eclipse plugin
>> 'Maven Integration for Eclipse' as a way of
>> generating the block, I suddenly found that the
>> Java-Bean did work.
>>
>> Can anyone explain this behaviour, in terms that a
>> non-java-speaker might understand?
>>
>> +++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> Details:
>>
>> Method One: (don't work)
>> ++++++++++++++++++
>>
>> a. In the shell,
>> --------------
>> mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
>>
>> <snip the details, I chose an artifactId of myBlock1>
>>
>> cd myBlock1
>> mvn eclipse:eclipse
>> mvn jetty:run
>>
>> b. Browser
>> -----------
>> Going to http://localhost:8888/myBlock1/spring-bean,
>>
>> <spring>#message</spring>
>>
>>
>> Method two (do work!)
>> ++++++++++=+++++
>>
>> a. in Eclipse
>> ------------
>> (with 'Maven integration for eclipse' plugin
>> from update site:-
>> http://m2eclipse.sonatype.org/update-dev/ )
>>
>> Menubar --.New --> Maven --> Maven Project
>> --> NEXT
>>
>> un-check 'Use default Workspace location'
>> browse to your usual 'GettingStartedApp' directory
>> --> Next
>>
>> Nexus Indexer. select artifact Id:-
>> cocoon-22-archetype-block
>> --> Finish
>>
>> <snip, to fill in details. this time I chose 'myBlock2 >
>>
>>
>> Cocoon then creates and compiles the block
>>
>> b. In the shell,
>> --------------
>>
>>
>> cd myBlock2
>> mvn jetty:run
>>
>> c. Browser
>> -----------
>> Going to http://localhost:8888/myBlock2/spring-bean,
>>
>> <spring>This is a message coming from a Spring bean.</spring>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java bean puzzle. using ecliplse plugin or not.
Posted by Jeff Caldwell <jc...@pace2020.com>.
Anyone else see this too? I've tried both approaches and have the same results.
The only thing I can think is that there is not an OSGi running when we start jetty
with "mvn jetty:run". Or perhaps the artifacts are actually different when running
from command line as opposed to running via the eclipse plug-in for maven?
On Tue, Jul 15, 2008 at 09:25:56PM +0100, Ken Starks wrote:
> It depends which way I do things, but I am still having
> problems with 'Your first Cocoon 2.2 Application'
> because the Java Bean doesn't work.
>
> But while experimenting with the Eclipse plugin
> 'Maven Integration for Eclipse' as a way of
> generating the block, I suddenly found that the
> Java-Bean did work.
>
> Can anyone explain this behaviour, in terms that a
> non-java-speaker might understand?
>
> +++++++++++++++++++++++++++++++++++++++++++++++++
>
> Details:
>
> Method One: (don't work)
> ++++++++++++++++++
>
> a. In the shell,
> --------------
> mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
>
> <snip the details, I chose an artifactId of myBlock1>
>
> cd myBlock1
> mvn eclipse:eclipse
> mvn jetty:run
>
> b. Browser
> -----------
> Going to http://localhost:8888/myBlock1/spring-bean,
>
> <spring>#message</spring>
>
>
> Method two (do work!)
> ++++++++++=+++++
>
> a. in Eclipse
> ------------
> (with 'Maven integration for eclipse' plugin
> from update site:-
> http://m2eclipse.sonatype.org/update-dev/ )
>
> Menubar --.New --> Maven --> Maven Project
> --> NEXT
>
> un-check 'Use default Workspace location'
> browse to your usual 'GettingStartedApp' directory
> --> Next
>
> Nexus Indexer. select artifact Id:-
> cocoon-22-archetype-block
> --> Finish
>
> <snip, to fill in details. this time I chose 'myBlock2 >
>
>
> Cocoon then creates and compiles the block
>
> b. In the shell,
> --------------
>
>
> cd myBlock2
> mvn jetty:run
>
> c. Browser
> -----------
> Going to http://localhost:8888/myBlock2/spring-bean,
>
> <spring>This is a message coming from a Spring bean.</spring>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
Java bean puzzle. using ecliplse plugin or not.
Posted by Ken Starks <ke...@lampsacos.demon.co.uk>.
It depends which way I do things, but I am still having
problems with 'Your first Cocoon 2.2 Application'
because the Java Bean doesn't work.
But while experimenting with the Eclipse plugin
'Maven Integration for Eclipse' as a way of
generating the block, I suddenly found that the
Java-Bean did work.
Can anyone explain this behaviour, in terms that a
non-java-speaker might understand?
+++++++++++++++++++++++++++++++++++++++++++++++++
Details:
Method One: (don't work)
++++++++++++++++++
a. In the shell,
--------------
mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
<snip the details, I chose an artifactId of myBlock1>
cd myBlock1
mvn eclipse:eclipse
mvn jetty:run
b. Browser
-----------
Going to http://localhost:8888/myBlock1/spring-bean,
<spring>#message</spring>
Method two (do work!)
++++++++++=+++++
a. in Eclipse
------------
(with 'Maven integration for eclipse' plugin
from update site:-
http://m2eclipse.sonatype.org/update-dev/
)
Menubar --.New --> Maven --> Maven Project
--> NEXT
un-check 'Use default Workspace location'
browse to your usual 'GettingStartedApp' directory
--> Next
Nexus Indexer. select artifact Id:-
cocoon-22-archetype-block
--> Finish
<snip, to fill in details. this time I chose 'myBlock2 >
Cocoon then creates and compiles the block
b. In the shell,
--------------
cd myBlock2
mvn jetty:run
c. Browser
-----------
Going to http://localhost:8888/myBlock2/spring-bean,
<spring>This is a message coming from a Spring bean.</spring>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Apache commons-fileupload returns an empty list
Posted by Magnus Haraldsen Amundsen <Ma...@computas.com>.
We use basic HTML Forms and not Cforms.
________________________________
From: Barbara Slupik [mailto:barbara.slupik@ntlworld.com]
Sent: 15. juli 2008 14:38
To: users@cocoon.apache.org
Subject: Re: Apache commons-fileupload returns an empty list
I use CForms upload widget to upload files and it works fine.
Barbara
On 15 Jul, 2008, at 12:08 pm, Magnus Haraldsen Amundsen wrote:
Hi,
I want to use commons-fileupload to handle fileupload in my webapp. I've
followed the tutorial at http://commons.apache.org/fileupload/using.html
<http://commons.apache.org/fileupload/using.html> but line
List /* FileItem */ items =
upload.parseRequest(request.getCocoonRequest());
always gives me an empty list. items.size() == 0.
I suspect that this is because the HttpServletRequest is already parsed
somewhere within Cocoon. Is there a workaround for this problem?
-Magnus
IMPORTANT NOTICE: This message may contain confidential information. If
you have received this e-mail in error, do not use, copy or distribute
it. Do not open any attachments. Delete it immediately from your system
and notify the sender promptly by e-mail that you have done so. Thank
you.
IMPORTANT NOTICE:
This message may contain confidential information.
If you have received this e-mail in error, do not use, copy or
distribute it. Do not open any attachments. Delete it immediately from
your system and notify the sender promptly by e-mail that you
have done so. Thank you.
Re: Apache commons-fileupload returns an empty list
Posted by Barbara Slupik <ba...@ntlworld.com>.
I use CForms upload widget to upload files and it works fine.
Barbara
On 15 Jul, 2008, at 12:08 pm, Magnus Haraldsen Amundsen wrote:
> Hi,
>
> I want to use commons-fileupload to handle fileupload in my webapp.
> I’ve followed the tutorial at http://commons.apache.org/fileupload/
> using.html but line
>
> List /* FileItem */ items = upload.parseRequest
> (request.getCocoonRequest());
>
> always gives me an empty list. items.size() == 0.
>
> I suspect that this is because the HttpServletRequest is already
> parsed somewhere within Cocoon. Is there a workaround for this
> problem?
>
> -Magnus
>
>
>
> IMPORTANT NOTICE: This message may contain confidential
> information. If you have received this e-mail in error, do not use,
> copy or distribute it. Do not open any attachments. Delete it
> immediately from your system and notify the sender promptly by e-
> mail that you have done so. Thank you.
>