1 2 Previous Next 23 Replies Latest reply on Mar 6, 2009 6:27 PM by fridgebuzz Go to original post
      • 15. Re: Observer methods being called multiple times
        norman

        I'm sure this is a problem with your app/environment and not a general Seam issue.  If it were me, I'd attach a debugger to the event handler code and try and figure out exactly what is causing the issue.  Failing that, it might be time to look at paid support. 

        • 16. Re: Observer methods being called multiple times
          fridgebuzz

          Hi Norman,


          a) you are probably right


          b) of course I have already tried this, many many many times. There's no insight to be gained there.


          c) can't possibly afford that. :-(


          I've asked my colleague to take a look since I've run out of ideas. Maybe he'll have more luck.


          Cheers,


          Vanessa

          • 17. Re: Observer methods being called multiple times
            nickarls

            Start with a fresh copy of your application server. Make sure you deploy no other applications than the one with the issue. Examine the WAR carefully for strangenesses (duplicate files, classloader isolation settings in jboss-web.xml etc).


            How was your project generated (manually? seam-gen? jboss tools?). How do you build it? ANT? Export to WAR from eclipse?

            • 18. Re: Observer methods being called multiple times
              nickarls

              And if all else fails, put a boolean alreadyRun flag somewhere and exit early if it's set ;-)

              • 19. Re: Observer methods being called multiple times
                fridgebuzz

                Actually, after a phone debugging session with my colleague we determined the cause of the problem. It is in fact, a Seam bug. It only appears in a certain circumstance. When I get a chance I'll create a minimal project demonstrating it and file a bug report.


                Basically, the problem only appears when an Observer method exists in a component that has a subclass. It will also result in other Observer methods not being called at all. I don't know enough about the internals of the Event mechanism, but somehow the walker/parser that looks for Observer annotations gets confused/derailed in this case.


                So,,, my problem is at last solved (knock wood), a bug report is forthcoming and in the meantime there is a workaround.


                Cheers,


                Vanessa

                • 20. Re: Observer methods being called multiple times
                  norman

                  Please open a JIRA and I'll take a look.  I tried a simple test case with observers at various points in an object hierarchy and saw no errors, but I'm sure my test wasn't exhaustive.

                  • 21. Re: Observer methods being called multiple times
                    fridgebuzz

                    It's described here:


                    https://jira.jboss.org/jira/browse/JBSEAM-3983


                    Unfortunately, I do not have time to properly construct a project to demonstrate the problem. But my description should suffice. A colleague with a different platform (I'm on Mac, he's using Windows) and a different version of Seam (I'm using 2.1.0 he's using 2.1.1) was able to reproduce both the problem and the workaround.


                    The workaround, by the way, is to place @Observer methods in final classes (or classes which do not have any subclasses.) It really doesn't matter where you put them as long as there are no subclasses in existence.


                    Cheers,


                    Vanessa

                    • 22. Re: Observer methods being called multiple times
                      fridgebuzz

                      OK, forget what I said about final classes, that will FAIL. Just don't subclass the thing.


                      And here's the issue properly formatted as a link.


                      JBSEAM-3983

                      • 23. Re: Observer methods being called multiple times
                        fridgebuzz

                        I'll have to accept that it's a feature, not a bug, since I don't know any better; however, this comment (taken from the JIRA issue) I don't understand:


                        Norman said: Subclassing a class does cause annotations on parent classes to be ignored.


                        Ok, that's fair enough. The problem I'm seeing, however, is the opposite. That is, the annotation on the parent class is not ignored, but the same annotation is applied to the sub-class. Even though the method with the annotation is not over-ridden in the sub-class and therefore no such annotation exists in the sub-class.


                        So... what is happening in effect is that subclassing a class causes annotations on parent classes to be duplicated in their sub-classes. Or something to that effect.


                        Is that truly what's supposed to happen?


                        Thanks,


                        Vanessa

                        1 2 Previous Next