jax-rs

“The request sent by the client was syntactically incorrect.” — bad Content-Type

走远了吗. 提交于 2019-12-25 16:46:24
问题 While sending some test requests to a JAX-RS REST server, I got back a 400 - Bad Request The request sent by the client was syntactically incorrect. The request was PUT http://localhost:8080/some/url Content-Type: text-plain foo 回答1: Content-Type: text-plain is a typo and a bad MIME type. It should be Content-type: text/plain This was a bit of a head-scratcher for a while. 来源: https://stackoverflow.com/questions/27929825/the-request-sent-by-the-client-was-syntactically-incorrect-bad-content

test serializations REST JAXRS

[亡魂溺海] 提交于 2019-12-25 14:09:15
问题 I'm built REST services using JAXRS. I'd like to test how JAXRS implementation serializes the body content of each request, and be able to provide some test examples in order to check the body content is serialized correctly. For example: public void createOrUpdate(FollowUpActivityDTO dto) throws RepositorySystemException { } I'm using jackson provider in order to do that: compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.5.3' I'd like to provide

test serializations REST JAXRS

余生长醉 提交于 2019-12-25 14:08:26
问题 I'm built REST services using JAXRS. I'd like to test how JAXRS implementation serializes the body content of each request, and be able to provide some test examples in order to check the body content is serialized correctly. For example: public void createOrUpdate(FollowUpActivityDTO dto) throws RepositorySystemException { } I'm using jackson provider in order to do that: compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.5.3' I'd like to provide

Inject EJB into JAX-RS 2.0 subresource when subresource is got via ResourceContext

断了今生、忘了曾经 提交于 2019-12-25 12:52:48
问题 I am using Jersey 2.8 with Glassfish 4.0. I have a resource locator class which looks like below @Path("/") @ManagedBean public class MyServiceLocator { @Context ResourceContext rc;//javax.ws.rs.container.ResourceContext @EJB private MyEJBHome myEJB; @Inject//javax.inject.Inject MySubService mss; @Path("/mysubservice") public MySubService getMySubService() { return rc.getResource(MySubService.class); //also tried return rc.initResource(new MySubService()); } } and a sub resource class which

Inject EJB into JAX-RS 2.0 subresource when subresource is got via ResourceContext

跟風遠走 提交于 2019-12-25 12:51:27
问题 I am using Jersey 2.8 with Glassfish 4.0. I have a resource locator class which looks like below @Path("/") @ManagedBean public class MyServiceLocator { @Context ResourceContext rc;//javax.ws.rs.container.ResourceContext @EJB private MyEJBHome myEJB; @Inject//javax.inject.Inject MySubService mss; @Path("/mysubservice") public MySubService getMySubService() { return rc.getResource(MySubService.class); //also tried return rc.initResource(new MySubService()); } } and a sub resource class which

@JsonIgnore is not working in the Swagger JSON generation when using jaxrs-analyzer

荒凉一梦 提交于 2019-12-25 11:26:11
问题 I'm using jaxrs-analyzer to generate Swagger JSON docs. In my POJO classes I have added @JsonIgnore annotation to skip them in the JSON doc, but I still see that portion in my swagger JSON doc, which then causes the following issue when loading Swagger UI: swagger.js:744 Uncaught TypeError: Cannot read property '$ref' of undefined` @JsonIgnore public Set<HistoryTankSystem> getHistoryStatusSet() { return historyStatusSet; } "historyStatusSet" : { "type": "array", "items": { "$ref":

Extract specific node of JSON response in RESTEasy Client

怎甘沉沦 提交于 2019-12-25 09:05:11
问题 I'm retrieving a JSON string from an API using a RESTEasy client. The JSON payload looks something like this: { "foo1" : "", "foo2" : "", "_bar" : { "items" : [ { "id" : 1 , "name" : "foo", "foo" : "bar" }, { "id" : 2 , "name" : "foo", "foo" : "bar" }, { "id" : 3 , "name" : "foo", "foo" : "bar" }, { "id" : 4 , "name" : "foo", "foo" : "bar" } ] } } Now I'd like to extract only the items node for object mapping. What is the best way to intercept the JSON response body and modify it to have

Jersey JAX-RS, Hibernate and LazyInitializationException

微笑、不失礼 提交于 2019-12-25 08:25:28
问题 I am working on a Java EE 6.0 RESTful app and I am using Hibernate. I need to de-proxy my lazy loaded objects(actually the lazy loaded entity properties of an entity) before serialization to avoid the LazyInitializationException. I have done this with AMF services successfully by coding some utility that does just that before serializing the entity. I am using the Jersey JAX-RS implementation and I need to do this with Jackson. I have found a spot in the BeanSerializer where I believed the de

java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J

半城伤御伤魂 提交于 2019-12-25 08:08:11
问题 I am using arquillian to do integration tests against a Restful java API, these tests are executed using @RunAsClient annotation, the application is deployed on Wildfly 9. The application tests were working but suddenly brake. I am getting this error: javax.ws.rs.ProcessingException: org.glassfish.jersey.client.ClientRequest.getLengthLong()J that seems to be caused by this one: Caused by: java.lang.NoSuchMethodError: org.glassfish.jersey.client.ClientRequest.getLengthLong()J A piece of code:

Injection CDI of Interface Returns NullPointerException

女生的网名这么多〃 提交于 2019-12-25 07:59:26
问题 I have a problem with the injection in Java as I would like to inject an interface called RemoteStatisticService but it keeps returning null in this case thus error NullPointerException. I have tried to follow this with init() method and @PostConstruct but still gives me the same error. Here is the code for MeasurementAspectService class: import javax.annotation.PostConstruct; import javax.inject.Inject; import *.dto.MeasureDownloadDto; import *.dto.MeasureUploadDto; import *.rs