Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-11116

Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 17.0.1.Final
    • 14.0.1.Final, 12.0.0.Final, 13.0.0.Final, 15.0.0.Final
    • Clustering
    • None
    • Workaround Exists
    • Hide

      Note that delaying (Code Below) the load of the HTTP POST request before getting the value of the session Variable will resolve the issue (as a workaround):

      for (int i = 0; i < 5000; i++)
      {
      System.out.println("Value of i = " + i );
      }
      TestBean testBean = (TestBean)session.getAttribute("testBean");
      String testAcc = testBean.getAmount();

      Show
      Note that delaying (Code Below) the load of the HTTP POST request before getting the value of the session Variable will resolve the issue (as a workaround): for (int i = 0; i < 5000; i++) { System.out.println("Value of i = " + i ); } TestBean testBean = (TestBean)session.getAttribute("testBean"); String testAcc = testBean.getAmount();

      I have two Servlets Book and BookPreview the attribute is set in Book Servlet as follow:

      Book.java
      TestBean testBean=null;
      if(session.getAttribute("testBean")!=null)
      testBean = (TestBean)session.getAttribute("testBean");
      else{
      testBean=new TestBean();
      session.setAttribute("testBean",testBean);
      }
      testBean.setAmount("10");

      response.sendRedirect("BookPreview");

      The session attribute can be retrieved and the page is loaded normally and the Amount value is displayed however when submitting the form (Post Action in BookPreview.java) Null Pointer exception is generated.

      BookPreview.java

      TestBean testBean = (TestBean)session.getAttribute("testBean");
      String amount = testBean.getAmount; //Null pointer exception when submitting the form

      <form method="Post" action="BookPreview">

      </form>

      TestBean.java

      public class TestBean implements java.io.Serializable {

      private static final long serialVersionUID = 1L;
      private String amount;

      public String getAmount()

      { return amount; }

      public void setAmount(String amount)

      { this.amount = amount; }

      }

      Kindly advice how to fix the problem at the level of the server configuration.

      PS: I am not getting the exception when deploying the same application under other J EE application servers (Tomcat....)

      Thanks and Best Regards

            pferraro@redhat.com Paul Ferraro
            zsaade ziad saade (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: