tomee-users mailing list archives

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

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

then i get
Caused by:
javax.enterprise.inject.IllegalProductException - WebBeans producer : 
keycloakSecurityContext return type in the component implementation 
class : scope type must 
be @Dependent to create null instance

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
Annotated producer method : public org.keycloak.KeycloakSecurityContext declare 
default @Scope annotation

View raw message