Discussion:
@Produces returning null
Matthew Broadhead
2017-11-27 10:02:41 UTC
Permalink
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
Romain Manni-Bucau
2017-11-27 10:09:55 UTC
Permalink
Hi

it looks accurate, a normal scoped instance - request scoped - proxies
a not null instance so you can't return null. Using a @RequestScoped
producer class (the enclosing one) and @Dependent producer can work
too if you inject this context in request scoped instances only.

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
@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
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)
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
Matthew Broadhead
2017-11-27 10:29:40 UTC
Permalink
starts up ok but then on page load i get

|java.lang.StackOverflowError at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:172)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:146)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:117)
at
org.apache.webbeans.util.GenericsUtil.satisfiesDependency(GenericsUtil.java:61)
at
org.apache.webbeans.container.BeanManagerImpl.isBeanTypeAssignableToGivenType(BeanManagerImpl.java:923)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:742)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:84)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:67)
at
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
at
org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
at
org.apache.webbeans.proxy.NormalScopeProxyFactory.unwrapInstance(NormalScopeProxyFactory.java:90)
at
org.apache.webbeans.inject.InjectableMethod.doInjection(InjectableMethod.java:91)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:89)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)|
Post by Romain Manni-Bucau
Hi
it looks accurate, a normal scoped instance - request scoped - proxies
too if you inject this context in request scoped instances only.
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
@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
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)
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
Romain Manni-Bucau
2017-11-27 10:31:02 UTC
Permalink
Loops in you generic usages?

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
starts up ok but then on page load i get
|java.lang.StackOverflowError at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:172)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:146)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:117)
at
org.apache.webbeans.util.GenericsUtil.satisfiesDependency(GenericsUtil.java:61)
at
org.apache.webbeans.container.BeanManagerImpl.isBeanTypeAssignableToGivenType(BeanManagerImpl.java:923)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:742)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:84)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:67) at
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
at
org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
at
org.apache.webbeans.proxy.NormalScopeProxyFactory.unwrapInstance(NormalScopeProxyFactory.java:90)
at
org.apache.webbeans.inject.InjectableMethod.doInjection(InjectableMethod.java:91)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:89)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)|
Post by Romain Manni-Bucau
Hi
it looks accurate, a normal scoped instance - request scoped - proxies
too if you inject this context in request scoped instances only.
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 11:02 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
@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
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)
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
Matthew Broadhead
2017-11-27 10:41:37 UTC
Permalink
looks like it.  another method was injecting the security context, so i
moved it to it own class and now it is working.  changing from
@ApplicationScoped to @RequestScoped must have uncovered the problem.  i
set everything to requestscoped now because all only produce on request
Post by Romain Manni-Bucau
Loops in you generic usages?
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
starts up ok but then on page load i get
|java.lang.StackOverflowError at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:172)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:146)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:117)
at
org.apache.webbeans.util.GenericsUtil.satisfiesDependency(GenericsUtil.java:61)
at
org.apache.webbeans.container.BeanManagerImpl.isBeanTypeAssignableToGivenType(BeanManagerImpl.java:923)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:742)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:84)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:67) at
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
at
org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
at
org.apache.webbeans.proxy.NormalScopeProxyFactory.unwrapInstance(NormalScopeProxyFactory.java:90)
at
org.apache.webbeans.inject.InjectableMethod.doInjection(InjectableMethod.java:91)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:89)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)|
Post by Romain Manni-Bucau
Hi
it looks accurate, a normal scoped instance - request scoped - proxies
too if you inject this context in request scoped instances only.
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 11:02 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
@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
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)
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
Matthew Broadhead
2017-11-27 15:43:42 UTC
Permalink
also i did not realise that @Dependent is a Scope.  so i was declaring
@RequestScoped and @Dependent at the same time
Post by Matthew Broadhead
looks like it.  another method was injecting the security context, so
i moved it to it own class and now it is working.  changing from
@ApplicationScoped to @RequestScoped must have uncovered the problem. 
i set everything to requestscoped now because all only produce on request
Post by Romain Manni-Bucau
Loops in you generic usages?
Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn
2017-11-27 11:29 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
starts up ok but then on page load i get
|java.lang.StackOverflowError at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:172)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:146)
at
org.apache.webbeans.util.GenericsUtil.isAssignableFrom(GenericsUtil.java:117)
at
org.apache.webbeans.util.GenericsUtil.satisfiesDependency(GenericsUtil.java:61)
at
org.apache.webbeans.container.BeanManagerImpl.isBeanTypeAssignableToGivenType(BeanManagerImpl.java:923)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:742)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:84)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)
at
org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:67)
at
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
at
org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
at
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
at
org.apache.webbeans.proxy.NormalScopeProxyFactory.unwrapInstance(NormalScopeProxyFactory.java:90)
at
org.apache.webbeans.inject.InjectableMethod.doInjection(InjectableMethod.java:91)
at
org.apache.webbeans.portable.ProducerMethodProducer.produce(ProducerMethodProducer.java:89)
at
org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:172)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:122)
at
org.apache.webbeans.component.ProducerMethodBean.create(ProducerMethodBean.java:95)
at
org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at
org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at
org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:659)
at
org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:103)
at
org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at
org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:220)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:206)
at
org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:196)
at
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:126)|
Post by Romain Manni-Bucau
Hi
it looks accurate, a normal scoped instance - request scoped - proxies
too if you inject this context in request scoped instances only.
Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn
2017-11-27 11:02 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
@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
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)
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
Loading...