This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSF and the fly likes @PostConstruct Method Not Called In JSF 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSF
Bookmark "@PostConstruct Method Not Called In JSF 2.0" Watch "@PostConstruct Method Not Called In JSF 2.0" New topic

@PostConstruct Method Not Called In JSF 2.0

Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
A method annotated with @PostConstruct on my managed bean is not being called in JSF 2.0.

Here is a snippet of my managed bean:

Here's a snippet from my web.xml:

Here's my faces-config.xml

Here's a list of the jars I am using:


Any ideas?
Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
No one has any idea? What more information could I include to help point to the problem?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17018

You probably need to include the commons-annotations jar, since I didn't spot it in the list.

I haven't had problems in my JSF 2.0 projects, but I've had spotty results using this annotation in my JSF 1.x projects. I think the server may need some configuration in order to get the classloader to process the annotation properly.

Also, you need to know that if you're using Tomcat6, it should be release 6.0.18 or later, as there were bugs relating to inheritance of annotations in earlier versions. Specifically, inherited annotations weren't being processed.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: @PostConstruct Method Not Called In JSF 2.0
It's not a secret anymore!