tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Broadhead <matthew.broadh...@nbmlaw.co.uk>
Subject @Produces returning null
Date Mon, 27 Nov 2017 10:02:41 GMT
if @Produces can produce null e.g.

@Produces
@Default
@RequestScoped
public KeycloakSecurityContext keycloakSecurityContext() {
     if (httpServletRequest.getUserPrincipal() instanceof 
KeycloakPrincipal) {
         KeycloakPrincipal<KeycloakSecurityContext> keycloakPrincipal = 
(KeycloakPrincipal<KeycloakSecurityContext>) 
httpServletRequest.getUserPrincipal();
         return keycloakPrincipal.getKeycloakSecurityContext();
     }
     return null;
}

then i get
Caused by:
javax.enterprise.inject.IllegalProductException - WebBeans producer : 
keycloakSecurityContext return type in the component implementation 
class : uk.me.kissy.external.producers.SecurityProducer scope type must 
be @Dependent to create null instance
at 
org.apache.webbeans.util.WebBeansUtil.checkNullInstance(WebBeansUtil.java:902)

I can't add @Dependent to the KeycloakSecurityContext class but if I add 
it to keycloakSecurityContext() i get
org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI Beans 
module deployment failed
  org.apache.webbeans.exception.WebBeansConfigurationException: 
Annotated producer method : public org.keycloak.KeycloakSecurityContext 
uk.me.kissy.external.producers.SecurityProducer.token()must declare 
default @Scope annotation

Mime
View raw message