Search code examples
jsf-2jsf-2.2myfaces

getApplication().evaluateExpressionGet trying to create new Instance (jsf 2.0 -> 2.2 migration issue?)


For some reason (wonder why....) After my bean in being created (as a result of ValueExpressionImpl: #{admin.userLocale} (I see it in the stack-trace in the break-point of the constructor), tight after that when my phaselistener is failing (exception) in invoking the following command

return context.getApplication().evaluateExpressionGet(context,
            "#{myBean}", myBean.class);

The execution of the code above triggers the constructor for the second time - why?

The weird thing is that I got the exact mechanism working just fine (bean constructor call -> phase listener invoking "the" command (which not calling beans constructor again)) in many others apps... but in that particular app its not working.

Also an important note that with MyFaces 2.0.11 this app works just fine

I double and triple checked that faces-config / web.xml are like in other apps too

The exception that I'm getting after moving from MyFaces JSF 2.0.11 to 2.2.3 is:

javax.faces.view.facelets.TagAttributeException: /viewMetadata/myPage.xhtml at line 13 and column 38 locale="#{myBean.userLocale}" null

...

Caused by: java.lang.NullPointerException at org.apache.myfaces.config.ManagedBeanBuilder.getScope(ManagedBeanBuilder.java:560)

I did a bit of Google and found the following MYFACES-3907 and I even tried to apply the fix but all it did is removing the exception but my webapp still no good

p.s Its a s @SessionScoped and the Phase Id in which the getApplication().evaluateExpressionGet is being called is RESTORE_VIEW

Any Ideas on how can I figure out what causes the issue?

Thanks!


Solution

  • Found the problem... although I don't really know why (do have some theories)

    In that bean of mine there was a ManagedProperty...

    @ManagedProperty(value = "#{error}")
    private ErrorPageMBean error;  //with getter/setter
    

    That managed property was there for years and wasn't even used. and again it all worked just fine in MyFaces 2.0.11...

    The moment I removed it all started to works just fine...

    Any idea whats wrong with that ManagedProperty ?