I am uploading a file using a form to a JAXRS service using CXF 3.0.0 but now I 
keep getting this error "Couldn't find MIME boundary: ------WebKitFormBoundary"

My upload form looks like this:

<form action="{restserviceurl}"  method="post" enctype="multipart/form-data">
 <input type="file" name="file" size="50"/>
 <input type="submit"/>
</form>


I have the following bean declared in my class that extends 
WebMvcConfiguereAdapter:

 Public class AppConfig extends WebMvcConfigurerAdapter {
    @Bean(name="filterMultipartResolver")
    public CommonsMultipartResolver filterMultipartResolver() {
       CommonsMultipartResolver commons  = new CommonsMultipartResolver();
        return new CommonsMultipartResolver();
    } 
...

}

My JAXRS service method looks like this:
  
@POST
@Path("/uploadonly")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public  List<String> upload(@Multipart(value="file") Attachment attachment);

In my class that exposes the JAXRS endpoints I have a class that extends the 
Application but not sure what that can do:

@ApplicationPath("/")
Public class JaxRsApiApplication extends Application{

}


Thanks
-Sonam

-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]] 
Sent: Friday, April 17, 2015 3:32 AM
To: [email protected]
Subject: Re: jaxrs with angularjs file upload question

Hi

One relevant info is here:

> [2015-04-16 10:30:29,681]  WARN LogUtils 452 doLog - Interceptor for
>>{http://user.jaxrs.webservice.note.sonam.com/}UserImages has thrown 
>>exception, unwinding now java.lang.NullPointerException
>>      at
>>org.apache.cxf.attachment.AttachmentUtil.getHeader(AttachmentUtil.java
>>:306)
https://fisheye6.atlassian.com/browse/~tag=cxf-3.0.0/cxf/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?r=c1674905a6deea5f7281f636039b9e5382187828#to306


I've checked the code, this is where some header is retrieved from a map of 
headers and this map is apparently null. I've just updated the local test to 
have a given multi-part have no headers at all, only some content and no NPE 
was reported...

I suspect the multipart request is somehow mis-formatted. You have this
reported:

[2015-04-16 10:30:29,427] DEBUG MultipartFilter 114 doFilterInternal - Request 
[/note/soa/linkableImages/images/upload] is not a multipart request

Perhaps it is not a multipart request after all...

Try to run the request via a tcp trace utility and see what is reported.

Cheers, Sergey

Reply via email to