3

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!

Daniel
  • 36,833
  • 10
  • 119
  • 200
  • You don't specify the scope of the given bean, nor in which phase of the lifecycle you're calling the method... – Aritz Sep 01 '14 at 20:14
  • Its a s `@SessionScoped` and the Phase Id is `RESTORE_VIEW` – Daniel Sep 01 '14 at 20:27
  • Was you also migrating to a different CDI environment? CDI calls the constructor when creating proxies. You'd better do business job in `@PostConstruct`. To naildown the one responsible for calling the constructor, put a breakpoint and explore the stack or do a `Thread.dumpStack()` in constructor. – BalusC Sep 02 '14 at 05:47
  • @BalusC, thanks for the tip, will continue with the `breakpoint` , I don't do business in the constructor, I created it only for logging and the `breakpoint` thing from the first place... The code from jsf that call the first Bean instance is `#{myBean.userLocale}` , that from my `PhaseListener` the `getApplication().evaluateExpressionGet` is called (same flow in all my web apps) – Daniel Sep 02 '14 at 07:02
  • @BalusC, I updated the question/title with more clear and detailed flow – Daniel Sep 02 '14 at 07:45
  • Can't reproduce in a blank project with MyFaces 2.2.3 on Tomcat 7.0.53. – BalusC Sep 02 '14 at 12:41
  • @BalusC, Thanks for trying to help, as I said , the exact setup works on several other apps... so my guess that this particular app got some sort of "garbage" that worked well in 2.0.11 but not in 2.2.3, I spent two days now.. and counting :/ to try to figure out whats wrong and where is that "garbage" is... what is that something that was allowed in 2.0.11 but not in 2.2.3 :'( opened issue on myfaces too https://issues.apache.org/jira/browse/MYFACES-3922 , so annoying... (I'm basically deleted all the content of the project now and reverting it back file by file....) Thanks again :| – Daniel Sep 02 '14 at 14:12
  • Is that environment (implicitly) using CDI? If so, try disabling it. – BalusC Sep 02 '14 at 16:29
  • @BalusC, I'm not using CDI, but I did found the problem (posted an answer) thanks for your help mate. – Daniel Sep 03 '14 at 10:48

1 Answers1

1

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 ?

Daniel
  • 36,833
  • 10
  • 119
  • 200