Hi Ivan,
It seems working fine here.
that is a sample:
https://github.com/danielsoro/cxf-upload
To run:
mvn clean install tomee:run
Fileupload dir:
target/apache-tomee/${FILE}
Em ter, 26 de mar de 2019 às 13:06, Ivan Junckes Filho <
[email protected]> escreveu:
> Same issues in all scenarios Dani :/
>
> On Tue, Mar 26, 2019 at 11:55 AM Daniel Cunha <[email protected]>
> wrote:
>
> > Hi Ivan,
> >
> > what happening if you don't define the type?
> > @Multipart(value = "anexo") Attachment anexo
> >
> > Em ter, 26 de mar de 2019 às 11:51, Daniel Cunha <[email protected]>
> > escreveu:
> >
> > > Have you get same issue with: MultipartBody?
> > > Something like:
> > > @Consumes(MediaType.MULTIPART_FORM_DATA)
> > > public Response upload(MultipartBody body,
> > > @PathParam("idProcesso") Long idProcesso {}
> > >
> > > So you can get the file from: body.getAllAttachments() or
> > > body.getAttachment("anexo").
> > > I need to try reproduce it locally or see if we have some sample on CXF
> > > side. But, can you try with MultipartBody?
> > >
> > > Em ter, 26 de mar de 2019 às 11:31, Ivan Junckes Filho <
> > > [email protected]> escreveu:
> > >
> > >> *CHROME REQUEST:*
> > >>
> > >> 1. Request URL:
> > >>
> > >> http://localhost:8080/crvirtualdemandas/api/processos/anexo/upload/1
> > >> 2. Request Method:
> > >> POST
> > >> 3. Status Code:
> > >> 415
> > >> 4. Remote Address:
> > >> [::1]:8080
> > >> 5. Referrer Policy:
> > >> no-referrer-when-downgrade
> > >> 1. Response Headersview source
> > >> 1. Access-Control-Allow-Credentials:
> > >> true
> > >> 2. Access-Control-Allow-Origin:
> > >> http://localhost:8080
> > >> 3. Access-Control-Expose-Headers:
> > >> Access-Control-Allow-Origin,Access-Control-Allow-Credentials
> > >> 4. Content-Length:
> > >> 0
> > >> 5. Date:
> > >> Tue, 26 Mar 2019 14:29:27 GMT
> > >> 6. Server:
> > >> Apache TomEE
> > >> 7. vary:
> > >> Origin
> > >> 2. Request Headersview source
> > >> 1. Accept:
> > >> application/json
> > >> 2. Accept-Encoding:
> > >> gzip, deflate, br
> > >> 3. Accept-Language:
> > >> en-US,en;q=0.9,pt;q=0.8
> > >> 4. Connection:
> > >> keep-alive
> > >> 5. Content-Length:
> > >> 213
> > >> 6. Content-Transfer-Encoding:
> > >> binary
> > >> 7. Content-Type:
> > >> multipart/form-data;
> > boundary=----WebKitFormBoundaryty8x9JCIl3wCHnkM
> > >> 8. Cookie:
> > >> Idea-4c26cc00=059851e2-1747-4e5a-8b39-5a15911d851b
> > >> 9. DNT:
> > >> 1
> > >> 10. Host:
> > >> localhost:8080
> > >> 11. Origin:
> > >> http://localhost:8080
> > >> 12. Referer:
> > >> http://localhost:8080/crvirtual_demandas/upload_test.html
> > >> 13. User-Agent:
> > >> Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
> > >> Gecko) Chrome/70.0.3538.102 Safari/537.36
> > >> 14. X-Requested-With:
> > >> XMLHttpRequest
> > >> 3. Form Dataview sourceview URL encoded
> > >> 1. anexo:
> > >> (binary)
> > >>
> > >>
> > >>
> > >>
> > >> *LOGS*
> > >>
> > >> 26-Mar-2019 10:58:10.290 SEVERE [http-nio-8080-exec-40]
> > >> org.apache.cxf.jaxrs.utils.JAXRSUtils.logMessageHandlerProblem No
> > message
> > >> body reader has been found for class
> > >> org.apache.cxf.jaxrs.ext.multipart.Attachment, ContentType:
> > >> multipart/form-data;boundary=----WebKitFormBoundaryDsJ1PGRCubchSS8G
> > >> 26-Mar-2019 10:58:10.297 WARNING [http-nio-8080-exec-40]
> > >> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper.toResponse
> > >> javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1370)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processRequestBodyParameter(JAXRSUtils.java:865)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:810)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> > >> at
> > >>
> > >>
> >
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
> > >> at
> > >>
> > >>
> >
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:258)
> > >> at
> > >>
> > >>
> >
> org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:99)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > >>
> >
> br.com.gbrsistemas.crvirtual.authentication.jwt.JwtFilter.doFilter(JwtFilter.java:35)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > >>
> >
> br.com.gbrsistemas.crvirtual.authentication.signature.SignatureFilter.doFilter(SignatureFilter.java:47)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:352)
> > >> at
> org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:171)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > >>
> >
> org.apache.geronimo.microprofile.opentracing.microprofile.server.OpenTracingFilter.doFilter(OpenTracingFilter.java:126)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > >>
> >
> org.apache.tomee.microprofile.jwt.MPJWTFilter.doFilter(MPJWTFilter.java:76)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> > >> at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> > >> at
> > >>
> > >>
> >
> org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
> > >> at
> > >>
> > >>
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> > >> at
> > >>
> >
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
> > >> at
> > >>
> > >>
> >
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> > >> at
> > >>
> > >>
> >
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
> > >> at
> > >> org.apache.tomcat.util.net
> > >> .NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
> > >> at
> > >> org.apache.tomcat.util.net
> > >> .SocketProcessorBase.run(SocketProcessorBase.java:49)
> > >> at
> > >>
> > >>
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> > >> at
> > >>
> > >>
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> > >> at
> > >>
> > >>
> >
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> > >> at java.lang.Thread.run(Thread.java:748)
> > >>
> > >> 26-Mar-2019 10:58:10.304 INFO [http-nio-8080-exec-40]
> > >>
> > >>
> >
> org.apache.geronimo.microprofile.opentracing.microprofile.zipkin.ZipkinLogger.onZipkinSpan
> > >>
> > >>
> >
> [{"annotations":[{"timestamp":1553608690289000,"value":"sr"},{"timestamp":1553608690299000,"value":"ss"}],"binaryAnnotations":[{"key":"http.status_code","type":3,"value":415},{"key":"component","type":6,"value":"jaxrs"},{"key":"span.kind","type":6,"value":"server"},{"key":"http.url","type":6,"value":"
> > >> http://localhost:8080/crvirtualdemandas/api/processos/anexo/upload/1
> > >>
> > >>
> >
> "},{"key":"http.method","type":6,"value":"POST"}],"duration":10000,"id":22,"kind":"SERVER","localEndpoint":{"ipv4":"127.0.0.1","port":8080,"serviceName":"ivan-Inspiron-5457_5557"},"name":"POST:br.com.gbrsistemas.crvirtual.demanda.processo.ProcessoFiscalizacaoAnexoService.upload","parentId":0,"tags":{"http.status_code":"415","component":"jaxrs","http.url":"
> > >> http://localhost:8080/crvirtualdemandas/api/processos/anexo/upload/1
> > >> ","http.method":"POST"},"timestamp":1553608690289000,"traceId":21}]
> > >>
> > >> *CODE*
> > >>
> > >> @POST
> > >> @Path("upload/{idProcesso}")
> > >> @Produces(MediaType.APPLICATION_JSON)
> > >> @Consumes(MediaType.MULTIPART_FORM_DATA)
> > >> public Response upload(@Multipart(value = "anexo", type =
> > >> MediaType.APPLICATION_OCTET_STREAM) Attachment anexo,
> > >> @PathParam("idProcesso") Long idProcesso){}
> > >>
> > >>
> > >>
> > >> On Tue, Mar 26, 2019 at 11:27 AM Daniel Cunha <[email protected]>
> > >> wrote:
> > >>
> > >> > Can you post your stacktrace?
> > >> >
> > >> > Em ter, 26 de mar de 2019 às 11:20, Ivan Junckes Filho <
> > >> > [email protected]> escreveu:
> > >> >
> > >> > > Hey guys, I am getting this issue while uploading a file.
> > >> > >
> > >> > > Anyone know why this is happening?
> > >> > >
> > >> > >
> > >> >
> > >>
> >
> https://stackoverflow.com/questions/45075798/cxf-no-message-body-reader-has-been-found-for-class-attachment
> > >> > >
> > >> >
> > >> >
> > >> > --
> > >> > Daniel "soro" Cunha
> > >> > https://twitter.com/dvlc_
> > >> >
> > >>
> > >
> > >
> > > --
> > > Daniel "soro" Cunha
> > > https://twitter.com/dvlc_
> > >
> >
> >
> > --
> > Daniel "soro" Cunha
> > https://twitter.com/dvlc_
> >
>
--
Daniel "soro" Cunha
https://twitter.com/dvlc_