myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakob Korherr (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3116) MyFaces cannot resolve @ManagedProperty on startup, throws UnsupportedOperationException
Date Wed, 27 Apr 2011 22:37:03 GMT

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

Jakob Korherr commented on MYFACES-3116:
----------------------------------------

The solution was to check if MyFaces is currently starting (StartupServletExternalContextImpl
is used) and to avoid calls to getRequestMap() and getSessionMap() in that case. In addition,
the FacesContext attribute map had to be used instead of the request map for "global" values
(e.g. needed in cyclic reference detection).

Also, an eager bean must not be initialized if it has already been initialized by another
eager beans via a @ManagedProperty reference. Otherwise it would be created twice!

> MyFaces cannot resolve @ManagedProperty on startup, throws UnsupportedOperationException
> ----------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3116
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3116
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.0.5
>         Environment: Tomcat 6
>            Reporter: Alois Glomann
>            Assignee: Jakob Korherr
>             Fix For: 2.0.6-SNAPSHOT
>
>
> I have a managedbean which initializes some services:
> @ManagedBean(eager = true)
> @ApplicationScoped
> public class Services {
>  private SecurityContext securityContext;
>  @PostConstruct
>  public void init() {
>   securityContext = new SecurityContext();
>  }
> }
> In another bean i want to inject a ManagedProperty of type SecurityContext (applicationscoped
as well)
> @ManagedBean(eager = true)
> @ApplicationScoped
> public class Validator{	
>  @ManagedProperty("#{services.securityContext}")
>  private SecurityContext securityContext;
>  //irrelevant code ...
>  public void setSecurityContext(SecurityContext securityContext) {
>   this.securityContext = securityContext;
>  }
> }
> This is working with latest version of the reference implementation (mojarra 2.1.0).
I was trying to use MyFaces because mojarra has another ugly bug, which initilizes application
scoped beans twice.
> On application startup myfaces cannot init Validator due to this exception:
> INFO: Creating instance of com.eskupina.webrepositoryinterface.Services
> 26.04.2011 12:20:14 org.apache.myfaces.config.annotation.TomcatAnnotationLifecycleProvider
newInstance
> INFO: Creating instance of com.eskupina.webrepositoryinterface.Validator
> 26.04.2011 12:20:14 org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
> SCHWERWIEGEND: 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.getRequestMap(StartupServletExternalContextImpl.java:149)
> 	at org.apache.myfaces.config.ManagedBeanBuilder.getScope(ManagedBeanBuilder.java:540)
> 	at org.apache.myfaces.config.ManagedBeanBuilder.getNarrowestScope(ManagedBeanBuilder.java:462)
> 	at org.apache.myfaces.config.ManagedBeanBuilder.isInValidScope(ManagedBeanBuilder.java:433)
> 	at org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:322)
> 	at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:169)
> 	at org.apache.myfaces.webapp.AbstractFacesInitializer._createEagerBeans(AbstractFacesInitializer.java:221)
> 	at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:138)
> 	at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111)
> 	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
> 	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
> 	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
> 	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
> 	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
> 	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
> 	at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
> 	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
> 	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
> 	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
> 	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> 	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
> 	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
> 	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> 	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
> 	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
> 	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> 	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
> 	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
> 26.04.2011 12:20:14 org.apache.catalina.core.StandardContext start
> SCHWERWIEGEND: Error filterStart
> 26.04.2011 12:20:14 org.apache.catalina.core.StandardContext start

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message