6 Replies Latest reply on Oct 18, 2001 4:13 AM by Mack

    Updating entity beans not refreshed in the web page

    Mack Newbie

      Hi all,

      I encountered a problem on web application deployment in JBoss using Tomcat.

      JBoss version: 2.4.1
      Tomcat version: 3.2.3

      The problem:

      When I update the entity bean data, the modified data will be immediately saved into the database, however, the web page is unable to reflect the changes. I suspect that JBoss caches up the old entity data. I hope there is anyone out there to advise me on how to set any configurations, thus modification on web pages will directly be reflected.

      Previously I tried to set the commit option to B or C, but the effect was the same. I will be greatly grateful if anyone can guide me on solving this problem.

      Thanks,

      Mack

        • 1. Re: Updating entity beans not refreshed in the web page
          hamish carpenter Newbie

          I am using the same version of jboss/tomcat and am having no problems with updates. If I refresh a web page it hits the app server again and gets the latest data (from JBoss cache usually).
          If caching is causing a problem it could be with your browser?

          • 2. Re: Updating entity beans not refreshed in the web page
            Mack Newbie

            Hi haytona,

            I really appreciate your advice. However, after trying to set non-cache for browser, the effect was still the same.

            In fact, I tried to print out the result from output screen before relaying the result to the web, and in surprise that the old result is never updated. So it can be concluded that the caching is happening in the EJB level (JBoss), rather than in web level.

            I will be grateful if you can share your deployment settings with me to achieve the condition I want to. Hope that other developers will be kind to give some ideas on this issue.

            Thanks,

            Mack

            • 3. Re: Updating entity beans not refreshed in the web page
              Verdi March Newbie

              Are you using "value object" -- return a serializable
              object to client? Are you "cache" the detail (value obj)
              as a private field in ejb class? If so, maybe you
              just forget to set it to null every time you update
              ejb. Common mistake is:

              private ValueObject detail = null;
              public void updateDetail(ValueObject detail)
              {
              ...
              //detail = null; //won't refresh cahed value obj
              this.detail = null; // or this.detail = detail;
              }

              • 4. Re: Updating entity beans not refreshed in the web page
                Mack Newbie

                Hi Cincaipatron,

                Thanks for your advice. After making the changes that you recommend, it did work. I feel grateful, however, because I am a beginner to EJB, so maybe you are kind to guide me on why we need to set the value object to null in the update method.(I know that it's a good idea to pass value objects, as it will reduce the number of method calls)

                Thanks....

                Mack

                • 5. Re: Updating entity beans not refreshed in the web page
                  Verdi March Newbie

                  If we don't set it to null, detail field still refer to
                  "old detail" (before updated). Usualy in getDetail(),
                  we check if detail field is not null, the we create
                  a new one. This is necessary because we don't want
                  to serialize detail field (just a temporary in memory).

                  Maybe this will be clearer:
                  private ValueObject detail = null;
                  public void updateDetail(ValueObject _detail)
                  {
                  fieldA = _detail.getFieldA();
                  fieldB = _detail.getFieldB();
                  ...
                  detail = null;
                  }

                  • 6. Re: Updating entity beans not refreshed in the web page
                    Mack Newbie

                    Hi,

                    Thanks Cincaipatron for your explanation. I got what you meant. Once again, I really appreciate your help.

                    Regards,

                    Mack