jersey

Jersey @Produces Apache XSSFWorkbook

a 夏天 提交于 2019-12-22 12:13:49
问题 I am trying to produce a XSSFWorkbook using Jersey. I have tried the following headers and nothing seems to work: @Produces("application/xml") @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Produces("application/vnd.openxml" All return the following error: Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.apache.poi.xssf.usermodel.XSSFWorkbook, and Java type class org.apache.poi.xssf.usermodel.XSSFWorkbook, and MIME media

AsyncResponse and Java 8 parallel stream issue

╄→尐↘猪︶ㄣ 提交于 2019-12-22 10:59:46
问题 I am using spring boot with Jersey rest api @POST @Path("test") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public void test(final List<String> requests, @Suspended final AsyncResponse asyncResponse) { List<String> resplist = new ArrayList(); requests.parallelStream().forEach(req -> { String resp = //some process to get (Always return string) resplist.add(resp); }); asyncResponse.resume(resplist); } If I use parallelStream sometimes the list that is retrieved

How can I exclude null fields form my JSON request in Jersey?

ε祈祈猫儿з 提交于 2019-12-22 10:52:56
问题 What I'm trying to do is to avoid null fields in my request. I use this Jersey dependencies <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.18</version> </dependency> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.17</version> </dependency> <dependency>

How to parse JSON array using Jersey Rest Webservices and Java

自闭症网瘾萝莉.ら 提交于 2019-12-22 10:47:00
问题 I am getting Json array from iOS client and want to parse the Json in server side using Java and jersey and Gson. I am sending the JSON array in POST method from iOS. I want to consume the json but stuck on how do i save the json data in Java class. This is the structure of my Json array { "friendList": [ {"id": 1, "username": "user1", "name":"person1", "friendUsername":"fUser1", "friendName":"fName1"}, {"id": 2, "username": "user2", "name":"person2", "friendUsername":"fUser2", "friendName":

Marshalling of generic types in Jersey

廉价感情. 提交于 2019-12-22 09:10:16
问题 I need to return to client list of few results and total count of results. I have to do it on several places with different entities so I would like to have a generic class with these two attributes: @XmlRootElement public class QueryResult<T> implements Serializable { private int count; private List<T> result; public QueryResult() { } public void setCount(int count) { this.count = count; } public void setResult(List<T> result) { this.result = result; } public int getCount() { return count; }

Rest Filter : registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime

大兔子大兔子 提交于 2019-12-22 08:51:59
问题 I am getting an error : A provider com.xyx.in.astra.aqr.security.application.requestFilter.UniversalSessionManagerFilter registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider com.xyx.in.astra.aqr.security.application.requestFilter.UniversalSessionManagerFilter will be ignored. NOTE : 1) This UniversalSessionManagerFilter filter is in external jar file which is in the server classpath 2) I

Jersey rest api security

吃可爱长大的小学妹 提交于 2019-12-22 08:37:01
问题 I see the following link that explains how rest api needs to be secured. (Using public key and a HMAC(hash) of request parameters and private key). http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/ I also see this link in stackoverflow which talks about rest api security using spring combining spring security 3 with jersey rest api I see this link in oracle weblogic website that talks about restful api security using web.xml or security context etc http:/

Accept comma separated value in REST Webservice

隐身守侯 提交于 2019-12-22 08:23:34
问题 I am trying to receive a list of String as comma separated value in the REST URI ( sample : http://localhost:8080/com.vogella.jersey.first/rest/todo/test/1/abc,test , where abc and test are the comma separated values passed in). Currently I am getting this value as string and then splitting it to get the individual values. Current code : @Path("/todo") public class TodoResource { // This method is called if XMLis request @GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }

Jersey UniformInterfaceException trying to proxy to REST POST service

一个人想着一个人 提交于 2019-12-22 08:18:25
问题 I keep receiving a 406 HTTP response when I try to execute code structured in this way. I have tried restructuring the code and the inputs many times, but I still receive this error, and I've gotten to the point I don't even really know what to debug. The exception seems to indicate that the post() method isn't supplying the @FormParam s in the desired format, but as you can see the .accept(MediaType.APPLICATION_FORM_URLENCODED) and the @Consumes(MediaType.APPLICATION_FORM_URLENCODED) do

URI-specific ExceptionMapper in JAX-RS

試著忘記壹切 提交于 2019-12-22 06:55:34
问题 I'm using Jersey, and Guice as my IOC-container. I'd like to know if it is possible to associate an ExceptionMapper with a specific URI. The reason for this is that I want to map the same exception differently based on what URI was visited. For example, suppose I've got the following two exception mappers for my custom exception: public class MyExceptionMapperForFirstURI implements ExceptionMapper<MyException> {..return response based on first URI..} public class MyExceptionMapperForSecondURI