1 Reply Latest reply on Nov 27, 2009 7:44 AM by bsgcic

    Datamodel: casting exception on @Destroy - Submit bug?

    bsgcic Newbie

      Is there a bug that should be reported for the following?:


      Getting the following error for a datamodel when it is used to display an h:dataTable. The dataTable is displayed fine. However, in the log, I receive:


      15:04:42,312 WARN  [Component] Exception calling component @Destroy method: deliveryDeadlineOptionList
      javax.ejb.EJBException: java.lang.ClassCastException: java.util.ArrayList cannot be cast to javax.faces.model.DataModel
      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
      ...
      



      The bean for this is used for the following two purposes:


      1. Value of an s:selectItems


      2. Value of an h:dataTable (i.e., as mentioned above)


      The bean:


      @Stateful
      @Scope(CONVERSATION)
      @Name("deliveryDeadlineOptionList")
      @TransactionAttribute(REQUIRES_NEW)
      public class DeliveryDeadlineOptionListAction implements DeliveryDeadlineOptionList, Serializable
      {
      @PersistenceContext(type=PersistenceContextType.EXTENDED)
      @In(create=true)
      private EntityManager entityManager;
      
      @DataModel
      private List<DeliveryDeadlineOption> deliveryDeadlineOptionsList;
      
      @DataModelSelection
      private DeliveryDeadlineOption deliveryDeadlineOption;
      
      @Create
      public void create() {getDeliveryDeadlineOptionsList();}
      
      @Factory
      public List<DeliveryDeadlineOption> getDeliveryDeadlineOptionsList(){
      return (List<DeliveryDeadlineOption>) entityManager.createQuery("select c from DeliveryDeadlineOption c")
      .getResultList();
      }
      
      public DeliveryDeadlineOption getDeliveryDeadlineOption(){return deliveryDeadlineOption;}
      
      @Destroy
      @Remove
      public void destroy() {}
      }
      
      



      Relevant portions of the bean where deliveryDeadlineOptionList is used for the s:selectItems functionality:


      @Stateful
      @Name("quoteCalculate")
      @Scope(ScopeType.CONVERSATION)
      public class QuoteCalculatingAction implements QuoteCalculating
      {
      @PersistenceContext(type=PersistenceContextType.EXTENDED)
      @In(create=true)
      private EntityManager entityManager;
      
      ...
      
      @In(value="deliveryDeadlineOptionsList", create=true)
      private List<DeliveryDeadlineOption> deliveryDeadlineOptions;
      
      @DataModel
      private List<DeliveryDeadlineOption> selectedDeliveryDeadlineOptions;
      
      ...
      
      (Standard getters and setters for above)
      
      public void selectedDeliveryDeadlineOptionsChange(ValueChangeEvent valueChangeEvent) {
      setSelectedDeliveryDeadlineOptions((List<DeliveryDeadlineOption>) valueChangeEvent.getNewValue());
      ...
      }
      ...
      }