You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Collard, David L (Dave)" <da...@alcatel-lucent.com> on 2011/07/20 18:32:16 UTC

JAXRS Multipart Form-Data requiring Content-ID

I am processing multipart form-data for file uploads using JAX-RS.
Using Apache CXF 2.4.1


The example addBookFilesForm shown here is not working as-is for me:
http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles

Has an example request here:
http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles

The second part of the form data is a multipart/mixed list of books.
The relevant snippet of the above request is:


        Cntent-Disposition: form-data; name="files"

        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786

This fails for me with

WARNING: No multipart with content id files found

If I add
      Content-Id:<files>

to the request, then it works fine.

Should it not use the name if the Content-ID is not specified?
Is there something I can do to not require this Content-Id and use the name?   It is not
in my interface spec so hope to avoid requiring it.


On another note, there is an error in the addBookJaxbJsonForm example, the request has

        Content-ID: <jaxbPart>

But the signature specifies "bookXML" not jaxbPart.



Thanks!



-- DC

Dave.Collard@alcatel-lucent.com




Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
Ok,

wget --header="Content-Type: multipart/form-data;
boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"
--post-file=~/work/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
http://localhost:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform

works fine. Dave, I'm wondering - is it RESTClient bug ?

thanks, Sergey

On Fri, Jul 22, 2011 at 4:49 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> I guess Attachment handker expects "\r\n" and we only have "\n" which
> is a perfect line sep on Unix but is not good enough on its own as a
> sep between HTTP headers and such...
> Wondering if it is just a copy & paste issue ?
> Cheers, Sergey
>
> On Fri, Jul 22, 2011 at 4:30 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
>> Hi David
>>
>> I'm not exactly where the problem is but basically if (in RESTClient)
>> I add the empty line after the boundary but just before
>> Content-Disposition (with name=files) then it works. I suspect
>> "\u000a" is interfering. What happens is that
>> "Content-Disposition" of this part has 'C' stripped off and
>> "ontent-Disposition" is saved as a header.
>>
>> I'm going to try with wget, can you try independently as well ? May be
>> using HttpClient (it works with CXF client) ?
>>
>> Cheers, Sergey
>>
>>
>>
>> On Thu, Jul 21, 2011 at 6:01 PM, Collard, David L (Dave)
>> <da...@alcatel-lucent.com> wrote:
>>>
>>> Hi Sergey,
>>>
>>> No, I am not using struts.
>>>
>>> I made a simpler standalone example.
>>>
>>> //------------------------------------------------------------------------------------------------
>>> package tests.cxf.multi;
>>>
>>> import java.util.List;
>>>
>>> import javax.ws.rs.Consumes;
>>> import javax.ws.rs.POST;
>>> import javax.ws.rs.Path;
>>>
>>> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
>>> import org.apache.log4j.Logger;
>>>
>>> @Path("/tests/cxf/books")
>>> public class MultipartBooks {
>>>      private static Logger log = Logger.getLogger(MultipartBooks.class);
>>>
>>>      public MultipartBooks() {}
>>>
>>>      @POST
>>>      @Path("jsonform")
>>>      @Consumes("multipart/form-data")
>>>      public void addBookJsonFromForm(Book b1) {
>>>            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + b1.getName() + ", id:" + b1.getId());
>>>      }
>>>
>>>      @POST
>>>      @Path("filesform")
>>>      @Consumes("multipart/form-data")
>>>      public void addBookFilesForm(
>>>                  @Multipart("owner") String name,
>>>                  @Multipart("files")     List<Book> books) {
>>>            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + ", count:" + books.size());
>>>            for (Book book : books) {
>>>                  log.debug("  Book " + book.getName());
>>>            }
>>>      }
>>>
>>> }
>>> //---------------------------------------------------------------------------------------
>>>
>>> I am using firefox REST Client to send the request.
>>>
>>> The saved request with NO content-id:
>>>
>>> {"requestUrl":"http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>>>
>>> Resulting log:
>>>
>>> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>>> INFO: Inbound Message
>>> ----------------------------
>>> ID: 11
>>> Address: http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
>>> Encoding: UTF-8
>>> Http-Method: POST
>>> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
>>> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Content-Disposition: form-data; name="owner"
>>> Content-Type: text/plain
>>>
>>> Larry
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Content-Disposition: form-data; name="files"
>>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>>
>>> --_Part_4_701508.1145579811786
>>> Content-Disposition: form-data; name="book1"
>>> Content-Type: application/json; charset=US-ASCII
>>> Content-Transfer-Encoding: 8bit
>>>
>>> {"Book":{"name":"CXF in Action - 1","id":123}}
>>> --_Part_4_701508.1145579811786
>>> Content-Disposition: form-data; name="book2"
>>> Content-Type: application/json; charset=US-ASCII
>>> Content-Transfer-Encoding: 8bit
>>>
>>> {"Book":{"name":"CXF in Action - 2","id":124}}
>>> --_Part_4_701508.1145579811786--
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>>> --------------------------------------
>>> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils getMultipart
>>> WARNING: No multipart with content id files found, request content type : multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
>>> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>>> WARNING: WebApplicationException has been caught : no cause is available
>>> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>>> INFO: Outbound Message
>>> ---------------------------
>>> ID: 11
>>> Response-Code: 404
>>> Content-Type: text/xml
>>> Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}
>>>
>>>
>>> The saved request with content-id:
>>>
>>> {"requestUrl":"http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000aContent-Id: <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>>>
>>> Resulting log:
>>>
>>> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>>> INFO: Inbound Message
>>> ----------------------------
>>> ID: 12
>>> Address: http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
>>> Encoding: UTF-8
>>> Http-Method: POST
>>> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
>>> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Content-Disposition: form-data; name="owner"
>>> Content-Type: text/plain
>>>
>>> Larry
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>> Content-Disposition: form-data; name="files"
>>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>> Content-Id: <files>
>>>
>>> --_Part_4_701508.1145579811786
>>> Content-Disposition: form-data; name="book1"
>>> Content-Type: application/json; charset=US-ASCII
>>> Content-Transfer-Encoding: 8bit
>>>
>>> {"Book":{"name":"CXF in Action - 1","id":123}}
>>> --_Part_4_701508.1145579811786
>>> Content-Disposition: form-data; name="book2"
>>> Content-Type: application/json; charset=US-ASCII
>>> Content-Transfer-Encoding: 8bit
>>>
>>> {"Book":{"name":"CXF in Action - 2","id":124}}
>>> --_Part_4_701508.1145579811786--
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>>> --------------------------------------
>>> DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, owner name:Larry
>>> , count:2
>>> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
>>> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
>>> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>>> INFO: Outbound Message
>>> ---------------------------
>>> ID: 12
>>> Response-Code: 204
>>> Content-Type: text/xml
>>> Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}
>>>
>>> I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.
>>>
>>> If you like, I can send you a war file, or eclipse project.   File sharing sites
>>> are blocked from here or I would put it to dropbox or similar.
>>>
>>> Thanks!
>>>
>>> -- Dave Collard
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>>> Sent: Wednesday, July 20, 2011 7:41 PM
>>> To: users@cxf.apache.org
>>> Subject: Re: JAXRS Multipart Form-Data requiring Content-ID
>>>
>>>
>>>
>>> Hi
>>>
>>>
>>>
>>> On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)
>>>
>>> <da...@alcatel-lucent.com> wrote:
>>>
>>>> I am processing multipart form-data for file uploads using JAX-RS.
>>>
>>>> Using Apache CXF 2.4.1
>>>
>>>>
>>>
>>>>
>>>
>>>> The example addBookFilesForm shown here is not working as-is for me:
>>>
>>>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles
>>>
>>>>
>>>
>>>> Has an example request here:
>>>
>>>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
>>>
>>>>
>>>
>>>> The second part of the form data is a multipart/mixed list of books.
>>>
>>>> The relevant snippet of the above request is:
>>>
>>>>
>>>
>>>>
>>>
>>>>        Cntent-Disposition: form-data; name="files"
>>>
>>>>
>>>
>>>>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>>
>>>>
>>>
>>>> This fails for me with
>>>
>>>>
>>>
>>>> WARNING: No multipart with content id files found
>>>
>>>>
>>>
>>>> If I add
>>>
>>>>      Content-Id:<files>
>>>
>>>>
>>>
>>>> to the request, then it works fine.
>>>
>>>>
>>>
>>>> Should it not use the name if the Content-ID is not specified?
>>>
>>>> Is there something I can do to not require this Content-Id and use the name?   It is not
>>>
>>>> in my interface spec so hope to avoid requiring it.
>>>
>>>>
>>>
>>> That is a bit strange given that I can see this test working for me,
>>>
>>> here is the trace:
>>>
>>>
>>>
>>> POST /bookstore/books/filesform HTTP/1.1
>>>
>>> Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>>
>>> User-Agent: Jakarta Commons-HttpClient/3.1
>>>
>>> Host: localhost:8081
>>>
>>> Content-Length: 759
>>>
>>>
>>>
>>>
>>>
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>>
>>> Content-Disposition: form-data; name="owner"
>>>
>>> Content-Type: text/plain
>>>
>>>
>>>
>>> Larry
>>>
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>>
>>> Content-Disposition: form-data; name="files"
>>>
>>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>>
>>>
>>>
>>> --_Part_4_701508.1145579811786
>>>
>>> Content-Disposition: form-data; name="book1"
>>>
>>> Content-Type: application/json; charset=US-ASCII
>>>
>>> Content-Transfer-Encoding: 8bit
>>>
>>>
>>>
>>> {"Book":{"name":"CXF in Action - 1","id":123}}
>>>
>>> --_Part_4_701508.1145579811786
>>>
>>> Content-Disposition: form-data; name="book2"
>>>
>>> Content-Type: application/json; charset=US-ASCII
>>>
>>> Content-Transfer-Encoding: 8bit
>>>
>>>
>>>
>>> {"Book":{"name":"CXF in Action - 2","id":124}}
>>>
>>> --_Part_4_701508.1145579811786--
>>>
>>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>>>
>>>
>>>
>>> and the output is OK.
>>>
>>> I also recall updating the code to check Content-Disposition if
>>>
>>> Content-Id is missing.
>>>
>>>
>>>
>>> Are you using Struts by any chance ? Here are some hints just in case:
>>>
>>>
>>>
>>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts
>>>
>>>
>>>
>>>>
>>>
>>>> On another note, there is an error in the addBookJaxbJsonForm example, the request has
>>>
>>>>
>>>
>>>>        Content-ID: <jaxbPart>
>>>
>>>>
>>>
>>>> But the signature specifies "bookXML" not jaxbPart.
>>>
>>>>
>>>
>>>>
>>>
>>> Fixed - should be propagated shortly
>>>
>>>
>>>
>>> thanks, Sergey
>>>
>>>>
>>>
>>>> Thanks!
>>>
>>>>
>>>
>>>>
>>>
>>>>
>>>
>>>> -- DC
>>>
>>>>
>>>
>>>> Dave.Collard@alcatel-lucent.com
>

Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
I guess Attachment handker expects "\r\n" and we only have "\n" which
is a perfect line sep on Unix but is not good enough on its own as a
sep between HTTP headers and such...
Wondering if it is just a copy & paste issue ?
Cheers, Sergey

