I have a class that perform as a class producers within my rest services which is so made:
public class WebResources{
@Produces
@RequestScoped
public FacesContext produceFacesContext() {
return FacesContext.getCurrentInstance();
}
@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}
Now I wish to produce an object of mine by using HttpServletRequest or HttpSession as a parameter. Something like this:
@Produces
@RequestScoped
public MyObject getSecurityContext(InjectionPoint injectionPoint)
{
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
return Utils.getMyObject(request);
}
The error I receive on deploy phase is the following:
ERROR [org.jboss.as.cli.CommandContext] {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"zuora.ear\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"zuora.ear\".WeldStartService: Failed to start service Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-001406 Cannot inject [parameter 1] of [method] @Produces @RequestScoped public it.infocert.zuora.rest.util.WebResources.getSecurityContext(InjectionPoint) in a non @Dependent scoped bean"}} {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"zuora.ear\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"zuora.ear\".WeldStartService: Failed to start service Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-001406 Cannot inject [parameter 1] of [method] @Produces @RequestScoped public it.info
HttpServletRequest
with CDI >= 1.1 – chkal