jersey-2.0

Generating Swagger documentation from existing REST api

不打扰是莪最后的温柔 提交于 2019-12-21 06:38:30
问题 Given an existing JAX-RS-annotated API that accepts & returns json, with jackson-annotated types, is there a way that I can generate some YAML Swagger documentation? My plan B is to write some code that uses reflection to find REST-annotated types, make a hashmap of their arguments & returns, and then crawl those classes for Jackson annotations, and generate the documentation that way. I would prefer to use a solution that already exists to writing a one-off thing. I found this Swagger module

Connection reset on Jersey with Java 7

会有一股神秘感。 提交于 2019-12-21 06:12:09
问题 I'm trying to call an https link with the webTarget of jersey 2.22.2. The code is that: Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target(uri); MultivaluedMap<String, Object> headers = new MultivaluedHashMap<String, Object>(); headers.add("Content-Type", "application/json"); headers.add("id", id); headers.add("key", key); Response response = target.request().headers(headers).get(Response.class); In Java 8 it's work great, but in Java 7 it's give me this

Register ServletContainer programmatically in Osgi

回眸只為那壹抹淺笑 提交于 2019-12-21 05:14:20
问题 I'm developing a JAX-RS application with OSGI where resources are loaded dynamically. For this, I need to register the ServletContainer programmatically, then I can call the method ServletContainer.reload (ResourceConfig). I'm running on OSGI environment with support for servlet 3.x, using PAX-WEB 3.0.2 and Jersey 2.4. The problem is when I want to access a resource that implements Server Sent Event, Jersey raises an error that does not support asynchrony because it runs in a Servlet 2.x.

Jersey 2.7 - setting retry handler

我与影子孤独终老i 提交于 2019-12-21 05:02:31
问题 I would like to set a retry handler for Jersey client utilizing ApacheConnector . I wish to do it, because I want it to retry on timeout (my HAProxy will switch it to another server). I have no clue how to do this in Jersey 2.7 . Example code: public static void Example() { ClientConfig clientConfig = new ClientConfig(); clientConfig.connectorProvider(new ApacheConnectorProvider()); clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, new PoolingHttpClientConnectionManager());

Registering JacksonJsonProvider with ObjectMapper + JavaTimeModule to Jersey 2 Client

你离开我真会死。 提交于 2019-12-21 04:05:43
问题 I'm trying to marshal response containing ISO formatted timestamp like that: { ... "time" : "2014-07-02T04:00:00.000000Z" ... } into ZonedDateTime field in my domain model object. Eventually it works if I use solution that is commented in following snippet.There are many similar questions on SO but I would like to get a specific answer what is wrong with another approach which uses JacksonJsonProvider with ObjectMapper + JavaTimeModule ? ObjectMapper mapper = new ObjectMapper(); mapper

AngularJS Client, JAX-RS Jersey Rest Service - application/json client request throwing 'Error parsing media type'

。_饼干妹妹 提交于 2019-12-21 02:55:22
问题 I am using the below AngularJS client code to perform a HTTP post request with JSON formatted payload to the jersey rest service patientMgmtModule.controller('NewPatientCtrl', function NewPatientCtrl($scope, $http) { $scope.addPatient = function (){ var patientJSON = angular.toJson($scope.Patient); console.log("Patient (JSON) is ============> " + patientJSON); $http({ method: 'POST', data: $scope.Patient, url:'/ManagePatient/AddPatient', headers: {'Content-Type':'application/x-www-form

How do I migrate from Jersey 1.0 to Jersey 2.0?

旧时模样 提交于 2019-12-20 11:22:31
问题 I'm trying to upgrade to Jersey 2.0 and I'm having a lot of trouble because the groupIds and artifactIds of Jersey have completely changed and I can't find a migration plan in the Jersey docs. Here's what my pom.xml used to look like, and this compiled fine: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.17</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> <version>1.17</version>

How do I migrate from Jersey 1.0 to Jersey 2.0?

你。 提交于 2019-12-20 11:22:30
问题 I'm trying to upgrade to Jersey 2.0 and I'm having a lot of trouble because the groupIds and artifactIds of Jersey have completely changed and I can't find a migration plan in the Jersey docs. Here's what my pom.xml used to look like, and this compiled fine: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.17</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> <version>1.17</version>

How to use guice-servlet with Jersey 2.0?

白昼怎懂夜的黑 提交于 2019-12-20 10:33:27
问题 Is there any sample code demonstrating how to use guice-servlet with Jersey 2.0? 回答1: https://github.com/Squarespace/jersey2-guice seems to be the first genuine Guice integration for Jersey 2 but it requires version 2.11+. NOTE : I haven't tested this, but the idea is sound. 回答2: Yes, I've adapted an example and it's available here - https://github.com/piersy/jersey2-guice-example-with-test I've updated the example code now, its got a test using jetty and another using tomcat. 回答3: There is a

Spring-Boot Jersey: allow Jersey to serve static content

时间秒杀一切 提交于 2019-12-20 07:34:57
问题 The application uses JDK 8, Spring Boot & Spring Boot Jersey starter and is packaged as a WAR (although it is locally run via Spring Boot Maven plugin). What I would like to do is to get the documentation I generate on the fly (at build time) as a welcome page. I tried several approaches: letting Jersey serving the static contents by configuring in application.properties the proper init parameter as described here introduce a metadata-complete=false web.xml in order to list the generated HTML