1

I'm using JSF Mojarra 2.3.8 with Tomcat 8 (with additional libraries required for CDI and JPA). I have a ViewScoped bean:

@Named @ViewScoped
public class MyBean implements Serializable {
...

I have a page that uses this bean.

I open the page in 2 browser tabs, modify and post the page on tab 1. Then navigate away from the page on tab 1 (the action returns a different page).

Then, on tab 2, I try to modify and save the same record. There is no error, but I can see from the logs that MyBean is recreated and has lost the original data.

To save the data, I'm using:

<h:commandButton type="submit" value="Save" action="#{myBean.saveData}" />

I thought that ViewScoped beans could be used independently on multiple tabs. If that's true, why should one page affect the same bean associated with another page?

It seems that I have the same problem described here: Multiple browser tabs or windows with the same ViewScoped bean class but alas it has no answer.

Although this may share the same root cause as javax.faces.view.ViewScoped bean and multiple tabs issue I don't think it's a duplicate because I'm not using WildFly, so the answer for that question will be different to mine (i.e. WildFly was patched).

Edward
  • 580
  • 3
  • 15
  • And you also followed the link in the comment in that question? And the link in the answer on the link in the comment? The WildFly 'issue' link? Please do. – Kukeltje Feb 16 '19 at 10:57
  • 1
    Possible duplicate of [javax.faces.view.ViewScoped bean and multiple tabs issue](https://stackoverflow.com/questions/52477462/javax-faces-view-viewscoped-bean-and-multiple-tabs-issue) – Kukeltje Feb 16 '19 at 11:04
  • It seems then that this is a bug in Mojarra and will hopefully be fixed in version 2.3.10? – Edward Feb 16 '19 at 12:56
  • @Kukeltje I don't think this is a duplicate because I'm not using WildFly, so the answer for that question will be different to mine (i.e. WildFly was patched). – Edward Feb 16 '19 at 23:20
  • 1
    "It's a known and fixed issue in Mojarra" is the answer for Wildfly and Tomcat+Mojarra. Wildfly users will need to upgrade to a patched WF, Mojarra users to a patched Mojarra. I don't see a differene tho. – Selaron Feb 18 '19 at 11:58
  • @Selaron Is it actually fixed in Majorra? The bug report for it at https://github.com/eclipse-ee4j/mojarra/issues/4509 suggests it's still open and planned to be fixed for 2.3.10 (not sure how far away that is). Do you have some other information? Also, it's different for WildFly users because they have already patched it in version 16 Alpha, which is released, so "update to WildFly 16" is the answer for that one, but that doesn't help Tomcat+Mojarra users. – Edward Feb 19 '19 at 06:44
  • Have you tested with different browsers with same result? – Aritz Feb 19 '19 at 21:37
  • @XtremeBiker Yes, I tried it in FF and Safari - exactly the same in both. – Edward Feb 20 '19 at 00:04

1 Answers1

1

In case someone else has the same problem, I think this is the closest thing to an answer right now:

This is a bug with Mojarra and will be fixed in 2.3.10 according to this post: https://github.com/eclipse-ee4j/mojarra/issues/4509#issuecomment-453188481

Until Mojarra 2.3.10 is released, using the version that is shipped with WildFly 16 might work because the Wildfly team have patched that version (but I haven't tried that). If you're using Wildfly or Payara, then look into upgrading to the latest versions (16 Alpha 1 for WF) as they've both been patched (but not in GA as of this answer).

UPDATE: Version 2.3.10 can be found at its new home: http://central.maven.org/maven2/org/glassfish/jakarta.faces/2.3.10/

Edward
  • 580
  • 3
  • 15