Skip to main content

RePost question Glassfish 4 JAXRS UTF-8 consomption

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2007-01-26

Worth saying that this works perfectly under WildFly 8.0 but it's a show stopper under Glassfish 4.0:

Am running Jax-RS end-points on Glassfish 4.0 with Backbone MarionetteJS HTML client (uses JQuery internally) so far everything works correctly but when I POST a JSON payload with arabic content it hits the database (Postgres) with wrong encoding. If I directly modify the database row content with arabic content it gets displayed correctly.

Postgres 9.2 database is created with:

In glassfish-resources I have:

In glassfish-web.xml I have:

In the JAX-RS Resource I have:

@Consumes(MediaType.APPLICATION_JSON + ";charset=UTF-8")
public Response createCabinet(@Context UriInfo uriInfo, Cabinet cab) {
Cabinet createdCab = cabinetService.createCabinet(cab);
URI uri = uriInfo.getAbsolutePathBuilder().path(createdCab.getId()).build();
return Response.created(uri).build();

@Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
public Response getCabinets(@QueryParam("from") @DefaultValue("0") int from,
@QueryParam("to") @DefaultValue("10") int to) {
List cabinets = cabinetService.getCabinets(from, to);
GenericEntity> entity = new GenericEntity>(cabinets){};
return Response.ok(entity).build();

SO question:

Thanks in advance,