[
https://issues.apache.org/jira/browse/MYFACES-4010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bill Lucy updated MYFACES-4010:
-------------------------------
Resolution: Fixed
Fix Version/s: 2.2.9-SNAPSHOT
Status: Resolved (was: Patch Available)
> MyFaces 2.2 throws UnsupportedOperationException with an eager ManagedBean
> with ManagedProperty
> -----------------------------------------------------------------------------------------------
>
> Key: MYFACES-4010
> URL: https://issues.apache.org/jira/browse/MYFACES-4010
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.2.8
> Environment: Tomcat, WebShere
> Reporter: Bill Lucy
> Assignee: Bill Lucy
> Fix For: 2.2.9-SNAPSHOT
>
> Attachments: myfaces-4010.patch
>
>
> This seems to be a regression from another issue,
> https://issues.apache.org/jira/browse/MYFACES-3116, which was resolved in 2.0
> and 2.1.
> Given a bean similar to the following:
> @ManagedBean(eager=true, name="eagerBean")
> @ApplicationScoped
> public class EagerBean implements Serializable {
> private static final long serialVersionUID = 1L;
>
> @ManagedProperty(value="#{message}")
> private MessageBean messageBean;
> @PostConstruct
> public void postConstruct() {
> ...
> }
> ...
> }
> The following exception is thrown with MyFaces 2.2.8 on Tomcat 8:
> 19-Aug-2015 12:48:32.443 SEVERE [localhost-startStop-1]
> org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces An error occured
> while initializing MyFaces: This method is not supported during startup
> java.lang.UnsupportedOperationException: This method is not supported during
> startup
> at
> org.apache.myfaces.context.servlet.StartupServletExternalContextImpl.getSession(StartupServletExternalContextImpl.java:187)
> at
> org.apache.myfaces.view.impl.DefaultViewScopeHandler.generateViewScopeId(DefaultViewScopeHandler.java:128)
> at
> org.apache.myfaces.view.ViewScopeProxyMap.getWrapped(ViewScopeProxyMap.java:76)
> at
> org.apache.myfaces.view.ViewScopeProxyMap.get(ViewScopeProxyMap.java:109)
> at
> org.apache.myfaces.config.ManagedBeanBuilder.getScope(ManagedBeanBuilder.java:560)
> at
> org.apache.myfaces.config.ManagedBeanBuilder.getNarrowestScope(ManagedBeanBuilder.java:464)
> at
> org.apache.myfaces.config.ManagedBeanBuilder.isInValidScope(ManagedBeanBuilder.java:435)
> at
> org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:319)
> at
> org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:163)
> at
> org.apache.myfaces.webapp.AbstractFacesInitializer._createEagerBeans(AbstractFacesInitializer.java:303)
> at
> org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:193)
> at
> org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:119)
> at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
> at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
> Note, the app does not throw this Exception in MyFaces 2.0. The regression
> in 2.2 is caused by a spec update to UIViewRoot.getViewMap(boolean): that map
> is now backed by the session, which is not available during startup (which
> was addressed by MYFACES-3116):
> https://javaserverfaces.java.net/docs/2.2/javadocs/javax/faces/component/UIViewRoot.html#getViewMap%28boolean%29
> One solution is to make sure we don't call getViewMap(true) during startup;
> I'll attach a patch demonstrating that route.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)