cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miten Mehta (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-4552) typical HTML form payload does not seem to work when HTML form is used
Date Thu, 11 Oct 2012 05:53:03 GMT

    [ https://issues.apache.org/jira/browse/CXF-4552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473857#comment-13473857
] 

Miten Mehta edited comment on CXF-4552 at 10/11/12 5:51 AM:
------------------------------------------------------------

I am unable to understand your comment.  could you elaborate with code snippets.
what is 'plain' multipart payload and form-data payload and whats the difference ? 
I am using HTML form with multipart/form-data encoding.  can you refer in reference to it
?

different parts with same name/id ? 
In HTML form to upload multiple files if I use same name/id is that incorrect ? 

 <INPUT id="files" type="file" name="files"><BR>
 <INPUT id="files" type="file" name="files"><BR>

I am hoping that for two files I can use above html in form and then I can grab the two as
list by @Multipart("files") List<Attachment>.

When single file is submitted meaning single file upload tag in html form as below
 <INPUT id="files" type="file" name="files"><BR>

the parameter should not be List then what should it be ?
@Multipart("files") Attachment files ?

The ticket shows fix versions 2.5.6 etc.  is it immediately available from the CXF download
link ? 2.5.2 is not being applied fix ? 

how can I refer to files changed in the releases for this ticket ? I was hoping to see some
link in ticket referring to change list committed in version control system.

                
      was (Author: imitenmehta):
    I am unable to understand your comment.  could you elaborate with code snippets.
what is 'plain' multipart payload and form-data payload and whats the difference ? 
I am using HTML form with multipart/form-data encoding.  can you refer in reference to it
?

different parts with same name/id ? 
In HTML form to upload multiple files if I use same name/id is that incorrect ? 

 <INPUT id="files" type="file" name="files"><BR>
 <INPUT id="files" type="file" name="files"><BR>

I am hoping that for two files I can use above html in form and then I can grab the two as
list by @Multipart("files") List<Attachment>.

When single file is submitted meaning single file upload tag in html form as below
 <INPUT id="files" type="file" name="files"><BR>

the parameter should not be List then what should it be ?
@Multipart("files") Attachment files ?

The ticket shows fix versions 2.5.6 etc.  is it immediately available from the CXF download
link ? 2.5.2 is not being applied fix ?

                  
> typical HTML form payload does not seem to work when HTML form is used
> ----------------------------------------------------------------------
>
>                 Key: CXF-4552
>                 URL: https://issues.apache.org/jira/browse/CXF-4552
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.5.2
>         Environment: mitenm@pinkydebian:~$ uname -a; java -version
> Linux pinkydebian 2.6.32-5-686 #1 SMP Sun May 6 04:01:19 UTC 2012 i686 GNU/Linux
> java version "1.7.0_04"
> Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
> Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode)
> mitenm@pinkydebian:~$
>            Reporter: Miten Mehta
>            Assignee: Sergey Beryozkin
>             Fix For: 2.5.6, 2.6.3, 2.7.1
>
>
> I am using HTML form below to upload files using jax-rs but the attachments parameter
is null.    
> The code and error are shown:
> form:
> <html>
> <head>
> <meta http-equiv="pragma" content="no-cache" />
> </head>
> <body> 
> <FORM action="/jax_rs_basic/cxf/files/upload"
>        enctype="multipart/form-data"
>        method="post">
>    <P>
>    What is your name? <INPUT type="text" name="submit-name"><BR>
>    What files are you sending? <INPUT id="files" type="file" name="files"><BR>
>    
>    <INPUT type="submit" value="Send"> <INPUT type="reset">
>  </FORM>
> </body>
> </html>
> code:
> package demo.jaxrs.server;
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.util.List;
> import javax.ws.rs.Consumes;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.Response;
> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
> import org.apache.cxf.message.Attachment;
> @Path("/files/")
> public class MultipartService {
> 	
> 	@Path("/upload")
> 	@Consumes("multipart/form-data")
> 	@Produces("text/html")
> 	@POST
> 	public Response addAttachments(@Multipart("submit-name") String submitName, 
> 			@Multipart("files") List<Attachment> files) {
> 		
> 		System.out.println(submitName);
> 		System.out.println(files);
> 		for(Attachment a:files) {
> 			System.out.println(a.getId());
> 			InputStream is;
> 			try {
> 				is = a.getDataHandler().getInputStream();
> 				BufferedReader r = new BufferedReader(new InputStreamReader(is));
> 				System.out.println(r.readLine());
> 			} catch (IOException e) {
> 				// TODO Auto-generated catch block
> 				e.printStackTrace();
> 			}
> 			
> 		}
> 		
> 		return Response.ok("<html><body>Files Saved</body></html>").type("text/html").build();
> 	}
> }
> beans.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>   xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd">
>   <!-- do not use import statements if CXFServlet init parameters link to this beans.xml
--> 
>   <import resource="classpath:META-INF/cxf/cxf.xml" />
>   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>   <bean id="MyInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
>   	
>   <jaxrs:server id="customerService" address="/">
>   <jaxrs:inInterceptors><ref bean="MyInterceptor"/></jaxrs:inInterceptors>
>     <jaxrs:serviceBeans>
>       <!--  ref bean="customerBean" /-->
>       <ref bean="filesBean" />
>     </jaxrs:serviceBeans>
>   </jaxrs:server>
>   <bean id="customerBean" class="demo.jaxrs.server.CustomerService" />
>   <bean id="filesBean" class="demo.jaxrs.server.MultipartService" />
> </beans>
> error log:
> 17:10:58 INFO  context.ContextLoader - Root WebApplicationContext: initialization completed
in 1422 ms
> 17:10:58 DEBUG support.DefaultListableBeanFactory - Returning cached instance of singleton
bean 'cxf'
> Oct 09, 2012 5:02:09 PM org.apache.cxf.interceptor.LoggingInInterceptor
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Address: http://pinkydebian:8080/jax_rs_basic/cxf/files/upload
> Encoding: ISO-8859-1
> Http-Method: POST
> Content-Type: multipart/form-data; boundary=---------------------------222852432428027
> Headers: {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8], accept-encoding=[gzip,
deflate], accept-language=[en-us,en;q=0.5], connection=[keep-alive], Content-Length=[469],
content-type=[multipart/form-data; boundary=---------------------------222852432428027], host=[pinkydebian:8080],
referer=[http://pinkydebian:8080/jax_rs_basic/multipart.html], user-agent=[Mozilla/5.0 (Windows
NT 6.1; rv:15.0) Gecko/20100101 Firefox/15.0.1]}
> Payload: -----------------------------222852432428027
> Content-Disposition: form-data; name="submit-name"
> Miten
> -----------------------------222852432428027
> Content-Disposition: form-data; name="files"; filename="kingfisher.txt"
> Content-Type: text/plain
> Service Temporarily Unavailable
> The server is temporarily unable to service your request due to maintenance downtime
or capacity problems. Please try again later.
> -----------------------------222852432428027--
> --------------------------------------
> Miten
> null
> Oct 09, 2012 5:02:09 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
> WARNING: Application {http://server.jaxrs.demo/}MultipartService has thrown exception,
unwinding now
> org.apache.cxf.interceptor.Fault
> 	at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 	at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
> 	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
> 	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
> 	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)
> 	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> 	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.NullPointerException
> 	at demo.jaxrs.server.MultipartService.addAttachments(MultipartService.java:30)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> 	... 34 more
> Oct 09, 2012 5:02:09 PM org.apache.cxf.phase.PhaseInterceptorChain unwind
> WARNING: Exception in handleFault on interceptor org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor@8dae83
> org.apache.cxf.interceptor.Fault
> 	at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 	at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
> 	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
> 	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
> 	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)
> 	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> 	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.NullPointerException
> 	at demo.jaxrs.server.MultipartService.addAttachments(MultipartService.java:30)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> 	... 34 more
> Oct 09, 2012 5:02:09 PM org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver
onMessage
> SEVERE: Error occurred during error handling, give up!
> org.apache.cxf.interceptor.Fault
> 	at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)
> 	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 	at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> 	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
> 	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
> 	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
> 	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
> 	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)
> 	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
> 	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> 	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
> Caused by: java.lang.NullPointerException
> 	at demo.jaxrs.server.MultipartService.addAttachments(MultipartService.java:30)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> 	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> 	... 34 more
> Regards,
> Miten
> imiten@yahoo.com

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message