sebastián scarano [
https://community.jboss.org/people/opensas] created the discussion
"CDI cannot retrieve servlet responde using @Context annotation"
To view the discussion, visit:
https://community.jboss.org/message/742035#742035
--------------------------------------------------------------
I have a jax-rs web service returning json, and I'd like to add cors headers to it.
so I Have the following class:
[...]
import javax.enterprise.context.RequestScoped;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Path;
[...]
@Stateful
@Path("/grupo")
@RequestScoped
@TransactionAttribute
public class GrupoEndpoint
{
@Context
private HttpServletResponse response;
@GET
public List<Grupo> listAll()
{
@SuppressWarnings("unchecked")
final List<Grupo> results = em.createQuery("SELECT x FROM Grupo
x").getResultList();
// here response is null!!!
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods", "GET, POST,
OPTIONS");
return results;
}
But response is always null, is there something I might be missing?
Ps: I asked the same question on stackoverflow, in case you'd like to improve your SO
reputation ;-)
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/742035#742035]
Start a new discussion in JBoss Web Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]