Buggy code:
@ Path ( "//certificateVS" ) public class CertificateVSResource { private static final Logger log = Logger . getLogger ( CertificateVSResource . class . getSimpleName ( ) ) ; @ Inject ConfigVS app ; @ Inject DAOBean dao ; @ Inject SignatureBean signatureBean ; @ Inject CertificateVSBean certificateVSBean ; @ Path ( "//hashHex//{hashHex}" ) @ GET @ Produces ( MediaType . TEXT_PLAIN ) public Response hashHex ( @ PathParam ( "hashHex" ) String hashHex , @ Context Request req , @ Context HttpServletResponse resp ) throws Exception { } @ Path ( "//userVS//id//{userId}" ) @ GET @ Produces ( MediaType . TEXT_PLAIN ) public Response userVS ( @ PathParam ( "userId" ) long userId , @ Context Request req , @ Context HttpServletResponse resp ) throws Exception { } @ Path ( "//editCert" ) @ POST @ Produces ( MediaType . APPLICATION_JSON ) public Response editCert ( MessageSMIME messageSMIME , @ Context HttpServletRequest req , @ Context HttpServletResponse resp ) throws Exception { } @ Transactional @ Path ( "//certs" ) @ GET @ Produces ( MediaType . APPLICATION_JSON ) public Response certs ( @ DefaultValue ( "0" ) @ QueryParam ( "offset" ) int offset , @ DefaultValue ( "100" ) @ QueryParam ( "max" ) int max , @ DefaultValue ( "USER" ) @ QueryParam ( "type" ) String typeStr , @ DefaultValue ( "OK" ) @ QueryParam ( "state" ) String stateStr , @ DefaultValue ( "" ) @ QueryParam ( "format" ) String format , @ QueryParam ( "searchText" ) String searchText , @ Context ServletContext context , @ Context HttpServletRequest req , @ Context HttpServletResponse resp ) throws Exception { String contentType = ( ( req . getContentType ( ) ) != null ) ? req . getContentType ( ) : "" ; CertificateVS . Type type = Type . valueOf ( typeStr ) ; CertificateVS . State state = State . valueOf ( stateStr ) ; Query query ; Long totalCount = null ; if ( searchText == null ) { query = dao . getEM ( ) . createQuery ( "select<seq2seq4repair_space>count(c)<seq2seq4repair_space>from<seq2seq4repair_space>CertificateVS<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>c.type<seq2seq4repair_space>=:type<seq2seq4repair_space>and<seq2seq4repair_space>c.state<seq2seq4repair_space>=:state" ) . setParameter ( "type" , type ) . setParameter ( "state" , state ) ; totalCount = ( ( long ) ( query . getSingleResult ( ) ) ) ; query = dao . getEM ( ) . createQuery ( "select<seq2seq4repair_space>c<seq2seq4repair_space>from<seq2seq4repair_space>CertificateVS<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>c.type<seq2seq4repair_space>=:type<seq2seq4repair_space>and<seq2seq4repair_space>c.state<seq2seq4repair_space>=:state" ) . setParameter ( "type" , type ) . setParameter ( "state" , state ) . setFirstResult ( offset ) . setMaxResults ( max ) ; } else { query = dao . getEM ( ) . createQuery ( ( "select<seq2seq4repair_space>count<seq2seq4repair_space>(c)<seq2seq4repair_space>from<seq2seq4repair_space>CertificateVS<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>c.type<seq2seq4repair_space>=:type<seq2seq4repair_space>and<seq2seq4repair_space>c.state<seq2seq4repair_space>=:state<seq2seq4repair_space>" + ( ( "and<seq2seq4repair_space>(c.userVS.name<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>or<seq2seq4repair_space>c.userVS.nif<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>" + "or<seq2seq4repair_space>c.userVS.firstName<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>or<seq2seq4repair_space>c.userVS.lastName<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>" ) + "or<seq2seq4repair_space>c.userVS.description<seq2seq4repair_space>like<seq2seq4repair_space>:searchText)" ) ) ) . setParameter ( "type" , type ) . setParameter ( "state" , state ) . setParameter ( "searchText" , ( ( "%" + searchText ) + "%" ) ) ; totalCount = ( ( long ) ( query . getSingleResult ( ) ) ) ; query = dao . getEM ( ) . createQuery ( ( "select<seq2seq4repair_space>c<seq2seq4repair_space>from<seq2seq4repair_space>CertificateVS<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>c.type<seq2seq4repair_space>=:type<seq2seq4repair_space>and<seq2seq4repair_space>c.state<seq2seq4repair_space>=:state<seq2seq4repair_space>" + ( ( "and<seq2seq4repair_space>(c.userVS.name<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>or<seq2seq4repair_space>c.userVS.nif<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>" + "or<seq2seq4repair_space>c.userVS.firstName<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>or<seq2seq4repair_space>c.userVS.lastName<seq2seq4repair_space>like<seq2seq4repair_space>:searchText<seq2seq4repair_space>" ) + "or<seq2seq4repair_space>c.userVS.description<seq2seq4repair_space>like<seq2seq4repair_space>:searchText)" ) ) ) . setParameter ( "type" , type ) . setParameter ( "state" , state ) . setParameter ( "searchText" , ( ( "%" + searchText ) + "%" ) ) . setFirstResult ( offset ) . setMaxResults ( max ) ; } List < CertificateVS > certificates = query . getResultList ( ) ; if ( contentType . contains ( "pem" ) ) { List < X509Certificate > resultList = new ArrayList < > ( ) ; for ( CertificateVS certificateVS : certificates ) { resultList . add ( certificateVS . getX509Cert ( ) ) ; } return Response . ok ( ) . entity ( CertUtils . getPEMEncoded ( resultList ) ) . build ( ) ; } else { List < CertificateVSDto > listDto = new ArrayList < > ( ) ; for ( CertificateVS certificateVS : certificates ) { listDto . add ( new CertificateVSDto ( certificateVS ) ) ; } ResultListDto < CertificateVSDto > resultListDto = new ResultListDto ( listDto , offset , max , totalCount ) ; if ( contentType . contains ( "json" ) ) { return Response . ok ( ) . entity ( JSON . getMapper ( ) . writeValueAsBytes ( resultListDto ) ) . build ( ) ; } else { <START_BUG> req . setAttribute ( "resultListDto" , JSON . getMapper ( ) . writeValueAsString ( resultListDto ) ) ; <END_BUG> context . getRequestDispatcher ( "//certificateVS//certs.xhtml" ) . forward ( req , resp ) ; return Response . ok ( ) . build ( ) ; } } } @ Path ( "//cert//{serialNumber}" ) @ GET @ Produces ( MediaType . APPLICATION_JSON ) @ Transactional public Object cert ( @ PathParam ( "serialNumber" ) long serialNumber , @ Context HttpServletRequest req , @ Context HttpServletResponse resp , @ DefaultValue ( "" ) @ QueryParam ( "format" ) String format , @ Context ServletContext context ) throws Exception { } No newline ; at end ; of file ; }

Fix:
req . setAttribute ( "certListDto" , JSON . getMapper ( ) . writeValueAsString ( resultListDto ) ) ;