Hallo,

I encountered another problem and I was hoping you could help me out, again.

I am trying to process a request containing a multipart/form-data.
As far as I understood beginning from v3 the HttpServletRequest can parse the 
form-data without the need of any library.

I extended my small osgi-test app by another controller for the multipart 
endpoint.
https://github.com/phhoef/osgi-test/blob/master/rest-service/src/main/java/com/my/app/rest/rest/MultipartController.java

Whenever I am trying to invoke the getParts() method the following exception is 
thrown:

<h2>HTTP ERROR 500</h2>

        <p>Problem accessing /multipart. Reason:



            <pre>    Server Error</pre>

        </p>

        <h3>Caused by:</h3>

        <pre>java.lang.IllegalStateException: Multipart not enabled for servlet.

         at 
org.apache.felix.http.base.internal.dispatch.ServletRequestWrapper.checkMultipart(ServletRequestWrapper.java:368)

         at 
org.apache.felix.http.base.internal.dispatch.ServletRequestWrapper.getParts(ServletRequestWrapper.java:522)

         at 
javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:345)

         at 
com.my.app.rest.rest.MultipartController.post(MultipartController.java:22)

I understand, that I have to activate multipart for that Servlet.
I didn't find much on the internet, only some posts stating either using 
@MultipartConfig or the @HttpWhiteboardServletMultipart annotation.
For the @MultipartConfig I modified the controller. I subclassed the 
HttpServlet and set the @Component(service=Servlet.class).
https://blog.osgi.org/2018/05/osgi-r7-highlights-http-whiteboard.html
But both annotations do not influence the behavior.



Do I miss something?

Reply via email to