jersey

Unmarshalling with multiple namespaces

て烟熏妆下的殇ゞ 提交于 2019-12-10 20:12:49
问题 So, lets say I have this xml with several namespaces. <Envelope xmlns:pdi="http://www.mypage.com/schemas/pdi" xmlns:ib="http://www.mypage.com/schemas/ib" xmlns="http://www.mypage.com/schemas/envelope"> <Product> <pdi:number>123456</pdi:number> </Product> <Instance> <ib:serial>abcdefg</ib:serial> </Instance> </Envelope> I'm trying to build a client for it. I have an Envelope POJO that's declared like this @XmlRootElement(name ="Envelope", namespace = "http://www.mypage.com/schemas/envelope")

grizzly logs to stderr, annoying in eclipse

时间秒杀一切 提交于 2019-12-10 19:54:52
问题 When i run my junit jersey service tests using the grizzly framework in eclipse, the log is directed to stderr. As a result the console window grabs focus, and the log appears red. I can't figure out the proper configuration steps. From my reading it looks like i need to add the slf4j.jar to my pom.xml and add a logging properties file somewhere? But i'm unsure which slf4j jars to add (there are many) or where to place the logging properties file. Or, frankly, if this is the right approach in

Jersey - Register ExceptionMapper for Resource Methods

时间秒杀一切 提交于 2019-12-10 19:48:43
问题 The question Exception Handling/Mapping for a particular class brought me to the question of how to register an ExceptionMapper to a particular resource Method . I've tried to use a DynamicFeature like this: DynamicFeature @Provider public class ExceptionMapperDynamicFeature implements DynamicFeature { @Override public void configure(final ResourceInfo resourceInfo, final FeatureContext context) { if(!resourceInfo.getResourceMethod().isAnnotationPresent(BindExceptionMapper.class)) return;

415 Status when trying to send FormData() in Jax-RS jersey

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 19:47:12
问题 I'm trying to send files which is appended to FormData using jquery ajax. After referring some of mozilla and IBM's documents, I've came up with following. ajax code: var sessionId = $.cookie("referenceId"); var myFormData = { sessionId: sessionId, cipherData: cipherData, // Encrypted xml data payslip: document.getElementById('payslip').files[0]}; var formData = new FormData(); for (var key in myFormData) { console.log(key, myFormData[key]); formData.append(key, myFormData[key]); } $.ajax({

Session management in Dropwizard 0.8.x

怎甘沉沦 提交于 2019-12-10 19:40:19
问题 Can someone give me insight of how do I implement session management in Dropwizard 0.8.x or above. I was using Dropwizard 0.7.0 till now and working perfectly in it. But I really confused by change docs provided when I migrated to 0.8.x. In Dropwizard 0.7.0 (which I was using previously) it was done like the following /*MainApplication.class session handler */ environment.jersey().register(HttpSessionProvider.class); environment.servlets().setSessionHandler(new SessionHandler()); /*Resource

Jersey Unit Tests without HTTP Server

旧时模样 提交于 2019-12-10 19:29:45
问题 I would like to setup a very lightweight jersey unit-test. My webservice produces JSON result which I want to validate directly without using a HTTP-Server. Is it possible to create lighweight jsersey tests without using a HTTP-Server like Grizzly HTTP? 回答1: Not sure what version of Jersey you are using, but look into Jersey Test Framework. There is an in-memory container, that doesn't involve any network connection. Here's a documentation Jersey 2.x Test Framework Jersey 1.x Test Framework

Guice nullpointer exception on injected instance

六眼飞鱼酱① 提交于 2019-12-10 18:46:51
问题 I'm using Guice in Jersey2 for DI (i want to use it so i can use Google App Engine -> not working with HK2). My ApplicationResource: public class ApplicationResource extends ResourceConfig { private static final Logger LOGGER = null; public ApplicationResource() { System.out.println("Application startup"); // Register resources and providers using package-scanning. packages("com.crawler.c_api"); // Register my custom provider - not needed if it's in my.package. register(ResponseCorsFilter

Could not find MessageBodyWriter for response object of type: com.sun.jersey.api.json.JSONWithPadding of media type: application/x-javascript

不想你离开。 提交于 2019-12-10 18:44:29
问题 I'm trying to use jsonp on my backbone application. In my webservice, I'm trying to use the Jersey library to use the JSONWithPadding response. Problem is, looks like the "application/x-javascript" is not supported. My code is : @GET @Path("/issues/jsonp") @Produces("application/x-javascript") public JSONWithPadding getIssuesJsonp(@Context HttpServletRequest req, @PathParam("ppid") String qppid, @QueryParam("callback") String callback) { Principal principal = req.getUserPrincipal(); String

Angular JS post object to Jersey is null

不想你离开。 提交于 2019-12-10 18:20:49
问题 I am trying to post my form data to my rest service using angular js and jersey. However the bean received at the rest service is null. Following is my angular code for the POST request. (function() { var dataUrls = { addSurveyUrl : '/CompanySurveyPortal/Company/Surveys/addSurvey' } angular.module('addNewSurvey', []).service('addSurveyDataService', function($http) { this.addNewSurvey = function(survey) { return $http.post(dataUrls.addSurveyUrl, {"surveyId": survey.surveyId, "title": survey

Why is Jersey/JAX-RS client unable to handle generics?

折月煮酒 提交于 2019-12-10 18:16:19
问题 I have a Jersery/JAX-RS client that hits a RESTful API (JSON) that is supposed to return a list of my POJOs: // Hits: GET localhost:8080/myapp/fizz/widget/{widget_id} @Override public List<Widget> getWidgetsByUser(Long id) { return webResource.path("fizz").path("widget").path(id.toString()).get(List.class); } And a driver to test the client with: public class Driver { public static void main(String[] args) { Driver d = new Driver(); d.run(); } public void run() { MyAppService myService =