jersey-2.0

Jersey @PathParam : contains multiple parameters with no annotation

放肆的年华 提交于 2019-12-11 07:59:53
问题 The following is my method signature which I am using in Jersey , when I debug/run the program I am getting error as : [[FATAL] Method public javax.ws.rs.core.Response com.xxxx.xxxxx.Xxxxx.xxxxx.xxxxxxxx(java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.ContainerRequestContext) on resource class com.xxxxxx.xxxxx.xxxxxx.xxxxxx contains multiple parameters with no annotation. My code: @PUT @Path("/user/{user}/{role}") @Consumes({MediaType.APPLICATION_JSON,MediaType.TEXT

exception in parsing the request after pre-flight request using jersey

天涯浪子 提交于 2019-12-11 07:08:26
问题 We have created the CORS filter as follows: @Provider public class CORSFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException { // TODO: Allow only from *our* Web front response.getHeaders().add("Access-Control-Allow-Origin", "*"); response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept,x-request-id, x-api-key, x-api-secret, authorization"); response

Enabling Jersey trace logging causes MaxHeaderCountExceededException

心已入冬 提交于 2019-12-11 06:58:40
问题 I am trying to debug my jersey 2 app on Payara 162, but on every request, after the trace information is printed I get this exception and the client gets no response: org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException: Illegal attempt to exceed the configured maximum number of headers: 100 at org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:396) at org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:422) at org.glassfish

JerseyTest with shiro

≡放荡痞女 提交于 2019-12-11 05:56:25
问题 Instantiating JerseyTest with this class public class NMAAbstractRestTest extends JerseyTest { @Override protected Application configure() { NMAdaptorApplication application = new NMAdaptorApplication(); return application; } } NMAdaptorApplication constructor. public NMAdaptorApplication() { log.info("NM-Adaptor-Application is being initilized...."); register(NMRestExceptionMapper.class); register(ShiroFeature.class); register(NMMarshallingFeature.class); register(new LoggingFeature(java

How to limit number of threads created on server side in Jersey Restful Web Services?

时间秒杀一切 提交于 2019-12-11 05:46:20
问题 Jersey creates one thread per request. Is it possible to limit number of threads created on server side in Jersey Restful Web Services? Firstly, i created a resource containing 4 methods viz., create, update, delete, read to perform operations on database. Then i wrote a shell script which creates 10 process asynchronously and each process performs 100 sets(1 set = Create() + Update()+ delete() + read()) of CURD operations using cURL requests which were not asynchronous as i had to calculate

Unsupported Media Type error in Jersey API

若如初见. 提交于 2019-12-11 05:39:34
问题 I have seen multiple answers on stackoverflow and yet unable to identify what is wrong with my pom.xml. I have to upload files on the server, so I am using the modified code from FormDataMultiPart of this link I have the code as: import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import javax

How to set an object to context so that i can get it anywhere in the application with @Context

廉价感情. 提交于 2019-12-11 05:38:41
问题 I want to set MyObject class instance to the application context so that I can use it anywhere with the following: @Context MyObject object I used Jedis which gives me access for the jedis through the above approach. Please help in setting the context. I am using dropwizard (jetty,jersery and jackson) . 回答1: I had some time and wrote up the way to do it (jersey only, no other DI framework used). Jersey is compliant with javax.inject annotations. The reason you do NOT use a context annotation

Using Jersey with Grizzly

≡放荡痞女 提交于 2019-12-11 05:31:47
问题 I want to create a simple REST service, and for that I am using Jersey and Grizzly. Here is my Service class: @Path("/service") class TestRESTService { @GET @Path("test") @Produces(Array(MediaType.APPLICATION_JSON)) public String test() { return "{ \"TestField\" : \"TestValue\" }"; } } And from what I understand here is how I supposed to start it: ResourceConfig config = new ResourceConfig(); config.registerClasses(TestRESTService.class); URI serverUri = UriBuilder.fromUri("http://localhost/"

Cannot read json from Jersey client Response

被刻印的时光 ゝ 提交于 2019-12-11 04:26:09
问题 I have a Jersey REST service set up like this: @GET @Path(ResourceConstants.PATH_START_BATCH) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public ServiceResponse startBatch(@QueryParam(ResourceConstants.PARAM_BATCH_ID) String batchId) { ServiceResponse serviceResponse = new ServiceResponse(); try { // will throw exception on error this.processorService.startBatch(batchId); Map<String, String> responseDetails = serviceResponse.getResponseDetails(); responseDetails.put(

@Valid not throwing exception

↘锁芯ラ 提交于 2019-12-11 03:54:51
问题 I'm trying to validate my JPA Entity with @Valid like this: public static void persist(@Valid Object o) It worked fine for a while but now it stopped working and I'm not sure why. I tried to do it manually inside the persist method, and it works as expected: ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<Object>> constraintViolations = validator.validate(o); if (!constraintViolations.isEmpty()) {