On Fri, Jul 22, 2011 at 4:30 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi David
>
> I'm not exactly where the problem is but basically if (in RESTClient)
> I add the empty line after the boundary but just before
> Content-Disposition (with name=files) then it works. I suspect
> "\u000a" is interfering. What happens is that
> "Content-Disposition" of this part has 'C' stripped off and
> "ontent-Disposition" is saved as a header.
>
> I'm going to try with wget, can you try independently as well ? May be
> using HttpClient (it works with CXF client) ?
>
> Cheers, Sergey
>
>
>
> On Thu, Jul 21, 2011 at 6:01 PM, Collard, David L (Dave)
> <da...@alcatel-lucent.com> wrote:
>>
>> Hi Sergey,
>>
>> No, I am not using struts.
>>
>> I made a simpler standalone example.
>>
>> //------------------------------------------------------------------------------------------------
>> package tests.cxf.multi;
>>
>> import java.util.List;
>>
>> import javax.ws.rs.Consumes;
>> import javax.ws.rs.POST;
>> import javax.ws.rs.Path;
>>
>> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
>> import org.apache.log4j.Logger;
>>
>> @Path("/tests/cxf/books")
>> public class MultipartBooks {
>>      private static Logger log = Logger.getLogger(MultipartBooks.class);
>>
>>      public MultipartBooks() {}
>>
>>      @POST
>>      @Path("jsonform")
>>      @Consumes("multipart/form-data")
>>      public void addBookJsonFromForm(Book b1) {
>>            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + b1.getName() + ", id:" + b1.getId());
>>      }
>>
>>      @POST
>>      @Path("filesform")
>>      @Consumes("multipart/form-data")
>>      public void addBookFilesForm(
>>                  @Multipart("owner") String name,
>>                  @Multipart("files")     List<Book> books) {
>>            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + ", count:" + books.size());
>>            for (Book book : books) {
>>                  log.debug("  Book " + book.getName());
>>            }
>>      }
>>
>> }
>> //---------------------------------------------------------------------------------------
>>
>> I am using firefox REST Client to send the request.
>>
>> The saved request with NO content-id:
>>
>> {"requestUrl":"http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>>
>> Resulting log:
>>
>> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>> INFO: Inbound Message
>> ----------------------------
>> ID: 11
>> Address: http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
>> Encoding: UTF-8
>> Http-Method: POST
>> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
>> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Content-Disposition: form-data; name="owner"
>> Content-Type: text/plain
>>
>> Larry
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Content-Disposition: form-data; name="files"
>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>
>> --_Part_4_701508.1145579811786
>> Content-Disposition: form-data; name="book1"
>> Content-Type: application/json; charset=US-ASCII
>> Content-Transfer-Encoding: 8bit
>>
>> {"Book":{"name":"CXF in Action - 1","id":123}}
>> --_Part_4_701508.1145579811786
>> Content-Disposition: form-data; name="book2"
>> Content-Type: application/json; charset=US-ASCII
>> Content-Transfer-Encoding: 8bit
>>
>> {"Book":{"name":"CXF in Action - 2","id":124}}
>> --_Part_4_701508.1145579811786--
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>> --------------------------------------
>> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils getMultipart
>> WARNING: No multipart with content id files found, request content type : multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
>> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>> WARNING: WebApplicationException has been caught : no cause is available
>> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>> INFO: Outbound Message
>> ---------------------------
>> ID: 11
>> Response-Code: 404
>> Content-Type: text/xml
>> Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}
>>
>>
>> The saved request with content-id:
>>
>> {"requestUrl":"http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000aContent-Id: <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>>
>> Resulting log:
>>
>> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>> INFO: Inbound Message
>> ----------------------------
>> ID: 12
>> Address: http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
>> Encoding: UTF-8
>> Http-Method: POST
>> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
>> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Content-Disposition: form-data; name="owner"
>> Content-Type: text/plain
>>
>> Larry
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>> Content-Disposition: form-data; name="files"
>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>> Content-Id: <files>
>>
>> --_Part_4_701508.1145579811786
>> Content-Disposition: form-data; name="book1"
>> Content-Type: application/json; charset=US-ASCII
>> Content-Transfer-Encoding: 8bit
>>
>> {"Book":{"name":"CXF in Action - 1","id":123}}
>> --_Part_4_701508.1145579811786
>> Content-Disposition: form-data; name="book2"
>> Content-Type: application/json; charset=US-ASCII
>> Content-Transfer-Encoding: 8bit
>>
>> {"Book":{"name":"CXF in Action - 2","id":124}}
>> --_Part_4_701508.1145579811786--
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>> --------------------------------------
>> DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, owner name:Larry
>> , count:2
>> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
>> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
>> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
>> INFO: Outbound Message
>> ---------------------------
>> ID: 12
>> Response-Code: 204
>> Content-Type: text/xml
>> Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}
>>
>> I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.
>>
>> If you like, I can send you a war file, or eclipse project.   File sharing sites
>> are blocked from here or I would put it to dropbox or similar.
>>
>> Thanks!
>>
>> -- Dave Collard
>>
>>
>>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Wednesday, July 20, 2011 7:41 PM
>> To: users@cxf.apache.org
>> Subject: Re: JAXRS Multipart Form-Data requiring Content-ID
>>
>>
>>
>> Hi
>>
>>
>>
>> On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)
>>
>> <da...@alcatel-lucent.com> wrote:
>>
>>> I am processing multipart form-data for file uploads using JAX-RS.
>>
>>> Using Apache CXF 2.4.1
>>
>>>
>>
>>>
>>
>>> The example addBookFilesForm shown here is not working as-is for me:
>>
>>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles
>>
>>>
>>
>>> Has an example request here:
>>
>>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
>>
>>>
>>
>>> The second part of the form data is a multipart/mixed list of books.
>>
>>> The relevant snippet of the above request is:
>>
>>>
>>
>>>
>>
>>>        Cntent-Disposition: form-data; name="files"
>>
>>>
>>
>>>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>
>>>
>>
>>> This fails for me with
>>
>>>
>>
>>> WARNING: No multipart with content id files found
>>
>>>
>>
>>> If I add
>>
>>>      Content-Id:<files>
>>
>>>
>>
>>> to the request, then it works fine.
>>
>>>
>>
>>> Should it not use the name if the Content-ID is not specified?
>>
>>> Is there something I can do to not require this Content-Id and use the name?   It is not
>>
>>> in my interface spec so hope to avoid requiring it.
>>
>>>
>>
>> That is a bit strange given that I can see this test working for me,
>>
>> here is the trace:
>>
>>
>>
>> POST /bookstore/books/filesform HTTP/1.1
>>
>> Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>
>> User-Agent: Jakarta Commons-HttpClient/3.1
>>
>> Host: localhost:8081
>>
>> Content-Length: 759
>>
>>
>>
>>
>>
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>
>> Content-Disposition: form-data; name="owner"
>>
>> Content-Type: text/plain
>>
>>
>>
>> Larry
>>
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>>
>> Content-Disposition: form-data; name="files"
>>
>> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>
>>
>>
>> --_Part_4_701508.1145579811786
>>
>> Content-Disposition: form-data; name="book1"
>>
>> Content-Type: application/json; charset=US-ASCII
>>
>> Content-Transfer-Encoding: 8bit
>>
>>
>>
>> {"Book":{"name":"CXF in Action - 1","id":123}}
>>
>> --_Part_4_701508.1145579811786
>>
>> Content-Disposition: form-data; name="book2"
>>
>> Content-Type: application/json; charset=US-ASCII
>>
>> Content-Transfer-Encoding: 8bit
>>
>>
>>
>> {"Book":{"name":"CXF in Action - 2","id":124}}
>>
>> --_Part_4_701508.1145579811786--
>>
>> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>>
>>
>>
>> and the output is OK.
>>
>> I also recall updating the code to check Content-Disposition if
>>
>> Content-Id is missing.
>>
>>
>>
>> Are you using Struts by any chance ? Here are some hints just in case:
>>
>>
>>
>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts
>>
>>
>>
>>>
>>
>>> On another note, there is an error in the addBookJaxbJsonForm example, the request has
>>
>>>
>>
>>>        Content-ID: <jaxbPart>
>>
>>>
>>
>>> But the signature specifies "bookXML" not jaxbPart.
>>
>>>
>>
>>>
>>
>> Fixed - should be propagated shortly
>>
>>
>>
>> thanks, Sergey
>>
>>>
>>
>>> Thanks!
>>
>>>
>>
>>>
>>
>>>
>>
>>> -- DC
>>
>>>
>>
>>> Dave.Collard@alcatel-lucent.com
>>
>>>
>>
>>>
>>
>>>
>>
>>>
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>> Sergey Beryozkin
>>
>>
>>
>> http://sberyozkin.blogspot.com
>>
>> Talend - http://www.talend.com
>>
>
>
>
> --
> Sergey Beryozkin
>
> http://sberyozkin.blogspot.com
> Talend - http://www.talend.com
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com

Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi David

I'm not exactly where the problem is but basically if (in RESTClient)
I add the empty line after the boundary but just before
Content-Disposition (with name=files) then it works. I suspect
"\u000a" is interfering. What happens is that
"Content-Disposition" of this part has 'C' stripped off and
"ontent-Disposition" is saved as a header.

I'm going to try with wget, can you try independently as well ? May be
using HttpClient (it works with CXF client) ?

Cheers, Sergey



On Thu, Jul 21, 2011 at 6:01 PM, Collard, David L (Dave)
<da...@alcatel-lucent.com> wrote:
>
> Hi Sergey,
>
> No, I am not using struts.
>
> I made a simpler standalone example.
>
> //------------------------------------------------------------------------------------------------
> package tests.cxf.multi;
>
> import java.util.List;
>
> import javax.ws.rs.Consumes;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
>
> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
> import org.apache.log4j.Logger;
>
> @Path("/tests/cxf/books")
> public class MultipartBooks {
>      private static Logger log = Logger.getLogger(MultipartBooks.class);
>
>      public MultipartBooks() {}
>
>      @POST
>      @Path("jsonform")
>      @Consumes("multipart/form-data")
>      public void addBookJsonFromForm(Book b1) {
>            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + b1.getName() + ", id:" + b1.getId());
>      }
>
>      @POST
>      @Path("filesform")
>      @Consumes("multipart/form-data")
>      public void addBookFilesForm(
>                  @Multipart("owner") String name,
>                  @Multipart("files")     List<Book> books) {
>            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + ", count:" + books.size());
>            for (Book book : books) {
>                  log.debug("  Book " + book.getName());
>            }
>      }
>
> }
> //---------------------------------------------------------------------------------------
>
> I am using firefox REST Client to send the request.
>
> The saved request with NO content-id:
>
> {"requestUrl":"http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 11
> Address: http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils getMultipart
> WARNING: No multipart with content id files found, request content type : multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 11
> Response-Code: 404
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}
>
>
> The saved request with content-id:
>
> {"requestUrl":"http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000aContent-Id: <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 12
> Address: http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
> Content-Id: <files>
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, owner name:Larry
> , count:2
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 12
> Response-Code: 204
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}
>
> I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.
>
> If you like, I can send you a war file, or eclipse project.   File sharing sites
> are blocked from here or I would put it to dropbox or similar.
>
> Thanks!
>
> -- Dave Collard
>
>
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Wednesday, July 20, 2011 7:41 PM
> To: users@cxf.apache.org
> Subject: Re: JAXRS Multipart Form-Data requiring Content-ID
>
>
>
> Hi
>
>
>
> On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)
>
> <da...@alcatel-lucent.com> wrote:
>
>> I am processing multipart form-data for file uploads using JAX-RS.
>
>> Using Apache CXF 2.4.1
>
>>
>
>>
>
>> The example addBookFilesForm shown here is not working as-is for me:
>
>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles
>
>>
>
>> Has an example request here:
>
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
>
>>
>
>> The second part of the form data is a multipart/mixed list of books.
>
>> The relevant snippet of the above request is:
>
>>
>
>>
>
>>        Cntent-Disposition: form-data; name="files"
>
>>
>
>>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
>>
>
>> This fails for me with
>
>>
>
>> WARNING: No multipart with content id files found
>
>>
>
>> If I add
>
>>      Content-Id:<files>
>
>>
>
>> to the request, then it works fine.
>
>>
>
>> Should it not use the name if the Content-ID is not specified?
>
>> Is there something I can do to not require this Content-Id and use the name?   It is not
>
>> in my interface spec so hope to avoid requiring it.
>
>>
>
> That is a bit strange given that I can see this test working for me,
>
> here is the trace:
>
>
>
> POST /bookstore/books/filesform HTTP/1.1
>
> Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>
> User-Agent: Jakarta Commons-HttpClient/3.1
>
> Host: localhost:8081
>
> Content-Length: 759
>
>
>
>
>
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>
> Content-Disposition: form-data; name="owner"
>
> Content-Type: text/plain
>
>
>
> Larry
>
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
>
> Content-Disposition: form-data; name="files"
>
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
>
>
> --_Part_4_701508.1145579811786
>
> Content-Disposition: form-data; name="book1"
>
> Content-Type: application/json; charset=US-ASCII
>
> Content-Transfer-Encoding: 8bit
>
>
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
>
> --_Part_4_701508.1145579811786
>
> Content-Disposition: form-data; name="book2"
>
> Content-Type: application/json; charset=US-ASCII
>
> Content-Transfer-Encoding: 8bit
>
>
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
>
> --_Part_4_701508.1145579811786--
>
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>
>
>
> and the output is OK.
>
> I also recall updating the code to check Content-Disposition if
>
> Content-Id is missing.
>
>
>
> Are you using Struts by any chance ? Here are some hints just in case:
>
>
>
> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts
>
>
>
>>
>
>> On another note, there is an error in the addBookJaxbJsonForm example, the request has
>
>>
>
>>        Content-ID: <jaxbPart>
>
>>
>
>> But the signature specifies "bookXML" not jaxbPart.
>
>>
>
>>
>
> Fixed - should be propagated shortly
>
>
>
> thanks, Sergey
>
>>
>
>> Thanks!
>
>>
>
>>
>
>>
>
>> -- DC
>
>>
>
>> Dave.Collard@alcatel-lucent.com
>
>>
>
>>
>
>>
>
>>
>
>
>
>
>
>
>
> --
>
> Sergey Beryozkin
>
>
>
> http://sberyozkin.blogspot.com
>
> Talend - http://www.talend.com
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com

Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
> thanks for the above analysis, I'm not sure why I'm not seeing the
> same issue - I guess I could try
> Tomcat 7.0.14 as well and/or RESTClient (just installed). Can I paste
> the request fragment above as is in RESTClient ?
> If you could send me a war with only MultipartBooks.class (I'll add
> cxf distro libs myself) then it will help me to test quickly

plus web.xml & beans.xml (if used)

thanks
>
> Cheers, Sergey
>
>> Thanks!
>>
>> -- Dave Collard
>>
>

Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Dave

On Thu, Jul 21, 2011 at 6:01 PM, Collard, David L (Dave)
<da...@alcatel-lucent.com> wrote:
>
> Hi Sergey,
>
> No, I am not using struts.
>
> I made a simpler standalone example.
>
> //------------------------------------------------------------------------------------------------
> package tests.cxf.multi;
>
> import java.util.List;
>
> import javax.ws.rs.Consumes;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
>
> import org.apache.cxf.jaxrs.ext.multipart.Multipart;
> import org.apache.log4j.Logger;
>
> @Path("/tests/cxf/books")
> public class MultipartBooks {
>      private static Logger log = Logger.getLogger(MultipartBooks.class);
>
>      public MultipartBooks() {}
>
>      @POST
>      @Path("jsonform")
>      @Consumes("multipart/form-data")
>      public void addBookJsonFromForm(Book b1) {
>            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + b1.getName() + ", id:" + b1.getId());
>      }
>
>      @POST
>      @Path("filesform")
>      @Consumes("multipart/form-data")
>      public void addBookFilesForm(
>                  @Multipart("owner") String name,
>                  @Multipart("files")     List<Book> books) {
>            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + ", count:" + books.size());
>            for (Book book : books) {
>                  log.debug("  Book " + book.getName());
>            }
>      }
>
> }
> //---------------------------------------------------------------------------------------
>
> I am using firefox REST Client to send the request.
>
> The saved request with NO content-id:
>
> {"requestUrl":"http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 11
> Address: http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils getMultipart
> WARNING: No multipart with content id files found, request content type : multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
> Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
> Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 11
> Response-Code: 404
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}
>
>
> The saved request with content-id:
>
> {"requestUrl":"http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000aContent-Id: <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}
>
> Resulting log:
>
> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Inbound Message
> ----------------------------
> ID: 12
> Address: http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
> Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
> Content-Id: <files>
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
 Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
> --------------------------------------
> DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, owner name:Larry
> , count:2
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
> DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
> Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
> INFO: Outbound Message
> ---------------------------
> ID: 12
> Response-Code: 204
> Content-Type: text/xml
> Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}
>
> I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.
>
> If you like, I can send you a war file, or eclipse project.   File sharing sites
> are blocked from here or I would put it to dropbox or similar.
>
thanks for the above analysis, I'm not sure why I'm not seeing the
same issue - I guess I could try
Tomcat 7.0.14 as well and/or RESTClient (just installed). Can I paste
the request fragment above as is in RESTClient ?
If you could send me a war with only MultipartBooks.class (I'll add
cxf distro libs myself) then it will help me to test quickly

Cheers, Sergey

> Thanks!
>
> -- Dave Collard
>

RE: JAXRS Multipart Form-Data requiring Content-ID

Posted by "Collard, David L (Dave)" <da...@alcatel-lucent.com>.
Hi Sergey,

No, I am not using struts.

I made a simpler standalone example.

//------------------------------------------------------------------------------------------------
package tests.cxf.multi;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.apache.log4j.Logger;

@Path("/tests/cxf/books")
public class MultipartBooks {
      private static Logger log = Logger.getLogger(MultipartBooks.class);

      public MultipartBooks() {}

      @POST
      @Path("jsonform")
      @Consumes("multipart/form-data")
      public void addBookJsonFromForm(Book b1) {
            log.debug("MULTIPARTBOOKS: addBookJsonFromForm, Book:" + b1.getName() + ", id:" + b1.getId());
      }

      @POST
      @Path("filesform")
      @Consumes("multipart/form-data")
      public void addBookFilesForm(
                  @Multipart("owner") String name,
                  @Multipart("files")     List<Book> books) {
            log.debug("MULTIPARTBOOKS: addBookFilesForm, owner name:" + name + ", count:" + books.size());
            for (Book book : books) {
                  log.debug("  Book " + book.getName());
            }
      }

}
//---------------------------------------------------------------------------------------

I am using firefox REST Client to send the request.

The saved request with NO content-id:

{"requestUrl":"http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}

Resulting log:

Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
INFO: Inbound Message
----------------------------
ID: 11
Address: http://<IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[735], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="owner"
Content-Type: text/plain

Larry
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786

--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book1"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 1","id":123}}
--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book2"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 2","id":124}}
--_Part_4_701508.1145579811786--
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
--------------------------------------
Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils getMultipart
WARNING: No multipart with content id files found, request content type : multipart/form-data;boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB;charset=UTF-8
Jul 21, 2011 12:31:07 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available
Jul 21, 2011 12:31:07 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
INFO: Outbound Message
---------------------------
ID: 11
Response-Code: 404
Content-Type: text/xml
Headers: {Date=[Thu, 21 Jul 2011 16:31:07 GMT]}


The saved request with content-id:

{"requestUrl":"http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform","requestMethod":"POST","requestBody":"--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"owner\"\u000aContent-Type: text/plain\u000a\u000aLarry\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB\u000aContent-Disposition: form-data; name=\"files\"\u000aContent-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786\u000aContent-Id: <files>\u000a\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book1\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 1\",\"id\":123}}\u000a--_Part_4_701508.1145579811786\u000aContent-Disposition: form-data; name=\"book2\"\u000aContent-Type: application/json; charset=US-ASCII\u000aContent-Transfer-Encoding: 8bit\u000a\u000a{\"Book\":{\"name\":\"CXF in Action - 2\",\"id\":124}}\u000a--_Part_4_701508.1145579811786--\u000a--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--","headers":["Content-Type","multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB"]}

Resulting log:

Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
INFO: Inbound Message
----------------------------
ID: 12
Address: http:// <IP ADDRESS>:8080/multi-1.0-SNAPSHOT/services/tests/cxf/books/filesform
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Headers: {Accept=[audio/x-wav,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], accept-encoding=[gzip, deflate], cache-control=[no-cache], connection=[keep-alive], Content-Length=[755], content-type=[multipart/form-data; charset=UTF-8; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB], cookie=[JSESSIONID=58E6D8C6B7C8CC2812E3F19CE3CEE892], host=[<IP ADDRESS>:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1]}
Payload: --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="owner"
Content-Type: text/plain

Larry
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
Content-Id: <files>

--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book1"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 1","id":123}}
--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book2"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 2","id":124}}
--_Part_4_701508.1145579811786--
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
--------------------------------------
DEBUG MultipartBooks                 [31] - MULTIPARTBOOKS: addBookFilesForm, owner name:Larry
, count:2
DEBUG MultipartBooks                 [33] -   Book CXF in Action - 1
DEBUG MultipartBooks                 [33] -   Book CXF in Action - 2
Jul 21, 2011 12:32:05 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
INFO: Outbound Message
---------------------------
ID: 12
Response-Code: 204
Content-Type: text/xml
Headers: {Date=[Thu, 21 Jul 2011 16:32:05 GMT]}

I am using tomcat 7.0.14, CXF 2.4.1, linux red hat Enterprise Server5.5.

If you like, I can send you a war file, or eclipse project.   File sharing sites
are blocked from here or I would put it to dropbox or similar.

Thanks!

-- Dave Collard



-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Sent: Wednesday, July 20, 2011 7:41 PM
To: users@cxf.apache.org
Subject: Re: JAXRS Multipart Form-Data requiring Content-ID



Hi



On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)

<da...@alcatel-lucent.com> wrote:

> I am processing multipart form-data for file uploads using JAX-RS.

> Using Apache CXF 2.4.1

>

>

> The example addBookFilesForm shown here is not working as-is for me:

> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles

>

> Has an example request here:

> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles

>

> The second part of the form data is a multipart/mixed list of books.

> The relevant snippet of the above request is:

>

>

>        Cntent-Disposition: form-data; name="files"

>

>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786

>

> This fails for me with

>

> WARNING: No multipart with content id files found

>

> If I add

>      Content-Id:<files>

>

> to the request, then it works fine.

>

> Should it not use the name if the Content-ID is not specified?

> Is there something I can do to not require this Content-Id and use the name?   It is not

> in my interface spec so hope to avoid requiring it.

>

That is a bit strange given that I can see this test working for me,

here is the trace:



POST /bookstore/books/filesform HTTP/1.1

Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB

User-Agent: Jakarta Commons-HttpClient/3.1

Host: localhost:8081

Content-Length: 759





--bqJky99mlBWa-ZuqjC53mG6EzbmlxB

Content-Disposition: form-data; name="owner"

Content-Type: text/plain



Larry

--bqJky99mlBWa-ZuqjC53mG6EzbmlxB

Content-Disposition: form-data; name="files"

Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786



--_Part_4_701508.1145579811786

Content-Disposition: form-data; name="book1"

Content-Type: application/json; charset=US-ASCII

Content-Transfer-Encoding: 8bit



{"Book":{"name":"CXF in Action - 1","id":123}}

--_Part_4_701508.1145579811786

Content-Disposition: form-data; name="book2"

Content-Type: application/json; charset=US-ASCII

Content-Transfer-Encoding: 8bit



{"Book":{"name":"CXF in Action - 2","id":124}}

--_Part_4_701508.1145579811786--

--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--



and the output is OK.

I also recall updating the code to check Content-Disposition if

Content-Id is missing.



Are you using Struts by any chance ? Here are some hints just in case:



http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts



>

> On another note, there is an error in the addBookJaxbJsonForm example, the request has

>

>        Content-ID: <jaxbPart>

>

> But the signature specifies "bookXML" not jaxbPart.

>

>

Fixed - should be propagated shortly



thanks, Sergey

>

> Thanks!

>

>

>

> -- DC

>

> Dave.Collard@alcatel-lucent.com

>

>

>

>







--

Sergey Beryozkin



http://sberyozkin.blogspot.com

Talend - http://www.talend.com

RE: CXF 2.5.1 problem with httpj:threadingParameters

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi Dan,
Great, thanks for fixing this and for the comment about the default.  I think my own usage will not exceed 254.

Thanks,
Jesse

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Tuesday, January 03, 2012 6:56 PM
To: users@cxf.apache.org
Cc: Jesse Pangburn
Subject: Re: CXF 2.5.1 problem with httpj:threadingParameters


OK.  Was able to reproduce this with one of the samples.   Looks like the 
threadpool is not being set in both places where it's needed.   Kind of a 
funny thing in the Jetty API's, but easily worked around/fixed.  Fix 
committed.

That said, the default with Jetty 7.5 is max 254 threads and 8 min threads.   
Thus, your settings might not really be needed.

Dan



On Tuesday, January 03, 2012 4:32:30 PM Jesse Pangburn wrote:
> Hi Dan,
> I replaced that whole portion of the classpath with a reference to the
> 2.5.1's cxf-manifest.jar which does specify Jetty 7.5.  For instance:
> jetty-server-7.5.3.v20111011.jar
> 
> So this is the jetty jar I'm using.  From your email it sounds like you
> thought I was using CXF 2.5.1 with Jetty 7.4 from CXF 2.4.2, which isn't
> the case.  So I think you were asking me to replace the 7.4 jars with 7.5.
> 
> Attaching the debugger with/without specifying the threading parameters
> shows that there's some thread missing when you specify the threading
> parameters.  Without specifying I see six of these "Thread [qtp20935029-16]
> (Running)", one of these "Thread [qtp20935029-15 Acceptor0
> SelectChannelConnector@0.0.0.0:9003 STARTING] (Running)", and one of these
> "Thread [qtp20935029-14 Selector0] (Running)".  When specifying the
> threading parameters (which causes the problem), then there's 13 of the
> common ones (I specified min=6 max=16) but no "Selector0" thread.
> 
> Anything else I should try?  I thought of trying to put the 7.4 jetty jars
> back in but figured that would cause other problems.
> 
> Thanks,
> Jesse
> 
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Tuesday, January 03, 2012 2:21 PM
> To: users@cxf.apache.org
> Cc: Jesse Pangburn
> Subject: Re: CXF 2.5.1 problem with httpj:threadingParameters
> 
> On Thursday, December 29, 2011 1:47:16 PM Jesse Pangburn wrote:
> > Hi,
> > I have the following portion of a Spring configuration file that I was
> > using with CXF 2.4.2: <httpj:engine-factory >
> > 
> > 		<httpj:engine port="9003" >
> > 		
> > 			<httpj:threadingParameters minThreads="6"
> > 			
> > 				maxThreads="16" />
> > 		
> > 		</httpj:engine>
> > 	
> > 	</httpj:engine-factory>
> > 
> > There is a corresponding jaxws:endpoint that listens to a url on port
> > 9003. When I updated to CXF 2.5.1, the server was acting like it never
> > received the message yet "netstat -an | grep 9003" shows the port open
> > and "telnet localhost 9003" connects.  I changed nothing else but the
> > CXF version by replacing my classpath with the cxf-manifest.jar from
> > 2.5.1.
> 
> Can you also try replacing the Jetty jars?   We did upgrade to Jetty 7.5.x
> (from 7.4.x) which required some changes.  We tried to make sure the code
> would still work with 7.4.x, but we may have missed something.   I'd like to
> at least check to see if it works with the Jetty we test with for 2.5.1.
> > A little testing showed that it's the httpj:threadingParameters at
> > fault.
> > If I remove it then the server gets connections on port 9003 just fine:
> > <httpj:engine-factory >
> > 
> > 		<httpj:engine port="9003" >
> > 		</httpj:engine>
> > 	
> > 	</httpj:engine-factory>
> > 
> > Anyone else run into this or have an idea?  Being able to set the
> > maxThreads over the default of 15 is a useful thing so hopefully this
> > can be made to work.
> 
> Actually, with Jetty 7.5, I think the default is a LOT higher.      Might
> not need it.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com



Re: CXF 2.5.1 problem with httpj:threadingParameters

Posted by Daniel Kulp <dk...@apache.org>.
OK.  Was able to reproduce this with one of the samples.   Looks like the 
threadpool is not being set in both places where it's needed.   Kind of a 
funny thing in the Jetty API's, but easily worked around/fixed.  Fix 
committed.

That said, the default with Jetty 7.5 is max 254 threads and 8 min threads.   
Thus, your settings might not really be needed.

Dan



On Tuesday, January 03, 2012 4:32:30 PM Jesse Pangburn wrote:
> Hi Dan,
> I replaced that whole portion of the classpath with a reference to the
> 2.5.1's cxf-manifest.jar which does specify Jetty 7.5.  For instance:
> jetty-server-7.5.3.v20111011.jar
> 
> So this is the jetty jar I'm using.  From your email it sounds like you
> thought I was using CXF 2.5.1 with Jetty 7.4 from CXF 2.4.2, which isn't
> the case.  So I think you were asking me to replace the 7.4 jars with 7.5.
> 
> Attaching the debugger with/without specifying the threading parameters
> shows that there's some thread missing when you specify the threading
> parameters.  Without specifying I see six of these "Thread [qtp20935029-16]
> (Running)", one of these "Thread [qtp20935029-15 Acceptor0
> SelectChannelConnector@0.0.0.0:9003 STARTING] (Running)", and one of these
> "Thread [qtp20935029-14 Selector0] (Running)".  When specifying the
> threading parameters (which causes the problem), then there's 13 of the
> common ones (I specified min=6 max=16) but no "Selector0" thread.
> 
> Anything else I should try?  I thought of trying to put the 7.4 jetty jars
> back in but figured that would cause other problems.
> 
> Thanks,
> Jesse
> 
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Tuesday, January 03, 2012 2:21 PM
> To: users@cxf.apache.org
> Cc: Jesse Pangburn
> Subject: Re: CXF 2.5.1 problem with httpj:threadingParameters
> 
> On Thursday, December 29, 2011 1:47:16 PM Jesse Pangburn wrote:
> > Hi,
> > I have the following portion of a Spring configuration file that I was
> > using with CXF 2.4.2: <httpj:engine-factory >
> > 
> > 		<httpj:engine port="9003" >
> > 		
> > 			<httpj:threadingParameters minThreads="6"
> > 			
> > 				maxThreads="16" />
> > 		
> > 		</httpj:engine>
> > 	
> > 	</httpj:engine-factory>
> > 
> > There is a corresponding jaxws:endpoint that listens to a url on port
> > 9003. When I updated to CXF 2.5.1, the server was acting like it never
> > received the message yet "netstat -an | grep 9003" shows the port open
> > and "telnet localhost 9003" connects.  I changed nothing else but the
> > CXF version by replacing my classpath with the cxf-manifest.jar from
> > 2.5.1.
> 
> Can you also try replacing the Jetty jars?   We did upgrade to Jetty 7.5.x
> (from 7.4.x) which required some changes.  We tried to make sure the code
> would still work with 7.4.x, but we may have missed something.   I'd like to
> at least check to see if it works with the Jetty we test with for 2.5.1.
> > A little testing showed that it's the httpj:threadingParameters at
> > fault.
> > If I remove it then the server gets connections on port 9003 just fine:
> > <httpj:engine-factory >
> > 
> > 		<httpj:engine port="9003" >
> > 		</httpj:engine>
> > 	
> > 	</httpj:engine-factory>
> > 
> > Anyone else run into this or have an idea?  Being able to set the
> > maxThreads over the default of 15 is a useful thing so hopefully this
> > can be made to work.
> 
> Actually, with Jetty 7.5, I think the default is a LOT higher.      Might
> not need it.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

RE: CXF 2.5.1 problem with httpj:threadingParameters

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi Dan,
I replaced that whole portion of the classpath with a reference to the 2.5.1's cxf-manifest.jar which does specify Jetty 7.5.  For instance:
jetty-server-7.5.3.v20111011.jar

So this is the jetty jar I'm using.  From your email it sounds like you thought I was using CXF 2.5.1 with Jetty 7.4 from CXF 2.4.2, which isn't the case.  So I think you were asking me to replace the 7.4 jars with 7.5.

Attaching the debugger with/without specifying the threading parameters shows that there's some thread missing when you specify the threading parameters.  Without specifying I see six of these "Thread [qtp20935029-16] (Running)", one of these "Thread [qtp20935029-15 Acceptor0 SelectChannelConnector@0.0.0.0:9003 STARTING] (Running)", and one of these "Thread [qtp20935029-14 Selector0] (Running)".  When specifying the threading parameters (which causes the problem), then there's 13 of the common ones (I specified min=6 max=16) but no "Selector0" thread.

Anything else I should try?  I thought of trying to put the 7.4 jetty jars back in but figured that would cause other problems.

Thanks,
Jesse

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Tuesday, January 03, 2012 2:21 PM
To: users@cxf.apache.org
Cc: Jesse Pangburn
Subject: Re: CXF 2.5.1 problem with httpj:threadingParameters

On Thursday, December 29, 2011 1:47:16 PM Jesse Pangburn wrote:
> Hi,
> I have the following portion of a Spring configuration file that I was using
> with CXF 2.4.2: <httpj:engine-factory >
> 		<httpj:engine port="9003" >
> 			<httpj:threadingParameters minThreads="6"
> 				maxThreads="16" />
> 		</httpj:engine>
> 	</httpj:engine-factory>
> 
> There is a corresponding jaxws:endpoint that listens to a url on port 9003. 
> When I updated to CXF 2.5.1, the server was acting like it never received
> the message yet "netstat -an | grep 9003" shows the port open and "telnet
> localhost 9003" connects.  I changed nothing else but the CXF version by
> replacing my classpath with the cxf-manifest.jar from 2.5.1.

Can you also try replacing the Jetty jars?   We did upgrade to Jetty 7.5.x 
(from 7.4.x) which required some changes.  We tried to make sure the code 
would still work with 7.4.x, but we may have missed something.   I'd like to 
at least check to see if it works with the Jetty we test with for 2.5.1.


> A little testing showed that it's the httpj:threadingParameters at fault. 
> If I remove it then the server gets connections on port 9003 just fine:
> <httpj:engine-factory >
> 		<httpj:engine port="9003" >
> 		</httpj:engine>
> 	</httpj:engine-factory>
> 
> Anyone else run into this or have an idea?  Being able to set the maxThreads
> over the default of 15 is a useful thing so hopefully this can be made to
> work.

Actually, with Jetty 7.5, I think the default is a LOT higher.      Might not 
need it.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com



Re: CXF 2.5.1 problem with httpj:threadingParameters

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday, December 29, 2011 1:47:16 PM Jesse Pangburn wrote:
> Hi,
> I have the following portion of a Spring configuration file that I was using
> with CXF 2.4.2: <httpj:engine-factory >
> 		<httpj:engine port="9003" >
> 			<httpj:threadingParameters minThreads="6"
> 				maxThreads="16" />
> 		</httpj:engine>
> 	</httpj:engine-factory>
> 
> There is a corresponding jaxws:endpoint that listens to a url on port 9003. 
> When I updated to CXF 2.5.1, the server was acting like it never received
> the message yet "netstat -an | grep 9003" shows the port open and "telnet
> localhost 9003" connects.  I changed nothing else but the CXF version by
> replacing my classpath with the cxf-manifest.jar from 2.5.1.

Can you also try replacing the Jetty jars?   We did upgrade to Jetty 7.5.x 
(from 7.4.x) which required some changes.  We tried to make sure the code 
would still work with 7.4.x, but we may have missed something.   I'd like to 
at least check to see if it works with the Jetty we test with for 2.5.1.


> A little testing showed that it's the httpj:threadingParameters at fault. 
> If I remove it then the server gets connections on port 9003 just fine:
> <httpj:engine-factory >
> 		<httpj:engine port="9003" >
> 		</httpj:engine>
> 	</httpj:engine-factory>
> 
> Anyone else run into this or have an idea?  Being able to set the maxThreads
> over the default of 15 is a useful thing so hopefully this can be made to
> work.

Actually, with Jetty 7.5, I think the default is a LOT higher.      Might not 
need it.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

CXF 2.5.1 problem with httpj:threadingParameters

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi,
I have the following portion of a Spring configuration file that I was using with CXF 2.4.2:
	<httpj:engine-factory >
		<httpj:engine port="9003" >
			<httpj:threadingParameters minThreads="6"
				maxThreads="16" />
		</httpj:engine>
	</httpj:engine-factory>

There is a corresponding jaxws:endpoint that listens to a url on port 9003.  When I updated to CXF 2.5.1, the server was acting like it never received the message yet "netstat -an | grep 9003" shows the port open and "telnet localhost 9003" connects.  I changed nothing else but the CXF version by replacing my classpath with the cxf-manifest.jar from 2.5.1.

A little testing showed that it's the httpj:threadingParameters at fault.  If I remove it then the server gets connections on port 9003 just fine:
	<httpj:engine-factory >
		<httpj:engine port="9003" >
		</httpj:engine>
	</httpj:engine-factory>

Anyone else run into this or have an idea?  Being able to set the maxThreads over the default of 15 is a useful thing so hopefully this can be made to work.

Thanks,
Jesse


RE: SSL engine starting problem

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Thank you Todd, I guess I just started with a bad example.  Wish I'd started with this example instead and saved myself a few hours of screwing around!

Thanks,
Jesse

-----Original Message-----
From: Todd Nist [mailto:todd.nist@ihg.com] 
Sent: Wednesday, July 27, 2011 4:35 AM
To: users@cxf.apache.org
Subject: Re: SSL engine starting problem

Hi,

I think the configuration for jetty should look something like this using
the engine-factory as Glen has suggested.

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://cxf.apache.org/transports/http-jetty/configuration
        http://cxf.apache.org/schemas/configuration/http-jetty.xsd
">

  <import resource="META-INF/cxf/cxf.xml"/>

  <engine-factory bus="cxf"
xmlns="http://cxf.apache.org/transports/http-jetty/configuration">
    <engine port="9090">
      <threadingParameters minThreads="10"
                                 maxThreads="10" />

      <sessionSupport>true</sessionSupport>
    </engine>
    <engine port="9191">
      <tlsServerParameters>
      	<keyManagers
xmlns="http://cxf.apache.org/configuration/security"
keyPassword="password">
      		<keyStore type="JKS" password="password" resource="certs/cherry.jks"/>
      	</keyManagers>
      </tlsServerParameters>
      <threadingParameters minThreads="10" maxThreads="10" />
      <sessionSupport>true</sessionSupport>
    </engine>
  </engine-factory>

  <!-- additional configuration here... -->

</beans>


On Wed, Jul 27, 2011 at 6:57 AM, Glen Mazza <gm...@talend.com> wrote:

