• Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 3.0.0.Beta2
    • Fix Version/s: None
    • Component/s: CDI Integration
    • Labels:
    • Environment:

      jboss AS 6 final, windows, war deployment

    • Steps to Reproduce:

      add multiple modules into the war (most importantly, persistence, solder)

      add multiple modules into the war (most importantly, persistence, solder)


      I have a big war with seam 3 faces, persistence, internationalization, xml config, solder modules in the web-inf/lib.
      I have tried to inject managed beans into the jsf converter, but it does not matter it is my own bean or seam's bean or weld's bean, the bean is always null. It seems that the injection fails silently. The converter code is as follows:
      package com.pearson.epen.managedBean.converter;

      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()

      {"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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()); }


      In above code, all injections are null and the @PostConstruct method is never called. However, getAsObject(FacesContext context, UIComponent component, String value) and getAsString(FacesContext context, UIComponent component, Object value) did get called.

      According to some other users, the injection works for them. But I am not sure they have multiple seam modules being used in the same war.

      Our war is big and it is difficult to isolate our application to just use seam faces, not others. So I am not creating a sample war. But it should be easy for seam faces developer to test this.

      I ended up doing bean lookup in my converter and it seems working and the bean is found in my converter.

      public List<T> findBeanRef(FacesContext context, String beanELName)

      { BeanManager bm = (BeanManager) (((ServletContext) context.getExternalContext().getContext()) .getAttribute("org.jboss.seam.faces.javax.enterprise.spi.BeanManager")); Bean bean = bm.getBeans(beanELName).iterator().next(); CreationalContext ctx = bm.createCreationalContext(bean); List<T> list = (List<T>) bm.getReference(bean, bean.getClass(), ctx); return list; }

        Gliffy Diagrams




              • Assignee:
                bleathem Brian Leathem
                yangju Richard Yang
              • Votes:
                1 Vote for this issue
                3 Start watching this issue


                • Created: