Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@PostConstruct from super-class not working...

 
Daniel Platon
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

Here's the problem - we have two classes:

class SuperBean, that has an init() method annotated with @PostConstruct

class NormalBean has no method whatsoever but extends SuperBean. NormalBean will just override some methods from the superclass

The jspx page displays the motd attribute using something like

Using the setting above the output in the browser is
This clearly means that the motd property is not set, i.e. the SuperBean.init() method does not run.

However, if I alter the NormalBean class like this:


The message in the browser displays correctly.

Why is this happening? I need the init() method to be only in the superclass, so the developer doesn't have to bother with the initialization stuff...
Actually, the original bug(?) is in IceFaces 1.8, but I tested it in a plain JSF1.2 application and I get the same behaviour, as you can see.

Thank you very much,
Dan
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it is documented behaviour that @PostConstruct cannot be inherited, so you may just be out of luck.
 
Daniel Platon
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it is documented behaviour that @PostConstruct cannot be inherited, so you may just be out of luck.


Actually... I have performed the same test using a simple Spring application, with no JSF involved. The @PostConstruct annotation worked as expected, and the init() method of the superclass was called immediately after the constructor. This means that is really a JSF "bug" (or should I say... bad implementation).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't appreciate it either, but if you do a little web searching, you'll probably uncover the discussion on the matter. For what it's worth. At the moment, the practical aspect of it all is you're out of luck, though.
 
Daniel Platon
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a little research and came up with this issue. Turns out it's a Tomcat issue, for any versions prior to 6.0.18. I upgraded to 6.0.32 and everything works fine.

Thank you Tim for pointing me to the right direction!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Good. I fought some serious battles with that stuff back then. Glad to see it's fixed now.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic