-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whiteboard JAX-RS Multipart #65
Comments
You have the correct configuration using It looks like it might be a problem/bug with |
thanks for your quick reply. Is there any way to verify your guess? |
I can look when I have time but I'm not sure where that will be. Maybe sending a message to the felix mail list might provide some insight? |
thanks, will do so |
I found out, that using the classic way and override the
I am still searching for a solution using the JAX-RS way with multipart... |
This appears to be an intentional limitation of the JAX-RS whiteboard implementation from Aries, which has not requested that multipart be enabled. Fortunately the Aries JAX-RS whiteboard is pretty flexible, and allows you to configure the properties of the servlet it registers. This should be as simple as adding:
as a configuration property for the whiteboard. Assuming that you are using the default whiteboard this pid would be Once you have done this then you can use multipart however you wish, although I would suggest that a more natural approach involves using the |
Thanks @timothyjward and thanks @rotty3000 for your patient and your answers. I am sorry, but I didn't understand your answer completely.
Is there something wrong? Thanks |
I’m afraid that this is a misunderstanding, and I may have been insufficiently clear. There is no property you can add to your JAX-RS resource service to enable multipart support. Note that this does not mean that you cannot enable multipart support, but you must do it elsewhere. Most JAX-RS whiteboards build on top of the Http Service Whiteboard by registering a whiteboard Servlet, which they then use to provide endpoints for all of their resources. Aries JAX-RS is one of these implementations. The available support from the web container is therefore entirely dictated by the service properties of the implementation’s whiteboard Servlet, not the service properties of the JAX-RS resources. Even if the JAX-RS whiteboard created its own web server, it would still be this configuration we needed to alter, not the properties of your whiteboard resource. To enable multipart support we must therefore add to the service properties of the JAX-RS whiteboard’s implementation. You can do this by changing the configuration of the whiteboard using a configuration admin dictionary as I described earlier. This would be a new entry in your JSON configuration file. For belt and braces you could further require that this property had been set by using a whiteboard target for your JAX-RS resource service (this would be a service property on your service). This filter could require that the |
I totally misunderstood your first post. |
Hi @timothyjward , Can you please let me know where I can add the property "osgi.http.whiteboard.servlet.multipart.enabled" to JAX-RS whiteboard configuration |
As described further up this bug, if you want to enable this for the default whiteboard then the configuration pid is |
@timothyjward I wonder if there would be any downside with making this the default? |
It would require the hosting Servlet container to always support multipart, which is a relatively uncommon feature to need in a JAX-RS app. As is we can run on containers which don’t support multipart. |
that's a good point. thanks for the thought experiment. retracting the idea :) |
Hi guys,
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: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 theHttpServlet
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?
The text was updated successfully, but these errors were encountered: