Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rest-dev] [External] : MultiPart Problems
  • From: Santiago Pericasgeertsen <santiago.pericasgeertsen@xxxxxxxxxx>
  • Date: Wed, 23 Aug 2023 20:36:26 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kwUDNN3mj8uXI/3Ls4NWWpzW1qmrobBa7E/ICdVWdL4=; b=YpEObVIG1XiPSVQyB3jVZHQaZFRcrfAml97zizMZzvjqtHfGu+3wQRuQFB5v0piGrITNEvmDWqQSUL0b9KQDQVDgQ99euhxUD7Rzj8RT9R4pOXyw65F2FuWLcaREBfKdbdAWSI2GnjngtL80hmW5Wcxz/Qio3AGzJflaNFx6kr+Z+cxNFvB7aeS3G52xiVPyBy629JyCnbhhYfgbvaJIeVE7RuxPgOuo43GliJviIagOpX7/zPmCN6/euEdc36kHdseh8G+7Ym+rGxTo1F3la3DavsFc1E/YnLe0I9YELDqRVaEDCWfvoR6kxnwyd3D92dBDK75lWXCgSAhvu5f0Zw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jxJUiR1oQaNr4miwu+oIBLYoKuLiZfleqggfZYHsf9jp5m69r+SYUx8s5xnsLjxX6tV5S+l6TR4H6PfgJZ8d3IvXxlS2aHLiZn3OtnteQc5Fwqz0H0PqYtev9GdaM7XFqGjCnDXgmCmxFW5SUdQ+rlUsFE6liGrVXVnK/JZ4A0E1qdPoRk9w5F5ySmvGqH+jLH1nICHEKqY3l2WgkPm0X7gXCyvE+lvABHCmrjzF4pk9foBMr15SJwqKRJ6ntADqEsLuBuH0Is+z1+MzBNJBJsuodmw3DDDv1b9uHVs0kyNs1vyqpk/lo35rmekT5lM8fJGMnHNcLlQ4DZJsfDA4Rw==
  • Delivered-to: rest-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/rest-dev/>
  • List-help: <mailto:rest-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/rest-dev>, <mailto:rest-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/rest-dev>, <mailto:rest-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AdnV+KClIAUsrRnaSZWsD8s2mtTDFQACNWGA
  • Thread-topic: [External] : [rest-dev] MultiPart Problems

Ken,

 Have you verified that the implementation version (of Jersey for example) is the correct one for the Jakarta 10 API? Which implementation is printing the warnings in your message? For Jersey, you should try 3.1.3.

 See also https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest31x/media.html#multipart

— Santiago

On Aug 23, 2023, at 3:35 PM, omniprof--- via rest-dev <rest-dev@xxxxxxxxxxx> wrote:

Hi everyone,
 
I am developing a workshop for the Eclipse Foundation on Jakarta 10 REST 3.1 services. The workshop is divided into 8 modules. There is one module I cannot get my code to work and that is using MultiPart to either upload or download an image file.
 
It should be straightforward. I have modules that take advantage of the automatic conversion from an object to a JSON serialized version of the object and vice versa. I show both SeBootstrap and server-based REST services and REST clients. I even show code using either Jersey or RESTEasy.
 
Things have fallen apart when it comes to MultiPart. Let us begin with where I am stuck. Many have written about MultiPart, but I have yet to find any working examples. There are articles that show how to code the rest service end point and articles on how to write clients. What I have not found is an article or text that presents both the service endpoint and a matching client for MultiPart. Here is an example of what I mean from the official Eclipse documentation:
 
In the text is this code fragment:
 
@Path("widgets4")
public class WidgetsResource4 {
 
    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response postWidget(@FormParam("part1Name") String part1,
                               @FormParam("part2Name") InputStream part2,
                               @FormParam("part3Name") EntityPart part3) {...}
}
 
There is no example how you might call this service. If I place this code in an SeBootstrap service and have it return Response.ok().build() I get:
 
WARNING: No injection source found for a parameter of type public jakarta.ws.rs.core.Response com.eclipse.restsebootstrap.FileUploadService.postWidget(java.lang.String,java.io.InputStream,jakarta.ws.rs.core.EntityPart) at index 2.
WARNING: No injection source found for a parameter of type public jakarta.ws.rs.core.Response com.eclipse.restsebootstrap.FileUploadService.uploadFile(java.lang.String,jakarta.ws.rs.core.EntityPart) at index 1.
 
I do not get any warnings when deployed as part of a server-based endpoint, but it just won’t work, throwing exceptions due to a null EntityPart. While they may be just warnings for a specific POST service, any other services that would normally run, fail as well. Remove this POST service and the remaining services work.
 
I suspect that there is a library I am missing in my dependencies. I discovered just yesterday that there are two Response classes, one for Servlets & family and one for web services. Rarely do online examples discuss dependencies. When there is code to download from a Git repo it is usually part of a project where numerous demos all use the same pom file with an overwhelming number of dependencies and plugins. Every example I am developing has its own repo.
 
All I am begging/pleading/asking for is a simple example of uploading and downloading binary files in a web service. While it should not make a difference, I work on Windows.
 
Ken Fogel
Java Champion
JChampions Conference Organizer
JCP Executive Committee Member
Research Scholar in Residence, Dawson College
Author of Transitioning to Java
All around nice guy, usually.
 
_______________________________________________
rest-dev mailing list
rest-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://urldefense.com/v3/__https://accounts.eclipse.org__;!!ACWV5N9M2RV99hQ!MCJzcECRQnU1EUFLcJ_bF2Bh9xo4L1527Tjbree_LxNEFIJvuzxshqeHAOp0PmuiKeYsbm2sTwuAUicDGkK08wiksoWd$


Back to the top