-
15. Re: Observer methods being called multiple times
norman Feb 27, 2009 7:42 PM (in response to fridgebuzz)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 Feb 27, 2009 8:07 PM (in response to 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 Feb 27, 2009 9:35 PM (in response to fridgebuzz)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 Feb 27, 2009 9:37 PM (in response to fridgebuzz)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 Feb 27, 2009 9:45 PM (in response to 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 Feb 27, 2009 10:08 PM (in response to fridgebuzz)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 Mar 2, 2009 10:53 PM (in response to 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 Mar 2, 2009 11:02 PM (in response to 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.
-
23. Re: Observer methods being called multiple times
fridgebuzz Mar 6, 2009 6:27 PM (in response to 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