I\'m running with the following problem.
I have a few Managed Beans that are shared between, at this moment, two JSF applications. As I don\'t want to copy and paste
Then the @PostConstruct annotation has not been scanned. This is result of the same problem which caused that your @ManagedBean annotation and likes have not been scanned.
There are several causes of this problem:
You used Mojarra 2.1.0 on Jetty/Tomcat/JBoss AS. This is a very specific bug in the annotation scanner. See issue 1937.
Your /WEB-INF/faces-config.xml file has a metadata-complete="true" attribute. This conflicts the 1st requirement as outlined in JSF 2.0 specification:
11.5.1 Requirements for scanning of classes for annotations
If the
element in theWEB-INF/faces-config.xmlfile containsmetadata-completeattribute whose value is“true”, the implementation must not perform annotation scanning on any classes except for those classes provided by the implementation itself. Otherwise, continue as follows.If the runtime discovers a conflict between an entry in the Application Configuration Resources and an annotation, the entry in the Application Configuration Resources takes precedence.
All classes in
WEB-INF/classesmust be scanned.For every jar in the application's
WEB-INF/libdirectory, if the jar contains a“META-INF/faces-config.xml”file or a file that matches the regular expression“.*\.faces-config.xml”(even an empty one), all classes in that jar must be scanned.
Your JAR file is not been dropped in /WEB-INF/lib, but somewhere else in the classpath. This conflicts the 4th requirement as outlined above.
Your webapp's /WEB-INF/faces-config.xml and/or your JAR's /META-INF/faces-config.xml is not JSF 2.x compatible. It must not contain a JSF 1.x specific declaration, but a JSF 2.x specific one.
The one in JAR's /META-INF is allowed to be completely empty.
Cause 1 can be scratched in your particular case as you're using Mojarra 2.1.3 on Glassfish. I'll bet it to be the other causes.