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 Re: @Produces returning null
Date Mon, 27 Nov 2017 10:41:37 GMT
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

On 27/11/2017 11:31, Romain Manni-Bucau wrote:
> Loops in you generic usages?
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>
>
> 2017-11-27 11:29 GMT+01:00 Matthew Broadhead <matthew.broadhead@nbmlaw.co.uk>:
>> 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)|
>>
>>
>>
>>
>> On 27/11/2017 11:09, Romain Manni-Bucau wrote:
>>> 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
>>>
>>>
>>> 2017-11-27 11:02 GMT+01:00 Matthew Broadhead
>>> <matthew.broadhead@nbmlaw.co.uk>:
>>>> 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