1 2 Previous Next 22 Replies Latest reply on Oct 4, 2018 9:36 AM by Ziad Saade

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

    Ziad Saade Newbie

      Dear All

       

      I am using Wildfly 12.0.0 Final, when deploying the application I’m receiving Null pointer exception, below is the flow of the Code:

       

      At the beginning of the Servlet, I am getting the value of the Session Variable:

      TestBean testBean = (TestBean)session.getAttribute("testBean");

       

      When getting the value from the variable “testBean” I am getting null pointer exception.

      String testAcc = testBean.getAmount();

       

      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++)

      {

      1. System.out.println("Value of i = " + i );

      }

      TestBean testBean = (TestBean)session.getAttribute("testBean");

      String testAcc = testBean.getAmount();

       

      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

        • 1. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
          Paul Ferraro Master

          I need more context to be able to help.  Where is this attribute set?  i.e. where is the call to session.setAttribute("testBean", ...);

          What type of object is TestBean?  e.g. EJB, CDI bean, POJO, etc.

          • 2. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
            Ziad Saade Newbie

            Hi Paul

             

            Thanks for your reply

             

            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 BookPreview.java) the 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;

                 }

            }

             

            if you need further details don't hesitate to contact me.

             

            Thanks and Best Regards

            • 3. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
              Paul Ferraro Master

              I assume this a distributable web application?  If so, can you paste your "web" cache-container configuration from the Infinispan subsystem, along with any jboss-web.xml customizations?

              • 4. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                Ziad Saade Newbie

                Hi Paul

                 

                Yes this is a distributed web application (EAR,WAR), but he process in question is being executed inside the same war no interaction with any other layer. I'm using the default cache-container configurations (no changes in the standalone-ha.xml or in the standalone-full-ha.xml files) and I don't have any jboss-web.xml file (neither in the deployment files nor in the Server Wildfly 12.0.0 Final).

                 

                Best Regards

                • 5. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                  Paul Ferraro Master

                  That's puzzling.  The behavior you've described sounds like the transaction isolation was lowered from REPEATABLE_READ to READ_COMMITTED.  Otherwise, the subsequent session read (from your redirect) should block until previous request has completed.  Can you verify whether this is the case?

                   

                  I suggest modifying your default cache configuration within the "web" subsystem of the Infinispan subsystem to disable txs.

                  e.g.

                                  <distributed-cache name="dist">

                                      <file-store/>

                                  </distributed-cache>

                  • 6. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                    Ziad Saade Newbie

                    Dear Paul

                     

                    While debugging the code the Session variable is always filled with the value until the post action is triggered, Note that I did the requested cache configurations under:

                    • standalone\configuration\standalone-full-ha.xml
                    • standalone\configuration\standalone-ha.xml

                    and the issue still reproducible.

                    Note the the issue is not always reproducible, most of the time it's reproducible. (Strange Behavior)

                     

                    thanks and best regards

                    • 7. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                      Paul Ferraro Master

                      Why you are modify both the "ha" and "full-ha" profiles.?  Which server profile are you actually using?

                      • 8. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                        Ziad Saade Newbie

                        Sorry for the inconvenience, I'm running the standalone.xml Profile. and it contains the below tags, Advice about the exact configuration:

                         

                         

                                <subsystem xmlns="urn:jboss:domain:infinispan:5.0">

                                    <cache-container name="server" default-cache="default" module="org.wildfly.clustering.server">

                                        <local-cache name="default">

                                            <transaction mode="BATCH"/>

                                        </local-cache>

                                    </cache-container>

                                    <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">

                                        <local-cache name="passivation">

                                            <locking isolation="REPEATABLE_READ"/>

                                            <transaction mode="BATCH"/>

                                            <file-store passivation="true" purge="false"/>

                                        </local-cache>

                                    </cache-container>

                                    <cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">

                                        <local-cache name="passivation">

                                            <locking isolation="REPEATABLE_READ"/>

                                            <transaction mode="BATCH"/>

                                            <file-store passivation="true" purge="false"/>

                                        </local-cache>

                                    </cache-container>

                                    <cache-container name="hibernate" module="org.infinispan.hibernate-cache">

                                        <local-cache name="entity">

                                            <transaction mode="NON_XA"/>

                                            <object-memory size="10000"/>

                                            <expiration max-idle="100000"/>

                                        </local-cache>

                                        <local-cache name="local-query">

                                            <object-memory size="10000"/>

                                            <expiration max-idle="100000"/>

                                        </local-cache>

                                        <local-cache name="timestamps"/>

                                    </cache-container>

                                </subsystem>

                         

                        Best Regards

                        • 9. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                          Paul Ferraro Master

                          That configuration should not allow any stale reads like those you've described.

                          However, I suggest the following configuration for your web cache-container:

                           

                                      <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">

                                          <local-cache name="passivation">

                                              <file-store passivation="true" purge="false"/>

                                          </local-cache>

                                      </cache-container>

                          • 10. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                            Ziad Saade Newbie

                            Hi Paul

                             

                            I did the requested configuration however the issue still reproduced, I will test the issue under Wildfly 13.0.0 Final and I will let you know the result:

                             

                            If you still have other suggestions please let me know

                             

                            Thanks and Best Regards

                            • 11. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                              Ziad Saade Newbie

                              Hi Paul

                               

                              Note that the issue is reproduced under Wildfly 13.0.0 Final

                               

                              Kindly advice is you still have any Configuration suggestions to fix the problem.

                               

                              Best Regards

                              • 12. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                                Paul Ferraro Master

                                zidoff Something isn't right.  I've tried to reproduce your issue locally using the same code, but do not see the NPE using the default standalone.xml.

                                Therefore, I suspect something is wrong with your configuration.  Please post the results of the following management operation via the CLI:

                                 

                                /subsystem=infinispan/cache-container=web:read-resource(recursive=true)

                                • 13. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                                  Ziad Saade Newbie

                                  Dear Paul

                                   

                                  Thanks for your reply

                                   

                                  Find below the requested:

                                  {

                                      "outcome" => "success",

                                      "result" => {

                                          "aliases" => undefined,

                                          "default-cache" => "passivation",

                                          "eviction-executor" => undefined,

                                          "jndi-name" => undefined,

                                          "listener-executor" => undefined,

                                          "module" => "org.wildfly.clustering.web.infinispan",

                                          "replication-queue-executor" => undefined,

                                          "start" => "LAZY",

                                          "statistics-enabled" => false,

                                          "distributed-cache" => undefined,

                                          "invalidation-cache" => undefined,

                                          "local-cache" => {"passivation" => {

                                              "batching" => false,

                                              "indexing" => "NONE",

                                              "indexing-properties" => undefined,

                                              "jndi-name" => undefined,

                                              "module" => undefined,

                                              "start" => "LAZY",

                                              "statistics-enabled" => false,

                                              "component" => {

                                                  "locking" => {

                                                      "acquire-timeout" => 15000L,

                                                      "concurrency-level" => 1000,

                                                      "isolation" => "REPEATABLE_READ",

                                                      "striping" => false

                                                  },

                                                  "transaction" => {

                                                      "locking" => "PESSIMISTIC",

                                                      "mode" => "BATCH",

                                                      "stop-timeout" => 10000L

                                                  },

                                                  "expiration" => {

                                                      "interval" => 60000L,

                                                      "lifespan" => -1L,

                                                      "max-idle" => -1L

                                                  }

                                              },

                                              "memory" => {"object" => {

                                                  "max-entries" => -1L,

                                                  "size" => -1L,

                                                  "strategy" => "NONE"

                                              }},

                                              "store" => {"file" => {

                                                  "fetch-state" => true,

                                                  "max-batch-size" => 100,

                                                  "passivation" => true,

                                                  "path" => undefined,

                                                  "preload" => false,

                                                  "properties" => undefined,

                                                  "purge" => false,

                                                  "relative-to" => "jboss.server.data.dir",

                                                  "shared" => false,

                                                  "singleton" => false,

                                                  "property" => undefined,

                                                  "write" => {"through" => {}}

                                              }}

                                          }},

                                          "replicated-cache" => undefined,

                                          "thread-pool" => {

                                              "async-operations" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 25,

                                                  "min-threads" => 25,

                                                  "queue-length" => 1000

                                              },

                                              "expiration" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 1

                                              },

                                              "listener" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 1,

                                                  "min-threads" => 1,

                                                  "queue-length" => 100000

                                              },

                                              "persistence" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 4,

                                                  "min-threads" => 1,

                                                  "queue-length" => 0

                                              },

                                              "remote-command" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 200,

                                                  "min-threads" => 1,

                                                  "queue-length" => 0

                                              },

                                              "state-transfer" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 60,

                                                  "min-threads" => 1,

                                                  "queue-length" => 0

                                              },

                                              "transport" => {

                                                  "keepalive-time" => 60000L,

                                                  "max-threads" => 25,

                                                  "min-threads" => 25,

                                                  "queue-length" => 100000

                                              }

                                          },

                                          "transport" => {"none" => {}}

                                      }

                                  }

                                   

                                  Thanks and best Regards

                                  • 14. Re: Wildfly 12.0.0 Final Delay in Getting the Value Attributes of the Session Variables (Result in Null Pointer Exception)
                                    Paul Ferraro Master

                                    I don't see any problem with your configuration.  Have you tried reproducing the issue on the latest stable release, i.e. 14.0.1.Final?

                                    1 2 Previous Next