[ 
https://issues.apache.org/jira/browse/MYFACES-4127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16104993#comment-16104993
 ] 

Dora Rajappan commented on MYFACES-4127:
----------------------------------------

If the  
FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlowScope()
 returns null for various reasons (includes invalid declarations such as 
postconstruct method in which case session will be null, or when its not inside 
a flow window will be null ); cdi throws the said exception. How to notify CDI 
whats the reason for the nulls will solve the problem. Need to throw 
appropriate exceptions from getCurrentFlowScope method so cdi can capture it 
show meaningful exception to the user.

> Unexpected exception thrown when FlowMap is injected on a RequestScoped bean
> ----------------------------------------------------------------------------
>
>                 Key: MYFACES-4127
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4127
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.3.0-beta
>            Reporter: Eduardo Breijo
>            Priority: Minor
>         Attachments: ConfigItems.java
>
>
> When @FlowMap is injected on a RequestScoped bean, and you try to use that 
> object (which should be null since we are not inside of a flow), an 
> unexpected exception is thrown. This was noted after JIRA issue: 
> https://issues.apache.org/jira/browse/MYFACES-4126
> Caused by: org.jboss.weld.exceptions.IllegalProductException: WELD-000052: 
> Cannot return null from a non-dependent producer method: Producer for 
> Producer Method [Map<Object, Object>] with qualifiers [@FlowMap @Any] 
> declared as [[UnbackedAnnotatedMethod] @Produces @FlowMap @ApplicationScoped 
> public 
> org.apache.myfaces.cdi.faces.ApplicationScopeObjectProducer.getFlowMap()] 
> declared on Managed Bean [class 
> org.apache.myfaces.cdi.faces.ApplicationScopeObjectProducer] with qualifiers 
> [@Any @Default]
>       at 
> org.apache.myfaces.cdi.faces.ApplicationScopeObjectProducer.getFlowMap(ApplicationScopeObjectProducer.java:73)
>   StackTrace:
>       at 
> org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:136)
>       at [internal classes]
>       at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
>       at 
> org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
>       at [internal classes]
>       at java.lang.String.valueOf(String.java:2994)
>       at java.lang.StringBuilder.append(StringBuilder.java:131)
>       at 
> com.ibm.ws.jsf23.fat.beans.ELImplicitObjectBean.execute(ELImplicitObjectBean.java:163)
> On Mojarra 2.3, we get a different exception which looks more appropriate.
> org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active 
> contexts for scope type javax.faces.flow.FlowScoped
>       
> org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:623)
>       
> org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:89)
>       
> org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
>       
> org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:87)
>       
> org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
>       
> org.jboss.weld.util.Map$1302817811$Proxy$_$$_WeldClientProxy.toString(Unknown 
> Source)
>       java.lang.String.valueOf(String.java:2994)
>       java.lang.StringBuilder.append(StringBuilder.java:131)
>       
> com.ibm.ws.jsf23.fat.beans.ELImplicitObjectBean.execute(ELImplicitObjectBean.java:163)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to