> Googling on "httpj:tlsServerParameters" brought
> http://aruld.info/programming-**ssl-for-jetty-based-cxf-**services/<http://aruld.info/programming-ssl-for-jetty-based-cxf-services/>(although it's 3 years old, it may still be accurate.)  That term also
> brings up other hits.  What I can immediately see is that your configuration
> does not wrap httpj:engine with httpj:engine-factory, although I'm unsure if
> that's required.
>
> Glen
>
>
> On 07/26/2011 06:02 PM, Jesse Pangburn wrote:
>
>> Hi,
>> Any advice on the httj:engine using SSL problem below?
>>
>> Thank you,
>> Jesse
>>
>> -----Original Message-----
>> From: Jesse Pangburn [mailto:Jesse.Pangburn@us.**lawson.com<Je...@us.lawson.com>
>> ]
>> Sent: Wednesday, July 20, 2011 5:55 PM
>> To: users@cxf.apache.org
>> Subject: SSL engine starting problem
>>
>> Hi,
>> I'm new to CXF so please forgive these noob questions.  I'm running CXF
>> embedded in a Spring app and have a couple problems.  The following is the
>> content of my spring config xml:
>> <beans xmlns="http://www.**springframework.org/schema/**beans<http://www.springframework.org/schema/beans>
>> "
>>        xmlns:beans="http://www.**springframework.org/schema/**beans<http://www.springframework.org/schema/beans>"
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>>        xmlns:sec="http://cxf.apache.**org/configuration/security<http://cxf.apache.org/configuration/security>"
>> xmlns:http="http://cxf.apache.**org/transports/http/**configuration<http://cxf.apache.org/transports/http/configuration>
>> "
>>        xmlns:httpj="http://cxf.**apache.org/transports/http-**
>> jetty/configuration<http://cxf.apache.org/transports/http-jetty/configuration>
>> "
>>        xmlns:jaxws="http://cxf.**apache.org/jaxws<http://cxf.apache.org/jaxws>"
>> xmlns:cxf="http://cxf.apache.**org/core <http://cxf.apache.org/core>"
>>        xmlns:soap="http://cxf.apache.**org/bindings/soap<http://cxf.apache.org/bindings/soap>
>> "
>>        xsi:schemaLocation="http://**cxf.apache.org/configuration/**
>> security <http://cxf.apache.org/configuration/security>
>> http://cxf.apache.org/schemas/**configuration/security.xsd<http://cxf.apache.org/schemas/configuration/security.xsd>
>>             http://cxf.apache.org/**transports/http/configuration<http://cxf.apache.org/transports/http/configuration>
>> http://cxf.apache.org/schemas/**configuration/http-conf.xsd<http://cxf.apache.org/schemas/configuration/http-conf.xsd>
>>             http://cxf.apache.org/**transports/http-jetty/**configuration<http://cxf.apache.org/transports/http-jetty/configuration>
>> http://cxf.apache.org/schemas/**configuration/http-jetty.xsd<http://cxf.apache.org/schemas/configuration/http-jetty.xsd>
>>             http://www.springframework.**org/schema/beans<http://www.springframework.org/schema/beans>
>> http://www.springframework.**org/schema/beans/spring-beans-**3.0.xsd<http://www.springframework.org/schema/beans/spring-beans-3.0.xsd>
>>             http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/**
>> jaxws.xsd <http://cxf.apache.org/schemas/jaxws.xsd>
>>             http://cxf.apache.org/core http://cxf.apache.org/schemas/**
>> core.xsd <http://cxf.apache.org/schemas/core.xsd>
>>             http://cxf.apache.org/**bindings/soap<http://cxf.apache.org/bindings/soap>
>> http://cxf.apache.org/schemas/**configuration/soap.xsd<http://cxf.apache.org/schemas/configuration/soap.xsd>
>> ">
>>
>>        <import resource="classpath:META-INF/**cxf/cxf.xml" />
>>        <import resource="classpath:META-INF/**cxf/cxf-extension-jaxws.xml"
>> />
>>
>>        <jaxws:endpoint id="restfulGreeting"
>>                implementor="com.infor.**cloverleaf.ib.**RestfulGreetingProvider"
>>
>>                bindingUri="http://www.w3.org/**2004/08/wsdl/http<http://www.w3.org/2004/08/wsdl/http>
>> "
>>                address="http://localhost:**9001/RestfulGreeting<http://localhost:9001/RestfulGreeting>"
>> />
>>
>>        <httpj:engine-factory bus="cxf" id="engineFactory">
>>
>>                <httpj:engine port="9001">
>>                        <httpj:threadingParameters minThreads="6"
>>                                maxThreads="16" />
>>                </httpj:engine>
>>
>>                <httpj:engine port="9002">
>>                        <httpj:tlsServerParameters>
>>                                <sec:keyManagers keyPassword="changeit">
>>                                        <sec:keyStore type="JKS"
>> password="changeit"
>>
>>  file="/home/jpangburn/certs/**server-keystore.jks" />
>>                                </sec:keyManagers>
>>                                <sec:trustManagers>
>>                                        <sec:keyStore type="JKS"
>> password="changeit"
>>
>>  file="/home/jpangburn/certs/**server-truststore.jks" />
>>                                </sec:trustManagers>
>>                                <sec:cipherSuitesFilter>
>>                                        <sec:include>.*_EXPORT_.*</**
>> sec:include>
>>                                        <sec:include>.*_EXPORT1024_.*<**
>> /sec:include>
>>                                        <sec:include>.*_WITH_DES_.*</**
>> sec:include>
>>                                        <sec:include>.*_WITH_NULL_.*</**
>> sec:include>
>>                                        <sec:exclude>.*_DH_anon_.*</**
>> sec:exclude>
>>                                </sec:cipherSuitesFilter>
>>                        </httpj:tlsServerParameters>
>>                        <httpj:threadingParameters minThreads="5"
>>                                maxThreads="15" />
>>                        <httpj:connector>
>>                                <beans:bean class="org.eclipse.jetty.**
>> server.ssl.SslSocketConnector"**>
>>                                        <beans:property name="port"
>> value="9002" />
>>                                </beans:bean>
>>                        </httpj:connector>
>>                        <httpj:handlers>
>>                                <beans:bean class="org.eclipse.jetty.**server.handler.DefaultHandler"
>> />
>>                        </httpj:handlers>
>>                        <httpj:sessionSupport>true</**
>> httpj:sessionSupport>
>>                </httpj:engine>
>>        </httpj:engine-factory>
>> </beans>
>>
>> This file is loaded by the following code:
>> ApplicationContext context = new ClassPathXmlApplicationContext**(new
>> String[] {"/com/infor/cloverleaf/ib/**IBApplicationContext.xml"});
>> // this line is just for debugging, not needed otherwise
>> Object factory = context.getBean("**engineFactory");
>>
>> With the address in my restful endpoint like this 'address="
>> http://localhost:**9001/RestfulGreeting<http://localhost:9001/RestfulGreeting>"'
>> I have no problems.  I can connect to the service and in the debugger when I
>> look at the factory object's portMap field I find that the 9001 port has
>> maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine
>> settings for that port.
>>
>> Problem #1 is if I change the address to 'address="https://localhost:**
>> 9002/RestfulGreeting <https://localhost:9002/RestfulGreeting>"' to use
>> SSL then I get an error on startup.  It says this:
>> WARNING: FAILED org.eclipse.jetty.http.ssl.**SslContextFactory@73b879:
>> java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or
>> directory)
>>
>> So since it's looking for /home/jpangburn/.keystore (the default) instead
>> of /home/jpangburn/certs/server-**keystore.jks as I have configured for
>> port 9002, it's clear that it's ignoring my configuration for that port.  I
>> know it's reading the configuration for the HTTP port, so why not the HTTPS
>> port?
>>
>> The problem #2 is probably just my own misunderstanding, but I see some
>> examples where the address doesn't have the host:port but can't get it to
>> work.  If I set 'address="/RestfulGreeting"' it does not seem to start the
>> jetty engine and netstat shows the port is not listening.  I would have
>> thought that it would try to listen on each engine instance (port 9001 and
>> 9002 in my case) when you didn't specify the host port.  Instead it says the
>> following but doesn't open any ports:
>> INFO: Setting the server's publish address to be /RestfulGreeting
>>
>> Thanks for your help!
>> Jesse
>>
>>
>>
>>
>
> --
> Glen Mazza
> Application Integration Division
> Talend (http://www.talend.com/ai)
> blog: http://www.jroller.com/gmazza
>
>
>


Re: SSL engine starting problem

Posted by Todd Nist <to...@ihg.com>.
Hi,

I think the configuration for jetty should look something like this using
the engine-factory as Glen has suggested.

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://cxf.apache.org/transports/http-jetty/configuration
        http://cxf.apache.org/schemas/configuration/http-jetty.xsd
">

  <import resource="META-INF/cxf/cxf.xml"/>

  <engine-factory bus="cxf"
xmlns="http://cxf.apache.org/transports/http-jetty/configuration">
    <engine port="9090">
      <threadingParameters minThreads="10"
                                 maxThreads="10" />

      <sessionSupport>true</sessionSupport>
    </engine>
    <engine port="9191">
      <tlsServerParameters>
      	<keyManagers
xmlns="http://cxf.apache.org/configuration/security"
keyPassword="password">
      		<keyStore type="JKS" password="password" resource="certs/cherry.jks"/>
      	</keyManagers>
      </tlsServerParameters>
      <threadingParameters minThreads="10" maxThreads="10" />
      <sessionSupport>true</sessionSupport>
    </engine>
  </engine-factory>

  <!-- additional configuration here... -->

</beans>


On Wed, Jul 27, 2011 at 6:57 AM, Glen Mazza <gm...@talend.com> wrote:

> Googling on "httpj:tlsServerParameters" brought
> http://aruld.info/programming-**ssl-for-jetty-based-cxf-**services/<http://aruld.info/programming-ssl-for-jetty-based-cxf-services/>(although it's 3 years old, it may still be accurate.)  That term also
> brings up other hits.  What I can immediately see is that your configuration
> does not wrap httpj:engine with httpj:engine-factory, although I'm unsure if
> that's required.
>
> Glen
>
>
> On 07/26/2011 06:02 PM, Jesse Pangburn wrote:
>
>> Hi,
>> Any advice on the httj:engine using SSL problem below?
>>
>> Thank you,
>> Jesse
>>
>> -----Original Message-----
>> From: Jesse Pangburn [mailto:Jesse.Pangburn@us.**lawson.com<Je...@us.lawson.com>
>> ]
>> Sent: Wednesday, July 20, 2011 5:55 PM
>> To: users@cxf.apache.org
>> Subject: SSL engine starting problem
>>
>> Hi,
>> I'm new to CXF so please forgive these noob questions.  I'm running CXF
>> embedded in a Spring app and have a couple problems.  The following is the
>> content of my spring config xml:
>> <beans xmlns="http://www.**springframework.org/schema/**beans<http://www.springframework.org/schema/beans>
>> "
>>        xmlns:beans="http://www.**springframework.org/schema/**beans<http://www.springframework.org/schema/beans>"
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>>        xmlns:sec="http://cxf.apache.**org/configuration/security<http://cxf.apache.org/configuration/security>"
>> xmlns:http="http://cxf.apache.**org/transports/http/**configuration<http://cxf.apache.org/transports/http/configuration>
>> "
>>        xmlns:httpj="http://cxf.**apache.org/transports/http-**
>> jetty/configuration<http://cxf.apache.org/transports/http-jetty/configuration>
>> "
>>        xmlns:jaxws="http://cxf.**apache.org/jaxws<http://cxf.apache.org/jaxws>"
>> xmlns:cxf="http://cxf.apache.**org/core <http://cxf.apache.org/core>"
>>        xmlns:soap="http://cxf.apache.**org/bindings/soap<http://cxf.apache.org/bindings/soap>
>> "
>>        xsi:schemaLocation="http://**cxf.apache.org/configuration/**
>> security <http://cxf.apache.org/configuration/security>
>> http://cxf.apache.org/schemas/**configuration/security.xsd<http://cxf.apache.org/schemas/configuration/security.xsd>
>>             http://cxf.apache.org/**transports/http/configuration<http://cxf.apache.org/transports/http/configuration>
>> http://cxf.apache.org/schemas/**configuration/http-conf.xsd<http://cxf.apache.org/schemas/configuration/http-conf.xsd>
>>             http://cxf.apache.org/**transports/http-jetty/**configuration<http://cxf.apache.org/transports/http-jetty/configuration>
>> http://cxf.apache.org/schemas/**configuration/http-jetty.xsd<http://cxf.apache.org/schemas/configuration/http-jetty.xsd>
>>             http://www.springframework.**org/schema/beans<http://www.springframework.org/schema/beans>
>> http://www.springframework.**org/schema/beans/spring-beans-**3.0.xsd<http://www.springframework.org/schema/beans/spring-beans-3.0.xsd>
>>             http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/**
>> jaxws.xsd <http://cxf.apache.org/schemas/jaxws.xsd>
>>             http://cxf.apache.org/core http://cxf.apache.org/schemas/**
>> core.xsd <http://cxf.apache.org/schemas/core.xsd>
>>             http://cxf.apache.org/**bindings/soap<http://cxf.apache.org/bindings/soap>
>> http://cxf.apache.org/schemas/**configuration/soap.xsd<http://cxf.apache.org/schemas/configuration/soap.xsd>
>> ">
>>
>>        <import resource="classpath:META-INF/**cxf/cxf.xml" />
>>        <import resource="classpath:META-INF/**cxf/cxf-extension-jaxws.xml"
>> />
>>
>>        <jaxws:endpoint id="restfulGreeting"
>>                implementor="com.infor.**cloverleaf.ib.**RestfulGreetingProvider"
>>
>>                bindingUri="http://www.w3.org/**2004/08/wsdl/http<http://www.w3.org/2004/08/wsdl/http>
>> "
>>                address="http://localhost:**9001/RestfulGreeting<http://localhost:9001/RestfulGreeting>"
>> />
>>
>>        <httpj:engine-factory bus="cxf" id="engineFactory">
>>
>>                <httpj:engine port="9001">
>>                        <httpj:threadingParameters minThreads="6"
>>                                maxThreads="16" />
>>                </httpj:engine>
>>
>>                <httpj:engine port="9002">
>>                        <httpj:tlsServerParameters>
>>                                <sec:keyManagers keyPassword="changeit">
>>                                        <sec:keyStore type="JKS"
>> password="changeit"
>>
>>  file="/home/jpangburn/certs/**server-keystore.jks" />
>>                                </sec:keyManagers>
>>                                <sec:trustManagers>
>>                                        <sec:keyStore type="JKS"
>> password="changeit"
>>
>>  file="/home/jpangburn/certs/**server-truststore.jks" />
>>                                </sec:trustManagers>
>>                                <sec:cipherSuitesFilter>
>>                                        <sec:include>.*_EXPORT_.*</**
>> sec:include>
>>                                        <sec:include>.*_EXPORT1024_.*<**
>> /sec:include>
>>                                        <sec:include>.*_WITH_DES_.*</**
>> sec:include>
>>                                        <sec:include>.*_WITH_NULL_.*</**
>> sec:include>
>>                                        <sec:exclude>.*_DH_anon_.*</**
>> sec:exclude>
>>                                </sec:cipherSuitesFilter>
>>                        </httpj:tlsServerParameters>
>>                        <httpj:threadingParameters minThreads="5"
>>                                maxThreads="15" />
>>                        <httpj:connector>
>>                                <beans:bean class="org.eclipse.jetty.**
>> server.ssl.SslSocketConnector"**>
>>                                        <beans:property name="port"
>> value="9002" />
>>                                </beans:bean>
>>                        </httpj:connector>
>>                        <httpj:handlers>
>>                                <beans:bean class="org.eclipse.jetty.**server.handler.DefaultHandler"
>> />
>>                        </httpj:handlers>
>>                        <httpj:sessionSupport>true</**
>> httpj:sessionSupport>
>>                </httpj:engine>
>>        </httpj:engine-factory>
>> </beans>
>>
>> This file is loaded by the following code:
>> ApplicationContext context = new ClassPathXmlApplicationContext**(new
>> String[] {"/com/infor/cloverleaf/ib/**IBApplicationContext.xml"});
>> // this line is just for debugging, not needed otherwise
>> Object factory = context.getBean("**engineFactory");
>>
>> With the address in my restful endpoint like this 'address="
>> http://localhost:**9001/RestfulGreeting<http://localhost:9001/RestfulGreeting>"'
>> I have no problems.  I can connect to the service and in the debugger when I
>> look at the factory object's portMap field I find that the 9001 port has
>> maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine
>> settings for that port.
>>
>> Problem #1 is if I change the address to 'address="https://localhost:**
>> 9002/RestfulGreeting <https://localhost:9002/RestfulGreeting>"' to use
>> SSL then I get an error on startup.  It says this:
>> WARNING: FAILED org.eclipse.jetty.http.ssl.**SslContextFactory@73b879:
>> java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or
>> directory)
>>
>> So since it's looking for /home/jpangburn/.keystore (the default) instead
>> of /home/jpangburn/certs/server-**keystore.jks as I have configured for
>> port 9002, it's clear that it's ignoring my configuration for that port.  I
>> know it's reading the configuration for the HTTP port, so why not the HTTPS
>> port?
>>
>> The problem #2 is probably just my own misunderstanding, but I see some
>> examples where the address doesn't have the host:port but can't get it to
>> work.  If I set 'address="/RestfulGreeting"' it does not seem to start the
>> jetty engine and netstat shows the port is not listening.  I would have
>> thought that it would try to listen on each engine instance (port 9001 and
>> 9002 in my case) when you didn't specify the host port.  Instead it says the
>> following but doesn't open any ports:
>> INFO: Setting the server's publish address to be /RestfulGreeting
>>
>> Thanks for your help!
>> Jesse
>>
>>
>>
>>
>
> --
> Glen Mazza
> Application Integration Division
> Talend (http://www.talend.com/ai)
> blog: http://www.jroller.com/gmazza
>
>
>

RE: SSL engine starting problem

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi Glen,
Thanks for your reply.  There are two http:engine instances in my config and those two elements are definitely wrapped by the http:engine-factory.  Thanks for the link, it agrees with the page on CXF's site http://cxf.apache.org/docs/standalone-http-transport.html which also doesn't show any httpj:Connector element.  Guess I just started from a bad example somewhere and assumed it worked.  Should have tried those other examples before posting...

Thanks,
Jesse

-----Original Message-----
From: Glen Mazza [mailto:gmazza@talend.com] 
Sent: Wednesday, July 27, 2011 3:57 AM
To: users@cxf.apache.org
Subject: Re: SSL engine starting problem

Googling on "httpj:tlsServerParameters" brought 
http://aruld.info/programming-ssl-for-jetty-based-cxf-services/ 
(although it's 3 years old, it may still be accurate.)  That term also 
brings up other hits.  What I can immediately see is that your 
configuration does not wrap httpj:engine with httpj:engine-factory, 
although I'm unsure if that's required.

Glen

On 07/26/2011 06:02 PM, Jesse Pangburn wrote:
> Hi,
> Any advice on the httj:engine using SSL problem below?
>
> Thank you,
> Jesse
>
> -----Original Message-----
> From: Jesse Pangburn [mailto:Jesse.Pangburn@us.lawson.com]
> Sent: Wednesday, July 20, 2011 5:55 PM
> To: users@cxf.apache.org
> Subject: SSL engine starting problem
>
> Hi,
> I'm new to CXF so please forgive these noob questions.  I'm running CXF embedded in a Spring app and have a couple problems.  The following is the content of my spring config xml:
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
> 	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
> 	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
> 	xmlns:soap="http://cxf.apache.org/bindings/soap"
> 	xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
>              http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
>              http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
>              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>              http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
>              http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
>              http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">
>
> 	<import resource="classpath:META-INF/cxf/cxf.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
>
> 	<jaxws:endpoint id="restfulGreeting"
> 		implementor="com.infor.cloverleaf.ib.RestfulGreetingProvider"		
> 		bindingUri="http://www.w3.org/2004/08/wsdl/http"
> 		address="http://localhost:9001/RestfulGreeting" />
>
> 	<httpj:engine-factory bus="cxf" id="engineFactory">
>
> 		<httpj:engine port="9001">
> 			<httpj:threadingParameters minThreads="6"
> 				maxThreads="16" />
> 		</httpj:engine>
>
> 		<httpj:engine port="9002">
> 			<httpj:tlsServerParameters>
> 				<sec:keyManagers keyPassword="changeit">
> 					<sec:keyStore type="JKS" password="changeit"
> 						file="/home/jpangburn/certs/server-keystore.jks" />
> 				</sec:keyManagers>
> 				<sec:trustManagers>
> 					<sec:keyStore type="JKS" password="changeit"
> 						file="/home/jpangburn/certs/server-truststore.jks" />
> 				</sec:trustManagers>
> 				<sec:cipherSuitesFilter>
> 					<sec:include>.*_EXPORT_.*</sec:include>
> 					<sec:include>.*_EXPORT1024_.*</sec:include>
> 					<sec:include>.*_WITH_DES_.*</sec:include>
> 					<sec:include>.*_WITH_NULL_.*</sec:include>
> 					<sec:exclude>.*_DH_anon_.*</sec:exclude>
> 				</sec:cipherSuitesFilter>
> 			</httpj:tlsServerParameters>
> 			<httpj:threadingParameters minThreads="5"
> 				maxThreads="15" />
> 			<httpj:connector>
> 				<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
> 					<beans:property name="port" value="9002" />
> 				</beans:bean>
> 			</httpj:connector>
> 			<httpj:handlers>
> 				<beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
> 			</httpj:handlers>
> 			<httpj:sessionSupport>true</httpj:sessionSupport>
> 		</httpj:engine>
> 	</httpj:engine-factory>
> </beans>
>
> This file is loaded by the following code:
> ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/com/infor/cloverleaf/ib/IBApplicationContext.xml"});
> // this line is just for debugging, not needed otherwise
> Object factory = context.getBean("engineFactory");
>
> With the address in my restful endpoint like this 'address="http://localhost:9001/RestfulGreeting"' I have no problems.  I can connect to the service and in the debugger when I look at the factory object's portMap field I find that the 9001 port has maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine settings for that port.
>
> Problem #1 is if I change the address to 'address="https://localhost:9002/RestfulGreeting"' to use SSL then I get an error on startup.  It says this:
> WARNING: FAILED org.eclipse.jetty.http.ssl.SslContextFactory@73b879: java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or directory)
>
> So since it's looking for /home/jpangburn/.keystore (the default) instead of /home/jpangburn/certs/server-keystore.jks as I have configured for port 9002, it's clear that it's ignoring my configuration for that port.  I know it's reading the configuration for the HTTP port, so why not the HTTPS port?
>
> The problem #2 is probably just my own misunderstanding, but I see some examples where the address doesn't have the host:port but can't get it to work.  If I set 'address="/RestfulGreeting"' it does not seem to start the jetty engine and netstat shows the port is not listening.  I would have thought that it would try to listen on each engine instance (port 9001 and 9002 in my case) when you didn't specify the host port.  Instead it says the following but doesn't open any ports:
> INFO: Setting the server's publish address to be /RestfulGreeting
>
> Thanks for your help!
> Jesse
>
>
>


-- 
Glen Mazza
Application Integration Division
Talend (http://www.talend.com/ai)
blog: http://www.jroller.com/gmazza





Re: SSL engine starting problem

Posted by Glen Mazza <gm...@talend.com>.
Googling on "httpj:tlsServerParameters" brought 
http://aruld.info/programming-ssl-for-jetty-based-cxf-services/ 
(although it's 3 years old, it may still be accurate.)  That term also 
brings up other hits.  What I can immediately see is that your 
configuration does not wrap httpj:engine with httpj:engine-factory, 
although I'm unsure if that's required.

Glen

On 07/26/2011 06:02 PM, Jesse Pangburn wrote:
> Hi,
> Any advice on the httj:engine using SSL problem below?
>
> Thank you,
> Jesse
>
> -----Original Message-----
> From: Jesse Pangburn [mailto:Jesse.Pangburn@us.lawson.com]
> Sent: Wednesday, July 20, 2011 5:55 PM
> To: users@cxf.apache.org
> Subject: SSL engine starting problem
>
> Hi,
> I'm new to CXF so please forgive these noob questions.  I'm running CXF embedded in a Spring app and have a couple problems.  The following is the content of my spring config xml:
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
> 	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
> 	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
> 	xmlns:soap="http://cxf.apache.org/bindings/soap"
> 	xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
>              http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
>              http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
>              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>              http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
>              http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
>              http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">
>
> 	<import resource="classpath:META-INF/cxf/cxf.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
>
> 	<jaxws:endpoint id="restfulGreeting"
> 		implementor="com.infor.cloverleaf.ib.RestfulGreetingProvider"		
> 		bindingUri="http://www.w3.org/2004/08/wsdl/http"
> 		address="http://localhost:9001/RestfulGreeting" />
>
> 	<httpj:engine-factory bus="cxf" id="engineFactory">
>
> 		<httpj:engine port="9001">
> 			<httpj:threadingParameters minThreads="6"
> 				maxThreads="16" />
> 		</httpj:engine>
>
> 		<httpj:engine port="9002">
> 			<httpj:tlsServerParameters>
> 				<sec:keyManagers keyPassword="changeit">
> 					<sec:keyStore type="JKS" password="changeit"
> 						file="/home/jpangburn/certs/server-keystore.jks" />
> 				</sec:keyManagers>
> 				<sec:trustManagers>
> 					<sec:keyStore type="JKS" password="changeit"
> 						file="/home/jpangburn/certs/server-truststore.jks" />
> 				</sec:trustManagers>
> 				<sec:cipherSuitesFilter>
> 					<sec:include>.*_EXPORT_.*</sec:include>
> 					<sec:include>.*_EXPORT1024_.*</sec:include>
> 					<sec:include>.*_WITH_DES_.*</sec:include>
> 					<sec:include>.*_WITH_NULL_.*</sec:include>
> 					<sec:exclude>.*_DH_anon_.*</sec:exclude>
> 				</sec:cipherSuitesFilter>
> 			</httpj:tlsServerParameters>
> 			<httpj:threadingParameters minThreads="5"
> 				maxThreads="15" />
> 			<httpj:connector>
> 				<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
> 					<beans:property name="port" value="9002" />
> 				</beans:bean>
> 			</httpj:connector>
> 			<httpj:handlers>
> 				<beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
> 			</httpj:handlers>
> 			<httpj:sessionSupport>true</httpj:sessionSupport>
> 		</httpj:engine>
> 	</httpj:engine-factory>
> </beans>
>
> This file is loaded by the following code:
> ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/com/infor/cloverleaf/ib/IBApplicationContext.xml"});
> // this line is just for debugging, not needed otherwise
> Object factory = context.getBean("engineFactory");
>
> With the address in my restful endpoint like this 'address="http://localhost:9001/RestfulGreeting"' I have no problems.  I can connect to the service and in the debugger when I look at the factory object's portMap field I find that the 9001 port has maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine settings for that port.
>
> Problem #1 is if I change the address to 'address="https://localhost:9002/RestfulGreeting"' to use SSL then I get an error on startup.  It says this:
> WARNING: FAILED org.eclipse.jetty.http.ssl.SslContextFactory@73b879: java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or directory)
>
> So since it's looking for /home/jpangburn/.keystore (the default) instead of /home/jpangburn/certs/server-keystore.jks as I have configured for port 9002, it's clear that it's ignoring my configuration for that port.  I know it's reading the configuration for the HTTP port, so why not the HTTPS port?
>
> The problem #2 is probably just my own misunderstanding, but I see some examples where the address doesn't have the host:port but can't get it to work.  If I set 'address="/RestfulGreeting"' it does not seem to start the jetty engine and netstat shows the port is not listening.  I would have thought that it would try to listen on each engine instance (port 9001 and 9002 in my case) when you didn't specify the host port.  Instead it says the following but doesn't open any ports:
> INFO: Setting the server's publish address to be /RestfulGreeting
>
> Thanks for your help!
> Jesse
>
>
>


-- 
Glen Mazza
Application Integration Division
Talend (http://www.talend.com/ai)
blog: http://www.jroller.com/gmazza



RE: SSL engine starting problem

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Found the SSL problem by trial and error, removing this block fixed the problem (apparently it's more than extraneous, it actually screws things up):
	<!-- httpj:connector>
		<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
			<beans:property name="port" value="9002" />
		</beans:bean>
	</httpj:connector-->

Still don't know how to make address="http://localhost:9001/Greetings12" work when you shorten it to address="/Greetings12", even if you're publishing by passing a wsdlLocation attribute- which you might think it would grab the host:port from.  Any clues on that part?

Thanks,
Jesse

-----Original Message-----
From: Jesse Pangburn [mailto:Jesse.Pangburn@us.lawson.com] 
Sent: Tuesday, July 26, 2011 3:02 PM
To: users@cxf.apache.org
Subject: RE: SSL engine starting problem

Hi,
Any advice on the httj:engine using SSL problem below?

Thank you,
Jesse

-----Original Message-----
From: Jesse Pangburn [mailto:Jesse.Pangburn@us.lawson.com] 
Sent: Wednesday, July 20, 2011 5:55 PM
To: users@cxf.apache.org
Subject: SSL engine starting problem

Hi,
I'm new to CXF so please forgive these noob questions.  I'm running CXF embedded in a Spring app and have a couple problems.  The following is the content of my spring config xml:
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
	xmlns:soap="http://cxf.apache.org/bindings/soap"
	xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
            http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
            http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
            http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
            http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
 
	<jaxws:endpoint id="restfulGreeting" 
		implementor="com.infor.cloverleaf.ib.RestfulGreetingProvider"		
		bindingUri="http://www.w3.org/2004/08/wsdl/http"
		address="http://localhost:9001/RestfulGreeting" />
 
	<httpj:engine-factory bus="cxf" id="engineFactory">

		<httpj:engine port="9001" >
			<httpj:threadingParameters minThreads="6"
				maxThreads="16" />
		</httpj:engine>

		<httpj:engine port="9002">
			<httpj:tlsServerParameters>
				<sec:keyManagers keyPassword="changeit">
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-keystore.jks" />
				</sec:keyManagers>
				<sec:trustManagers>
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-truststore.jks" />
				</sec:trustManagers>
				<sec:cipherSuitesFilter>
					<sec:include>.*_EXPORT_.*</sec:include>
					<sec:include>.*_EXPORT1024_.*</sec:include>
					<sec:include>.*_WITH_DES_.*</sec:include>
					<sec:include>.*_WITH_NULL_.*</sec:include>
					<sec:exclude>.*_DH_anon_.*</sec:exclude>
				</sec:cipherSuitesFilter>
			</httpj:tlsServerParameters>
			<httpj:threadingParameters minThreads="5"
				maxThreads="15" />
			<httpj:connector>
				<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
					<beans:property name="port" value="9002" />
				</beans:bean>
			</httpj:connector>
			<httpj:handlers>
				<beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
			</httpj:handlers>
			<httpj:sessionSupport>true</httpj:sessionSupport>
		</httpj:engine>
	</httpj:engine-factory>
</beans>

This file is loaded by the following code:
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/com/infor/cloverleaf/ib/IBApplicationContext.xml"});
// this line is just for debugging, not needed otherwise
Object factory = context.getBean("engineFactory");

With the address in my restful endpoint like this 'address="http://localhost:9001/RestfulGreeting"' I have no problems.  I can connect to the service and in the debugger when I look at the factory object's portMap field I find that the 9001 port has maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine settings for that port.

Problem #1 is if I change the address to 'address="https://localhost:9002/RestfulGreeting"' to use SSL then I get an error on startup.  It says this:
WARNING: FAILED org.eclipse.jetty.http.ssl.SslContextFactory@73b879: java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or directory)

So since it's looking for /home/jpangburn/.keystore (the default) instead of /home/jpangburn/certs/server-keystore.jks as I have configured for port 9002, it's clear that it's ignoring my configuration for that port.  I know it's reading the configuration for the HTTP port, so why not the HTTPS port?

The problem #2 is probably just my own misunderstanding, but I see some examples where the address doesn't have the host:port but can't get it to work.  If I set 'address="/RestfulGreeting"' it does not seem to start the jetty engine and netstat shows the port is not listening.  I would have thought that it would try to listen on each engine instance (port 9001 and 9002 in my case) when you didn't specify the host port.  Instead it says the following but doesn't open any ports:
INFO: Setting the server's publish address to be /RestfulGreeting

Thanks for your help!
Jesse






RE: SSL engine starting problem

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi,
Any advice on the httj:engine using SSL problem below?

Thank you,
Jesse

-----Original Message-----
From: Jesse Pangburn [mailto:Jesse.Pangburn@us.lawson.com] 
Sent: Wednesday, July 20, 2011 5:55 PM
To: users@cxf.apache.org
Subject: SSL engine starting problem

Hi,
I'm new to CXF so please forgive these noob questions.  I'm running CXF embedded in a Spring app and have a couple problems.  The following is the content of my spring config xml:
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
	xmlns:soap="http://cxf.apache.org/bindings/soap"
	xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
            http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
            http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
            http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
            http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
 
	<jaxws:endpoint id="restfulGreeting" 
		implementor="com.infor.cloverleaf.ib.RestfulGreetingProvider"		
		bindingUri="http://www.w3.org/2004/08/wsdl/http"
		address="http://localhost:9001/RestfulGreeting" />
 
	<httpj:engine-factory bus="cxf" id="engineFactory">

		<httpj:engine port="9001" >
			<httpj:threadingParameters minThreads="6"
				maxThreads="16" />
		</httpj:engine>

		<httpj:engine port="9002">
			<httpj:tlsServerParameters>
				<sec:keyManagers keyPassword="changeit">
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-keystore.jks" />
				</sec:keyManagers>
				<sec:trustManagers>
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-truststore.jks" />
				</sec:trustManagers>
				<sec:cipherSuitesFilter>
					<sec:include>.*_EXPORT_.*</sec:include>
					<sec:include>.*_EXPORT1024_.*</sec:include>
					<sec:include>.*_WITH_DES_.*</sec:include>
					<sec:include>.*_WITH_NULL_.*</sec:include>
					<sec:exclude>.*_DH_anon_.*</sec:exclude>
				</sec:cipherSuitesFilter>
			</httpj:tlsServerParameters>
			<httpj:threadingParameters minThreads="5"
				maxThreads="15" />
			<httpj:connector>
				<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
					<beans:property name="port" value="9002" />
				</beans:bean>
			</httpj:connector>
			<httpj:handlers>
				<beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
			</httpj:handlers>
			<httpj:sessionSupport>true</httpj:sessionSupport>
		</httpj:engine>
	</httpj:engine-factory>
</beans>

This file is loaded by the following code:
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/com/infor/cloverleaf/ib/IBApplicationContext.xml"});
// this line is just for debugging, not needed otherwise
Object factory = context.getBean("engineFactory");

With the address in my restful endpoint like this 'address="http://localhost:9001/RestfulGreeting"' I have no problems.  I can connect to the service and in the debugger when I look at the factory object's portMap field I find that the 9001 port has maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine settings for that port.

Problem #1 is if I change the address to 'address="https://localhost:9002/RestfulGreeting"' to use SSL then I get an error on startup.  It says this:
WARNING: FAILED org.eclipse.jetty.http.ssl.SslContextFactory@73b879: java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or directory)

So since it's looking for /home/jpangburn/.keystore (the default) instead of /home/jpangburn/certs/server-keystore.jks as I have configured for port 9002, it's clear that it's ignoring my configuration for that port.  I know it's reading the configuration for the HTTP port, so why not the HTTPS port?

The problem #2 is probably just my own misunderstanding, but I see some examples where the address doesn't have the host:port but can't get it to work.  If I set 'address="/RestfulGreeting"' it does not seem to start the jetty engine and netstat shows the port is not listening.  I would have thought that it would try to listen on each engine instance (port 9001 and 9002 in my case) when you didn't specify the host port.  Instead it says the following but doesn't open any ports:
INFO: Setting the server's publish address to be /RestfulGreeting

Thanks for your help!
Jesse




SSL engine starting problem

Posted by Jesse Pangburn <Je...@us.lawson.com>.
Hi,
I'm new to CXF so please forgive these noob questions.  I'm running CXF embedded in a Spring app and have a couple problems.  The following is the content of my spring config xml:
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration"
	xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
	xmlns:soap="http://cxf.apache.org/bindings/soap"
	xsi:schemaLocation="http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
            http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
            http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
            http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
            http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
 
	<jaxws:endpoint id="restfulGreeting" 
		implementor="com.infor.cloverleaf.ib.RestfulGreetingProvider"		
		bindingUri="http://www.w3.org/2004/08/wsdl/http"
		address="http://localhost:9001/RestfulGreeting" />
 
	<httpj:engine-factory bus="cxf" id="engineFactory">

		<httpj:engine port="9001" >
			<httpj:threadingParameters minThreads="6"
				maxThreads="16" />
		</httpj:engine>

		<httpj:engine port="9002">
			<httpj:tlsServerParameters>
				<sec:keyManagers keyPassword="changeit">
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-keystore.jks" />
				</sec:keyManagers>
				<sec:trustManagers>
					<sec:keyStore type="JKS" password="changeit"
						file="/home/jpangburn/certs/server-truststore.jks" />
				</sec:trustManagers>
				<sec:cipherSuitesFilter>
					<sec:include>.*_EXPORT_.*</sec:include>
					<sec:include>.*_EXPORT1024_.*</sec:include>
					<sec:include>.*_WITH_DES_.*</sec:include>
					<sec:include>.*_WITH_NULL_.*</sec:include>
					<sec:exclude>.*_DH_anon_.*</sec:exclude>
				</sec:cipherSuitesFilter>
			</httpj:tlsServerParameters>
			<httpj:threadingParameters minThreads="5"
				maxThreads="15" />
			<httpj:connector>
				<beans:bean class="org.eclipse.jetty.server.ssl.SslSocketConnector">
					<beans:property name="port" value="9002" />
				</beans:bean>
			</httpj:connector>
			<httpj:handlers>
				<beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
			</httpj:handlers>
			<httpj:sessionSupport>true</httpj:sessionSupport>
		</httpj:engine>
	</httpj:engine-factory>
</beans>

This file is loaded by the following code:
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"/com/infor/cloverleaf/ib/IBApplicationContext.xml"});
// this line is just for debugging, not needed otherwise
Object factory = context.getBean("engineFactory");

With the address in my restful endpoint like this 'address="http://localhost:9001/RestfulGreeting"' I have no problems.  I can connect to the service and in the debugger when I look at the factory object's portMap field I find that the 9001 port has maxThreads=16 and minThreads=6, so I know that it's using the httpj:engine settings for that port.

Problem #1 is if I change the address to 'address="https://localhost:9002/RestfulGreeting"' to use SSL then I get an error on startup.  It says this:
WARNING: FAILED org.eclipse.jetty.http.ssl.SslContextFactory@73b879: java.io.FileNotFoundException: /home/jpangburn/.keystore (No such file or directory)

So since it's looking for /home/jpangburn/.keystore (the default) instead of /home/jpangburn/certs/server-keystore.jks as I have configured for port 9002, it's clear that it's ignoring my configuration for that port.  I know it's reading the configuration for the HTTP port, so why not the HTTPS port?

The problem #2 is probably just my own misunderstanding, but I see some examples where the address doesn't have the host:port but can't get it to work.  If I set 'address="/RestfulGreeting"' it does not seem to start the jetty engine and netstat shows the port is not listening.  I would have thought that it would try to listen on each engine instance (port 9001 and 9002 in my case) when you didn't specify the host port.  Instead it says the following but doesn't open any ports:
INFO: Setting the server's publish address to be /RestfulGreeting

Thanks for your help!
Jesse


Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
Also - let me know please how the receiving method signature looks like

Cheers, Sergey

On Thu, Jul 21, 2011 at 12:41 AM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)
> <da...@alcatel-lucent.com> wrote:
>> I am processing multipart form-data for file uploads using JAX-RS.
>> Using Apache CXF 2.4.1
>>
>>
>> The example addBookFilesForm shown here is not working as-is for me:
>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles
>>
>> Has an example request here:
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
>>
>> The second part of the form data is a multipart/mixed list of books.
>> The relevant snippet of the above request is:
>>
>>
>>        Cntent-Disposition: form-data; name="files"
>>
>>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>>
>> This fails for me with
>>
>> WARNING: No multipart with content id files found
>>
>> If I add
>>      Content-Id:<files>
>>
>> to the request, then it works fine.
>>
>> Should it not use the name if the Content-ID is not specified?
>> Is there something I can do to not require this Content-Id and use the name?   It is not
>> in my interface spec so hope to avoid requiring it.
>>
> That is a bit strange given that I can see this test working for me,
> here is the trace:
>
> POST /bookstore/books/filesform HTTP/1.1
> Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> User-Agent: Jakarta Commons-HttpClient/3.1
> Host: localhost:8081
> Content-Length: 759
>
>
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>
> and the output is OK.
> I also recall updating the code to check Content-Disposition if
> Content-Id is missing.
>
> Are you using Struts by any chance ? Here are some hints just in case:
>
> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts
>
>>
>> On another note, there is an error in the addBookJaxbJsonForm example, the request has
>>
>>        Content-ID: <jaxbPart>
>>
>> But the signature specifies "bookXML" not jaxbPart.
>>
>>
> Fixed - should be propagated shortly
>
> thanks, Sergey
>>
>> Thanks!
>>
>>
>>
>> -- DC
>>
>> Dave.Collard@alcatel-lucent.com
>>
>>
>>
>>
>
>
>
> --
> Sergey Beryozkin
>
> http://sberyozkin.blogspot.com
> Talend - http://www.talend.com
>

Re: JAXRS Multipart Form-Data requiring Content-ID

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Wed, Jul 20, 2011 at 5:32 PM, Collard, David L (Dave)
<da...@alcatel-lucent.com> wrote:
> I am processing multipart form-data for file uploads using JAX-RS.
> Using Apache CXF 2.4.1
>
>
> The example addBookFilesForm shown here is not working as-is for me:
> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles
>
> Has an example request here:
> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
>
> The second part of the form data is a multipart/mixed list of books.
> The relevant snippet of the above request is:
>
>
>        Cntent-Disposition: form-data; name="files"
>
>        Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> This fails for me with
>
> WARNING: No multipart with content id files found
>
> If I add
>      Content-Id:<files>
>
> to the request, then it works fine.
>
> Should it not use the name if the Content-ID is not specified?
> Is there something I can do to not require this Content-Id and use the name?   It is not
> in my interface spec so hope to avoid requiring it.
>
That is a bit strange given that I can see this test working for me,
here is the trace:

POST /bookstore/books/filesform HTTP/1.1
Content-Type: multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8081
Content-Length: 759


--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="owner"
Content-Type: text/plain

Larry
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786

--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book1"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 1","id":123}}
--_Part_4_701508.1145579811786
Content-Disposition: form-data; name="book2"
Content-Type: application/json; charset=US-ASCII
Content-Transfer-Encoding: 8bit

{"Book":{"name":"CXF in Action - 2","id":124}}
--_Part_4_701508.1145579811786--
--bqJky99mlBWa-ZuqjC53mG6EzbmlxB--

and the output is OK.
I also recall updating the code to check Content-Disposition if
Content-Id is missing.

Are you using Struts by any chance ? Here are some hints just in case:

http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-NoteaboutStruts

>
> On another note, there is an error in the addBookJaxbJsonForm example, the request has
>
>        Content-ID: <jaxbPart>
>
> But the signature specifies "bookXML" not jaxbPart.
>
>
Fixed - should be propagated shortly

thanks, Sergey
>
> Thanks!
>
>
>
> -- DC
>
> Dave.Collard@alcatel-lucent.com
>
>
>
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com