1 Reply Latest reply on May 20, 2008 2:01 AM by admin.admin.email.tld

    JSF exception being swallowed, need help plz

    admin.admin.email.tld

      Seam 2.0.1.GA
      RF 3.2.0.SR1
      JBoss 4.2.1.GA


      I am trying to replace commandButtons in each row of two datatables in a JSF with checkboxes.


      I was able to complete my POC of adding a checkbox to the hotel booking and outputting the values in the submit method  as follows:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                         xmlns:ui="http://java.sun.com/jsf/facelets"
                            xmlns:h="http://java.sun.com/jsf/html"
                            xmlns:f="http://java.sun.com/jsf/core"
                            xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:a="http://richfaces.org/a4j"
                          template="template.xhtml">
                       
      <!-- content -->
      <ui:define name="content">
            
            <h:form>
              <h:dataTable value="#{checkboxHotels}" var="hot">
                   <h:column>
                          <f:facet name="header">Name</f:facet>
                          #{hot.name}
                     </h:column>
                     <h:column>
                       <f:facet name="header">
                           <h:outputText value="Select" />
                       </f:facet>
                       <h:selectBooleanCheckbox value="#{hot.selected}" />
                   </h:column>
                     
              </h:dataTable>
              <h:commandButton value="submit" action="#{testHotelCheckbox.submit}"/>
           </h:form>
      </ui:define>
                      
      </ui:composition>



      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("testHotelCheckbox")
      public class TestHotelCheckboxActionBean implements TestHotelCheckboxLocal {
           
           @PersistenceContext 
           private EntityManager em;
           
           @Logger
           Log log;
           
           @DataModel(value="checkboxHotels")
           List<Hotel> hotels;
           
           @Factory(value="checkboxHotels")
           public void getHotels(){
                 hotels = em.createQuery("select h from Hotel h order by h.name")
                                             .getResultList();
                 log.info("results.size() = " + hotels.size());
                 
           }
           
           public void submit() {
                for(int i = 0; i < hotels.size(); i++) {
                     log.info("hotel.getName() = " + ((Hotel)hotels.get(i)).getName());
                     log.info("hotel.isSelected() = " + ((Hotel)hotels.get(i)).isSelected());
                }
           }
           
           @Remove @Destroy
           public void destroy(){}
      }



      @Entity
      @Name("hotel")
      public class Hotel implements Serializable
      {
         private Long id;
         private String name;
         private String address;
         private String city;
         private String state;
         private String zip;
         private String country;
         private BigDecimal price;
         //private transient boolean selected;
         private boolean selected;
         
         @Id @GeneratedValue
         public Long getId()
         {
            return id;
         }
         public void setId(Long id)
         {
            this.id = id;
         }
         
         @Length(max=50) @NotNull
         public String getName()
         {
            return name;
         }
         public void setName(String name)
         {
            this.name = name;
         }
         
         @Length(max=100) @NotNull
         public String getAddress()
         {
            return address;
         }
         public void setAddress(String address)
         {
            this.address = address;
         }
         
         @Length(max=40) @NotNull
         public String getCity()
         {
            return city;
         }
         public void setCity(String city)
         {
            this.city = city;
         }
         
         @Length(min=4, max=6) @NotNull
         public String getZip()
         {
            return zip;
         }
         public void setZip(String zip)
         {
            this.zip = zip;
         }
         
         @Length(min=2, max=10) @NotNull
         public String getState()
         {
            return state;
         }
         public void setState(String state)
         {
            this.state = state;
         }
         
         @Length(min=2, max=40) @NotNull
         public String getCountry()
         {
            return country;
         }
         public void setCountry(String country)
         {
            this.country = country;
         }
      
         @Column(precision=6, scale=2)
         public BigDecimal getPrice()
         {
            return price;
         }
         public void setPrice(BigDecimal price)
         {
            this.price = price;
         }
         
         @Transient
         public boolean isSelected() {
             return selected;
         }
        
         public void setSelected(boolean selected) {
             this.selected = selected;
         }
      
         
         
         @Override
         public String toString()
         {
            return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
         }
      }
      



      The problem is that now that I implemented the @Transient field setter/getter solution in my project's entity class, when I exec the use case by clicking the submit button, there is no exception/stack trace in the server.log and I consistently see the following in the h:messages components on the screen:


      /testMultiCheckbox.xhtml @40,62 value="#{hardware.selected}": Error writing 'selected' on type com.cox.shims.entity.TbHardware 
      /testMultiCheckbox.xhtml @40,62 value="#{hardware.selected}": Error writing 'selected' on type com.cox.shims.entity.TbHardware 
      /testMultiCheckbox.xhtml @40,62 value="#{hardware.selected}": Error writing 'selected' on type com.cox.shims.entity.TbHardware 
      /testMultiCheckbox.xhtml @40,62 value="#{hardware.selected}": Error writing 'selected' on type com.cox.shims.entity.TbHardware 
      /testMultiCheckbox.xhtml @40,62 value="#{hardware.selected}": Error writing 'selected' on type com.cox.shims.entity.TbHardware



      The code I'm using for my project that is involved in this use case is as follows.  Any help would be greatly appreciated as this is a major drag when there is no root cause in the server.log.


      Related JIRA:


      http://jira.jboss.org/jira/browse/JBSEAM-2597


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:s="http://jboss.com/products/seam/taglib"
           template="layout/template.xhtml">
           
      <ui:define name="body">
      <h:messages styleClass="message"/>
      <!-- 
           <h:form>
                <h:dataTable  id="techQueueTable" value="#{hardwareTableList}"     var="hardware" columnClasses="center">
                          <h:column>
                               <f:facet name="header"><h:outputText value="Barcode"/></f:facet>
                               <h:outputText value="#{hardware.coxBarcode}"/>
                          </h:column>
                          
                          <h:column>
                                <f:facet name="header"><h:outputText value="Assign To User"/></f:facet>
                                <h:selectBooleanCheckbox value="#{hardware.selected}"/>
                          </h:column>                    
                </h:dataTable>
                <h:commandButton id="submit"      value="Submit Technician Changes"      action="#{techDeployToUser.submit}"/>
           </h:form>
            -->
           <h:form>
                <h:dataTable  id="techQueueTable" value="#{checkboxHotels}"     var="hardware" columnClasses="center">
                          <h:column>
                               <f:facet name="header"><h:outputText value="Barcode"/></f:facet>
                               <h:outputText value="#{hardware.coxBarcode}"/>
                          </h:column>
                          
                          <h:column>
                                <f:facet name="header"><h:outputText value="Assign To User"/></f:facet>
                                <h:selectBooleanCheckbox value="#{hardware.selected}"/>                          
                          </h:column>          
                               
                </h:dataTable>
                <h:commandButton id="submit"      value="Submit Technician Changes"      action="#{testHotelCheckbox.submit}"/>
           </h:form>
      
      </ui:define>     
      </ui:composition>



      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("testHotelCheckbox")
      public class TestHotelCheckboxActionBean implements TestHotelCheckboxLocal {
           
           //@PersistenceContext
           @In
           private EntityManager entityManager;
           
           @Logger
           Log log;
           
           @DataModel(value="checkboxHotels")
           List<TbHardware> hotels;
           
           @Factory(value="checkboxHotels")
           public void getHotels(){
                 hotels = entityManager.createQuery("select h from TbHardware h")
                                             .getResultList();
                 log.info("results.size() = " + hotels.size());
                 
           }
           
           public void submit() {
                for(int i = 0; i < hotels.size(); i++) {
                     log.info("hotel.getCoxBarcode() = " + ((TbHardware)hotels.get(i)).getCoxBarcode());
                     //log.info("hotel.getDummyData() = " + ((TbHardware)hotels.get(i)).getDummyData());
                     log.info("hotel.isSelected() = " + ((TbHardware)hotels.get(i)).isSelected());
                }
           }
           
           @Remove @Destroy
           public void destroy(){}
      }
      



      @Entity
      @Table(name = "tbHardware")
      @Name("tbHardware")
      public class TbHardware implements java.io.Serializable {
           
           @Logger
           Log log;  //externalizable (according to Pete Muir) which implements serializable
      
           private int hardwareId;
           private TbLocation tbLocation;
           private TrOwnerType trOwnerType;
           private TrHardwareStatus trHardwareStatus;
           private TbHardwareModel tbHardwareModel;
           private String coxBarcode;
           private String serialNo;
           private String description;
           private Date firstEnteredDate;
           private String enteredByUser;
           private Date lastAuditedDate;
           private BigDecimal hardwarePrice;
           private String lastUsedByNetworkId;
           private Set<TbSoftwareInstance> tbSoftwareInstances = new HashSet<TbSoftwareInstance>(
                     0);
           private Set<TbHardwareNote> tbHardwareNotes = new HashSet<TbHardwareNote>(0);
           //private boolean assignSelected;
           //private boolean removeSelected;
           private boolean selected;     
           //private String dummyData;
      
           public TbHardware() {
           }
      
           public TbHardware(int hardwareId, TbLocation tbLocation,
                     TrOwnerType trOwnerType, TrHardwareStatus trHardwareStatus,
                     TbHardwareModel tbHardwareModel, String coxBarcode, String serialNo) {
                this.hardwareId = hardwareId;
                this.tbLocation = tbLocation;
                this.trOwnerType = trOwnerType;
                this.trHardwareStatus = trHardwareStatus;
                this.tbHardwareModel = tbHardwareModel;
                this.coxBarcode = coxBarcode;
                this.serialNo = serialNo;
           }
           public TbHardware(int hardwareId, TbLocation tbLocation,
                     TrOwnerType trOwnerType, TrHardwareStatus trHardwareStatus,
                     TbHardwareModel tbHardwareModel, String coxBarcode,
                     String serialNo, String description, Date firstEnteredDate,
                     String enteredByUser, Date lastAuditedDate,
                     BigDecimal hardwarePrice, String lastUsedByNetworkId,
                     Set<TbSoftwareInstance> tbSoftwareInstances,
                     Set<TbHardwareNote> tbHardwareNotes) {
                this.hardwareId = hardwareId;
                this.tbLocation = tbLocation;
                this.trOwnerType = trOwnerType;
                this.trHardwareStatus = trHardwareStatus;
                this.tbHardwareModel = tbHardwareModel;
                this.coxBarcode = coxBarcode;
                this.serialNo = serialNo;
                this.description = description;
                this.firstEnteredDate = firstEnteredDate;
                this.enteredByUser = enteredByUser;
                this.lastAuditedDate = lastAuditedDate;
                this.hardwarePrice = hardwarePrice;
                this.lastUsedByNetworkId = lastUsedByNetworkId;
                this.tbSoftwareInstances = tbSoftwareInstances;
                this.tbHardwareNotes = tbHardwareNotes;
           }
      
           @Id
           @Column(name = "HardwareID", unique = true, nullable = false)
           public int getHardwareId() {
                return this.hardwareId;
           }
      
           public void setHardwareId(int hardwareId) {
                this.hardwareId = hardwareId;
           }
           @ManyToOne(fetch = FetchType.LAZY)
           @JoinColumn(name = "CurrentLocationNo", nullable = false)
           public TbLocation getTbLocation() {
                return this.tbLocation;
           }
      
           public void setTbLocation(TbLocation tbLocation) {
                this.tbLocation = tbLocation;
           }
           @ManyToOne(fetch = FetchType.LAZY)
           @JoinColumn(name = "OwnerTypeCode", nullable = false)
           public TrOwnerType getTrOwnerType() {
                return this.trOwnerType;
           }
      
           public void setTrOwnerType(TrOwnerType trOwnerType) {
                this.trOwnerType = trOwnerType;
           }
           @ManyToOne(fetch = FetchType.LAZY)
           @JoinColumn(name = "CurrentStatus", nullable = false)
           public TrHardwareStatus getTrHardwareStatus() {
                return this.trHardwareStatus;
           }
      
           public void setTrHardwareStatus(TrHardwareStatus trHardwareStatus) {
                this.trHardwareStatus = trHardwareStatus;
           }
           @ManyToOne(fetch = FetchType.LAZY)
           @JoinColumn(name = "HardwareModelID", nullable = false)
           public TbHardwareModel getTbHardwareModel() {
                return this.tbHardwareModel;
           }
      
           public void setTbHardwareModel(TbHardwareModel tbHardwareModel) {
                this.tbHardwareModel = tbHardwareModel;
           }
      
           @Column(name = "CoxBarcode", nullable = false, length = 200)
           //AS 05-08-08 - moving some validations for barcode here from SFSB processValueChange()...     
           @Pattern(regex="^\\d{5}$", message="Please enter a 5-digit numeric barcode (ex: 01234)")          
           public String getCoxBarcode() {
                return this.coxBarcode;
           }
      
           public void setCoxBarcode(String coxBarcode) {
                this.coxBarcode = coxBarcode;
           }
      
           @Column(name = "SerialNo", nullable = false, length = 50)
           public String getSerialNo() {
                return this.serialNo;
           }
      
           public void setSerialNo(String serialNo) {
                this.serialNo = serialNo;
           }
      
           @Column(name = "Description", length = 200)
           public String getDescription() {
                return this.description;
           }
      
           public void setDescription(String description) {
                this.description = description;
           }
      
           @Column(name = "FirstEnteredDate", length = 23)
           public Date getFirstEnteredDate() {
                return this.firstEnteredDate;
           }
      
           public void setFirstEnteredDate(Date firstEnteredDate) {
                this.firstEnteredDate = firstEnteredDate;
           }
      
           @Column(name = "EnteredByUser", length = 50)
           public String getEnteredByUser() {
                return this.enteredByUser;
           }
      
           public void setEnteredByUser(String enteredByUser) {
                this.enteredByUser = enteredByUser;
           }
      
           @Column(name = "LastAuditedDate", length = 23)
           public Date getLastAuditedDate() {
                return this.lastAuditedDate;
           }
      
           public void setLastAuditedDate(Date lastAuditedDate) {
                this.lastAuditedDate = lastAuditedDate;
           }
      
           @Column(name = "HardwarePrice", scale = 4)
           public BigDecimal getHardwarePrice() {
                return this.hardwarePrice;
           }
      
           public void setHardwarePrice(BigDecimal hardwarePrice) {
                this.hardwarePrice = hardwarePrice;
           }
      
           @Column(name = "LastUsedByNetworkID")
           public String getLastUsedByNetworkId() {
                return this.lastUsedByNetworkId;
           }
      
           public void setLastUsedByNetworkId(String lastUsedByNetworkId) {
                this.lastUsedByNetworkId = lastUsedByNetworkId;
           }
           @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbHardware")
           public Set<TbSoftwareInstance> getTbSoftwareInstances() {
                return this.tbSoftwareInstances;
           }
      
           public void setTbSoftwareInstances(
                     Set<TbSoftwareInstance> tbSoftwareInstances) {
                this.tbSoftwareInstances = tbSoftwareInstances;
           }
           @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbHardware")
           public Set<TbHardwareNote> getTbHardwareNotes() {
                return this.tbHardwareNotes;
           }
      
           public void setTbHardwareNotes(Set<TbHardwareNote> tbHardwareNotes) {
                this.tbHardwareNotes = tbHardwareNotes;
           }
           
           /*@Transient
          public boolean isAssignSelected() {
              return assignSelected;
          }
        
          public void setAssignSelected(boolean selected) {
               log.info("in setAssignSelected: selected = " + selected);
              this.assignSelected = selected;
          }
          
          @Transient
          public boolean isRemoveSelected() {
              return removeSelected;
          }
        
          public void setRemoveSelected(boolean selected) {
               log.info("in setRemoveSelected: selected = " + selected);
              this.removeSelected = selected;
          }*/
          
           //below @Transient methods work now...
           @Transient
          public boolean isSelected() {
              return selected;
          }
        
          public void setSelected(boolean selected) {
               log.info("in setSelected: coxBarcode = " + coxBarcode);
               log.info("in setSelected: selected = " + selected);
              this.selected = selected;
          }
          
          /*@Transient
          public String getDummyData() {
               return dummyData;
          }
          
          public void setDummyData(String dummyData) {
               this.dummyData = dummyData;
          }*/
           
      
      }

        • 1. Re: JSF exception being swallowed, need help plz
          admin.admin.email.tld

          issue has been resolved by using different variable and getter/setter names...


          @Transient
              public boolean getIsSelected() {
                  return isSelected;
              }
             
              public void setIsSelected(boolean selected) {
                  this.isSelected = selected;
              }



          The JSF swallowing exception is still a problem and I don't understand what the error means in terms of root cause (this works fine with the booking mod I did, see below).


          @Transient
             public boolean isSelected() {
                 return selected;
             }
            
             public void setSelected(boolean selected) {
                 this.selected = selected;
             }