2 Replies Latest reply on Feb 10, 2011 10:47 AM by richard yang

    seam 3 faces beta2 injection of any bean in face converter is null when combined with seam persistence

    richard yang Newbie

      `package com.pearson.epen.managedBean.converter;

      import java.io.Serializable;
      import java.util.List;

      import javax.annotation.PostConstruct;
      import javax.enterprise.context.SessionScoped;
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.Converter;
      import javax.faces.convert.FacesConverter;

      import javax.inject.Inject;
      import javax.persistence.EntityManager;

      import org.slf4j.Logger;

      import com.pearson.epen.account.model.api.TestAdmin;
      import com.pearson.epen.cdi.qualifier.CentralRepo;
      import com.pearson.epen.cdi.qualifier.StaticData;

      public class TestAdminConverter implements Converter, Serializable {

          private static final long serialVersionUID = 1L;

          private List<TestAdmin> admins;

          private FacesContext context;

          private EntityManager em;
          private Logger log;

          public void init() {

          public Object getAsObject(FacesContext context, UIComponent component, String value) {
              try {

                  Long id = Long.valueOf(value);           
                  for (TestAdmin admin : admins) {
                      if (admin.getId().longValue() == id.longValue()) {
                          return admin;

              } catch (Throwable t) {
                  log.error("got exception", t);

              return null;

          public String getAsString(FacesContext context, UIComponent component, Object value) {
              TestAdmin testAdmin = (TestAdmin) value;
              return Long.toString(testAdmin.getId());



      It does not matter the injected bean is my own or seam's or weld's. They are all null. But no exception is thrown. The @PostConstruct never get called. But getAsObject and getAsString did get called.

      If I inject those outside the converter, then they are not null.

      Some people say it works for them: http://seamframework.org/Community/InjectionNotWorkingInFaceConverter?cid=2285991

      But in my case, I have several seam 3 modules included in the war and I wonder if that makes injection in face converter not working?
      Seam faces developers, please help. I have tried everything I can think of.