I am making a Java EE 7 application (war) on Glassfish 4.1.
The application is a simple CRUD app.
For testing CRUD operations I have made a Java SE Client (Using Jersey2 client api).
The strange behaviour is that the HTTP POST Creation does not detect one field of the object:
I have a "birthDate" attribute, which comes "null" always in the server side.
I dont understand why this is happens and how to resolve this?
Here is the dependencies that I am using in the server-side:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.6.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Here is the client side dependencies:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.2</version>
</dependency>
Here is the creation block in client side:
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target("http://localhost:8080/MedicalCenter/rest/customers");
Customer customer = new Customer("Jason", "Bourne", new Date(), "This is description", new ArrayList<Device>());
ObjectMapper mapper = new ObjectMapper();
String mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
result = mapper.writeValueAsString(customer);
Response response = webTarget.request("application/json")
.post(Entity.entity(result, MediaType.APPLICATION_JSON_TYPE));
Here is an example of a sent JSON:
Here is an example {"id":null,
"name":"Jason",
"familyName":"Bourne",
"birthDate":"2015-10-05T21:41:43.044+0000",
"description":"This is description",
"creation":"2015-10-05T21:41:43.044+0000",
"enabled":true,
"system":true,
"version":null,
"devices":[]}
Please help me :) Thank you !!