jersey

Jersey 2 singleton dependency injection creates multiple instances

落爺英雄遲暮 提交于 2020-01-13 19:07:32
问题 Here I have a singleton, that I whant to inject to my application @Singleton @Path("singleton-bean") public class MyContext { private MyContext() { instances++; } private static MyContext instance; public static MyContext getInstance(){ if (instance == null) instance = new MyContext(); return instance; } public static int instances = 0; } Here's how I register it: @ApplicationPath("webresources") public class ApplicationConfig extends Application { @Override public Set<Object> getSingletons()

WARNING: Provider com.sun.xml.internal.bind.v2.ContextFactory not found

空扰寡人 提交于 2020-01-13 10:34:08
问题 I have integrated within a JSF app a few webservices through Jersey . Everything works fine, even the OAuth identification is working. BUT! When starting my webserver, I ALWAYS get this error : INFO: Scanning for root resource and provider classes in the packages: com.mysite.webService INFO: Root resource classes found: class com.mysite.webService.Accounts INFO: No provider classes found. INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM' SEVERE: The provider

WARNING: Provider com.sun.xml.internal.bind.v2.ContextFactory not found

情到浓时终转凉″ 提交于 2020-01-13 10:33:33
问题 I have integrated within a JSF app a few webservices through Jersey . Everything works fine, even the OAuth identification is working. BUT! When starting my webserver, I ALWAYS get this error : INFO: Scanning for root resource and provider classes in the packages: com.mysite.webService INFO: Root resource classes found: class com.mysite.webService.Accounts INFO: No provider classes found. INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM' SEVERE: The provider

Difference between ResourceConfig and ServletContextListener for Jersey Rest Service

孤人 提交于 2020-01-13 02:13:13
问题 I want to initialize a Jersey Rest service and introduce a global application-wide variable which should be calculated at application start up-time and should be available in each rest resource and each method (here indicated by the integer globalAppValue=17, but will be a complex object later). In order to initialize the service and calculate the value once at start up I found two practices: The general ServletContextListener and the Jersey ResourceConfig method. But I have not understood

SecurityContext doesn't work with @RolesAllowed

匆匆过客 提交于 2020-01-12 19:13:09
问题 I'm currently creating a backend server using Jersey 2.5.1 in a Tomcat 7. For the security I'm using the @RolesAllowed , @PermitAll etc. annotations, and I have created my custom ContainerRequestFilter and SecurityContext . My problem is that when my @RolesAllowed annotated resource is requested it always denies permission, even if I force my isUserInRole(role) method to return true . However, my filter method gets called. Do you have any suggestions? I'll paste some relevant code below. My

Multiple JAX-RS applications in the same WAR

蓝咒 提交于 2020-01-12 05:41:25
问题 I have @ApplicationPath("/resourcesP") public class RestfulPrediction extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> set = new HashSet<Class<?>>(); set.add(PredictionsRS.class); return set; } } And @ApplicationPath("/resourcesA") public class RestfulAdage extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> set = new HashSet<Class<?>>(); set.add(Adages.class); return set; } } Two different ApplicationPath and the class are as

How do I get the JAX-RS @Path of a different resource during a POST?

早过忘川 提交于 2020-01-11 19:50:29
问题 I have two REST classes for a simple web service (Jersey and GlassFish) that involves user resources - one to operate on all users (e.g., a factory for @POSTing) and another on individual users (e.g., @GET, @PUT, @DELETE). They are at: @Stateless @Path("users") public class AllUsersResource {...} @Stateless @Path("user") public class OneUserResource {...} respectively. When POSTing to AllUsersResource I want to return the Location (via Response.created(uri).build() ) of the new User, e.g.,

Receive zip file, angularJs

做~自己de王妃 提交于 2020-01-11 14:46:09
问题 I've got a problem when I want to download a zip file from a Rest api, When the zip file is tranfered from my server (with jersey), I receive it corrupted, ... I've already tried to put responseType: 'arraybuffer' on my $http request but it isn't fixing anything... here's my code. $http.get(uploadUrl, { cache: false, responseType: 'arraybuffer' }) .success(function (data, $scope) { var element = angular.element('<a/>'); console.debug("data : " + data); element.attr({ href: 'data:application

Cross domain put call does not work with Access-Control-Allow-Origin

自作多情 提交于 2020-01-11 13:19:53
问题 I am facing problem related to cross domain PUT call , i have allowed Access-Control-Allow-Origin from server side put still it doesn't work. @PUT @Path("/getresponse/{caller}") @Produces({MediaType.APPLICATION_JSON}) public Response getResponseData(@PathParam("caller") String caller ,@QueryParam("ticket")String ticket ,@FormParam("formParam") String data){ ResponseBuilder resp; System.out.println("name of caller is -> "+ caller); System.out.println("query param ticket -> "+ ticket); System

Jersey Sub-Resource Locators Error

醉酒当歌 提交于 2020-01-11 12:32:19
问题 I'm trying to get the JSR-311 plugin working with Grails 2.3.7. I'm using version 0.10, because I think 0.11 requires Grails 2.4. I've used the generate-resource command to create an end point for my domain class Product . Two resource classes are created, ProductCollectionResource and ProductResource . I've tweaked them a bit, but essentially they look like this: ProductCollectionResource @Path('/api/products') @Consumes(['application/json']) @Produces(['application/json']) class