title: jsf-spring : managedbean postconstruct not called
body: <p>I'm rather learning by doing so it might be a stupid question but I couldn't find any answer.</p>
  
  <p>I have an JSF application which worked well as used with simple JDBC.</p>
  
  <p>Take an example of the "domain.xhtml", which had a table listing elements from a "DomainController" bean. It was all working great then we switched to JPA. That controller has to use services so it's declared as @Component and includes (@Autowired) services from there. It also works well EXCEPT that <strong>all my JSF injections (@ManagedProperty) are not injected anymore, my @PostConstruct is not called anymore either</strong>.</p>
  
  <p>Is there something I missed, or is wrong with that manner to proceed ? </p>
  
  <pre><code>@ManagedBean
  @Component
  public class DomainController implements Serializable {
      private static Logger log = Logger.getLogger(DomainController.class);
  
      private static final long serialVersionUID = -2862060884914941992L;
      private List&lt;Domain&gt; allItems;
      private Domain[] selectedItem;
      private SelectItem[] yesNoNull;
      private DomainFilter filter = new DomainFilter();
  
      @Autowired
      private DomainService domainService;
  
      @Autowired
      private ValidationLookUpService validationLookUpService;
  
      @Autowired
      private ValidationService validationService;
  
      @ManagedProperty("#{workspace.on}")
      private boolean wsOn;
  
      //  @ManagedProperty("#{libraryVersionController.selectedItem.id}")
      //  private Integer selectedLibVersionID;
  
      @ManagedProperty("#{libraryVersionController.selectedItem}")
      private LibraryVersion selectedLibVersion;
  
      @ManagedProperty("#{obsoleteEntry}")
      private PObsoleteEntry pObsoleteEntry;
  
      @ManagedProperty("#{validationFailedItemsController}")
      private ValidationFailedItemsController validationFailedCont;
  
      private Domain itemEdited;
  
      private boolean persisted = false;
  
      public DomainController() {
          log.info("Creating metadata controller");
  
          allItems = new ArrayList&lt;Domain&gt;();
  
          // model for a yes/no/null column filtering
          yesNoNull = new SelectItem[4];
          yesNoNull[0] = new SelectItem("", "All");
          yesNoNull[1] = new SelectItem("true", "yes");
          yesNoNull[2] = new SelectItem("false", "no");
          yesNoNull[3] = new SelectItem("null", "not yet validated");
  
  
      }
  
      @PostConstruct
      public void test() 
      {
          log.info("!!!");
          log.info("WS is ... "+wsOn);
          // NOT CALLED ANYMORE
      }
  
  ...
  </code></pre>
  
  <p><strong>My web.xml :</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets 
          and Filters --&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;!-- indique le fichier de configuration pour Spring --&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;facelets.DEVELOPMENT&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt; &lt;!-- to really skip comments in xhtml pages --&gt;
          &lt;param-name&gt;javax.faces.FACELETS_SKIP_COMMENTS&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
          &lt;param-value&gt;.xhtml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.CONFIG_FILES&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/faces-config.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/app/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/spring/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
  
      &lt;listener&gt; &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;listener&gt; &lt;!-- links JSF with spring --&gt;
          &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;listener&gt; &lt;!-- parses JSF configuration --&gt;
          &lt;listener-class&gt;com.sun.faces.config.ConfigureListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;listener&gt; &lt;!-- vide le cache d’introspection Spring à l’arrêt du serveur. Ce listener n’est pas obligatoire mais conseillé --&gt;
          &lt;listener-class&gt;org.springframework.web.util.IntrospectorCleanupListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
  
  
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;/filter-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Thanks !</p>