2 Replies Latest reply on Sep 11, 2007 1:45 PM by asookazian

    IllegalArgumentException when pre-loading SFSB instance vari

    asookazian

      Seam 1.2.1.GA
      JBoss 4.0.5.GA
      ICEfaces-1.6.1

      I have incorporated my files below (including SFSB local interface) in the Seam icefaces example project. Trying to get the dynamic data table based on sproc to render properly. Richfaces apparently doesn't support this functionality but there is a Tomahawk <t:columns> tag we may try. Also, is it true that you can not use Richfaces and ICEfaces in the same project? If not, is it possible to use Richfaces and Tomahawk in the same project?

      getting the following exception when JSF is rendered after pages.xml config is causing the pre-loading of the choices List in SFSB. Seems that the instance variable is possibly getting set to null after it's loaded properly in the SFSB. Session-scoped SFSB, so the instance variable should be available (ie. loaded, not null) in the JSF when <f:selectItems value="#{columnsBean.choices}"/> is processed.

      08:08:32,853 ERROR [[Blocking Servlet]] Servlet.service() for servlet Blocking Servlet threw exception
      java.lang.IllegalArgumentException: Value binding '#{columnsBean.choices}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /testDatatable.xhtml][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id1][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id7][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: document][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: container][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: content][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id15][Class: javax.faces.component.html.HtmlForm,Id: _id16][Class: javax.faces.component.html.HtmlPanelGrid,Id: roles_grid][Class: javax.faces.component.html.HtmlPanelGrid,Id: select_grid][Class: javax.faces.component.html.HtmlSelectManyCheckbox,Id: allRoles][Class: javax.faces.component.UISelectItems,Id: _id23]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null


      pages.xml:

      <!DOCTYPE pages PUBLIC
       "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
       "http://jboss.com/products/seam/pages-1.2.dtd">
      
      <pages>
       <page view-id="/hotel.xhtml">View hotel: #{hotel.name}</page>
       <page view-id="/book.xhtml">Book hotel: #{hotel.name}</page>
       <page view-id="/confirm.xhtml">Confirm: #{booking.description}</page>
       <page view-id="/testDatatable.xhtml">
       <action execute="#{columnsBean.getSeedSelection}"/>
       </page>
      </pages>


      testDatatable.xhtml:

      <!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:ice="http://www.icesoft.com/icefaces/component"
       template="template.xhtml">
      
      <!-- content -->
      <ui:define name="content">
      
      
      
      
       <div class="section">
      
      
      
      
       <h:form>
      
       <h:panelGrid id="roles_grid" columns="1">
       <h1><h:outputText id="userRoleInfo" value="Filter by Role(s)"/></h1><br/>
      
      
       <h:selectBooleanCheckbox/>
       <b><h:outputText id="labelViewAll" value="View All"/></b>
       <br/><br/>
      
       <h:panelGrid id="select_grid" columns="1">
       <h:selectManyCheckbox id="allRoles"
       value="#{columnsBean.selectedChoices}"
       layout="pageDirection">
       <f:selectItems value="#{columnsBean.choices}"/>
       </h:selectManyCheckbox>
      
       </h:panelGrid>
      
       <h:commandButton id="searchButton" value="Run" action="#{columnsBean.viewRoles}">
       <ui:debug />
       </h:commandButton>
       <br/>
      
       <ice:dataTable id="dataTbl" var="item" value="#{columnsBean.rowDataModel}"
       columnClasses="columnsColumn"
       rows="#{columnsBean.rows}">
      
       <ice:columns id="columnDataModel" value="#{columnsBean.columnDataModel}"
       var="column">
       <f:facet name="header">
       <ice:panelGroup >
       <ice:outputText id="rowData" value="#{columnsBean.columnDataModel.rowData}"/>
       </ice:panelGroup>
       </f:facet>
      
       <ice:panelGroup style="text-align: center; white-space: nowrap;" >
       <ice:outputText id="cellValue"
       value="#{columnsBean.cellValue}"/>
      
       </ice:panelGroup>
      
       </ice:columns>
      
       </ice:dataTable>
      
       </h:panelGrid>
      
       </h:form>
       </div>
      
      
      
      </ui:define>
      
      
      
      </ui:composition>



      ColumnsBean:

      package org.jboss.seam.example.booking;
      
      import java.sql.CallableStatement;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.ResultSetMetaData;
      import java.sql.SQLException;
      import java.util.ArrayList;
      import java.util.List;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.faces.model.DataModel;
      import javax.faces.model.ListDataModel;
      import javax.faces.model.SelectItem;
      
      import org.apache.log4j.Logger;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.ScopeType;
      
      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("columnsBean")
      public class ColumnsBean implements ColumnsBeanLocal {
      
       Logger log = Logger.getLogger(this.getClass());
      
       private ResultSet rs = null;
       private CallableStatement cstmt = null;
       private Connection con = null;
      
       private final String url = "jdbc:sqlserver://CORG0DV02:3220;databaseName=boBETS";
      
       private final String username = "_AppUser_JavaTestAcct";
       private final String password = "JavaTestAcct";
      
      // row columna data map
       private DataModel columnDataModel;
       private DataModel rowDataModel;
      
       // default column and row values
       private int columns = 0;
       private int rows = 0;
      
       //2D array to save the table values to.
       private String table[][];
      
       /*
       * Contains the results of the choices the user made on the selectManyCheckbox
       * Gets seeded with default values in @see populate()
       */
       String[] selectedChoices;
      
       List<SelectItem> choices;
      
       /*
       * use this to decide when to show the commandButton, selectManyCheckbox, selectOneMenu
       */
       String alreadyPopulated;
      
       public ColumnsBean() {
      
       // calulate rows
       //calculateRows();
      
       //updateTableColumns(null);
       }
      
       /**
       * Seed the initial choices as well as those items user can select from
       */
       private void populate() {
      
       log.info("in populate()");
      
       try {
      
      
       Connection con = DriverManager.getConnection(url, username, password);
      
       cstmt = con.prepareCall("{call usp_u_adm_select_Role}");
       rs = cstmt.executeQuery();
      
      
       choices = new ArrayList<SelectItem>();
       while(rs.next()) {
       choices.add(new SelectItem(rs.getString("ApplicationRoleID"), rs.getString("Name")));
      
       String name = rs.getString("Name");
       log.info("populate(): name = " + name);
      
       String applicationRoleID = rs.getString("ApplicationRoleID");
       log.info("populate(): applicationRoleID = " + applicationRoleID);
      
       }
       alreadyPopulated = "a value indicating we are populated";
      
       }
       catch(Exception e) {
       e.printStackTrace();
       }
       finally {
       this.cleanUp();
       }
      
      
       }
      
       public void getSeedSelection() {
       log.info("in getSeedSelection()");
       populate();
      
       }
      
      
       public String getCellValue() {
       log.info("in getCellValue()");
      
       if (rowDataModel.isRowAvailable() &&
       columnDataModel.isRowAvailable()) {
      
       // get the index of the row and column that this method is being
       // called for
       int row = rowDataModel.getRowIndex();
       int col = columnDataModel.getRowIndex();
      
       //return the element at the specified column and row
       return table[col][row];
       }
       // empty field.
       return "-";
       }
      
      
       public DataModel getColumnDataModel() {
       log.info("in getColumnDataModel()");
      
       return columnDataModel;
       }
      
       public int getColumns() {
       log.info("in getColumns()");
      
       return columns;
       }
      
       public DataModel getRowDataModel() {
       log.info("in getRowDataModel()");
      
       return rowDataModel;
       }
      
       public int getRows() {
       log.info("in getRows()");
      
       return rows;
       }
      
       public void setColumns(int columns) {
       log.info("in setColumns()");
      
       this.columns = columns;
       }
      
      
       //public void updateTableColumns(ValueChangeEvent event) {
       public void loadDataModels() {
       log.info("in updateTableColumns()");
      
      
       }
      
       public void viewRoles() {
      
       log.info("viewRoles: step 0");
       viewRolesData(selectedChoices);
       log.info("viewRoles: step 1");
       //displayViewRolesDataTable = true;
      
       }
      
       private void viewRolesData(String[] selectedChoices) {
      
       log.info("begin viewRolesData()");
      
       try {
       //using existing stored proc for now; build XML string to pass as param to sproc
      
       String appRoleIDString = "";
      
       for(String myChoices : selectedChoices) {
       appRoleIDString += "<ApplicationRole ApplicationRoleID=\""+myChoices+"\" />";
       }
      
       log.info("appRoleIDString = " + appRoleIDString);
      
       String xmlParam = "<?xml version=\"1.0\" standalone=\"yes\"?><root>" + appRoleIDString + "</root>";
      
       log.info("in viewRoles: xmlParam = " + xmlParam);
      
       con = DriverManager.getConnection(url, username, password);
      
       cstmt = con.prepareCall("{call usp_u_adm_select_ViewUserRole(?)}");
       cstmt.setString(1, xmlParam);
      
       //NOTE: need to figure out how to get scrollable resultset to work...
       ResultSet rsCopy = cstmt.executeQuery();
       ResultSetMetaData rsmd = rsCopy.getMetaData();
      
       // get columncount of resultset
       int numberOfColumns = rsmd.getColumnCount();
       log.info("numberOfColumns: "+numberOfColumns);
      
       int numberOfRows = 0;
      
       while (rsCopy.next()) {
       numberOfRows++;
       }
      
       rs = cstmt.executeQuery();
      
      
       log.info("numberOfRows: "+numberOfRows);
      
      
       ArrayList<String> columnList = new ArrayList<String>();
       ArrayList<String> rowList = new ArrayList<String>();
       table = new String[numberOfColumns][numberOfRows];
      
       //find the column names of the resultset
       log.info("columnNames are:");
       for (int i = 1; i <= numberOfColumns; i++) {
       table[i-1][0] = rsmd.getColumnName(i);
       log.info(table[i-1][0]);
       columnList.add(rsmd.getColumnName(i));
      
       }
      
       //test
       for(int i = 0; i < columnList.size(); i++) {
       log.info("columnList["+i+"] = " + columnList.get(i));
       }
       //end test
      
       String cellData;
       int j=1;
      
       while(rs.next() && j <= numberOfRows) {
       for( int i=1; i <= numberOfColumns; i++ ){
      
       cellData = rs.getString(i);
      
       table[i-1][j-1] = cellData;
      
       rowList.add(cellData);
       }
       j++;
       }
      
       // test
       for(int i = 0; i < rowList.size(); i++) {
       log.info("rowList["+i+"] = " + rowList.get(i));
       }
       //end test
      
       rowDataModel = new ListDataModel(rowList);
       columnDataModel = new ListDataModel(columnList);
      
      
      
       if (rsCopy != null) rsCopy.close();
       }
       catch(Exception e) {
       e.printStackTrace();
       }
       finally {
       this.cleanUp();
      
       }
      
       }
      
       public List<SelectItem> getChoices() {
       log.info("Retrieving all possible selections");
       return choices;
       }
      
       public String[] getSelectedChoices() {
       log.info("Retrieving the default selections, String[]");
       return selectedChoices;
       }
      
       public void setSelectedChoices(String[] selected) {
       log.info("Setting the new selections, String[]");
       this.selectedChoices = selected;
       }
      
       private void cleanUp() {
       try {
       if (rs != null) rs.close();
       if (cstmt != null) cstmt.close();
       if (con != null) con.close();
       }
       catch(SQLException e) {
       e.printStackTrace();
       }
       }
      
       @Destroy @Remove
       public void destroy() {
       log.info("in destroy()");
       }
      
      }







        • 1. Re: IllegalArgumentException when pre-loading SFSB instance
          asookazian

          also, the destroy() method of the SFSB is not being exec'd during or after the use case. I see no logging as such in the server.log. So that doesn't explain it.

          • 2. Re: IllegalArgumentException when pre-loading SFSB instance
            asookazian

            when I click the Run button on the JSF:

            <h:commandButton id="searchButton" value="Run" action="#{columnsBean.viewRoles}">

            the wrong method is being exec'd on the SFSB based on the output in the server.log. It's calling the getChoices() method in the SFSB when I click Run button.

            Why does this happen? seems like a bug. I will try with a fresh JBoss extraction...

            2007-09-11 10:42:14,796 INFO [org.jboss.seam.example.booking.ColumnsBean] Retrieving all possible selections
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] after phase: PROCESS_VALIDATIONS(3)
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.afterPhase
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postCreate.org.jboss.seam.core.validation
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2007-09-11 10:42:14,796 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.validationFailed
            2007-09-11 10:42:14,796 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/seam-icefaces].[Blocking Servlet]] Servlet.service() for servlet Blocking Servlet threw exception
            java.lang.IllegalArgumentException: Value binding '#{columnsBean.choices}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /testDatatable.xhtml][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id1][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id7][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: document][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: container][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: content][Class: com.icesoft.faces.component.UIXhtmlComponent,Id: _id15][Class: javax.faces.component.html.HtmlForm,Id: _id16][Class: javax.faces.component.html.HtmlPanelGrid,Id: roles_grid][Class: javax.faces.component.html.HtmlPanelGrid,Id: select_grid][Class: javax.faces.component.html.HtmlSelectManyCheckbox,Id: allRoles][Class: javax.faces.component.UISelectItems,Id: _id23]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null