You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/12/28 18:51:52 UTC

DO NOT REPLY [Bug 32861] New: - DynaActionForm and optionsCollection get exception Cannot create iterator...

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32861>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32861

           Summary: DynaActionForm and optionsCollection get exception
                    Cannot create iterator...
           Product: Struts
           Version: 1.2.4
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Unknown
        AssignedTo: dev@struts.apache.org
        ReportedBy: gskeim@yahoo.com


I having been trying to convert existing pages from extending ActionForm to 
DynaActionForm so that I don�t have to provide the set and get.  I am having 
problems with the optionsCollection trying to get the iterator. The correct 
values are being obtained from the database and store via the LabelValueBean 
class.  The getIterator method in OptionsCollectionTag should have a 
Collection, but it throw exception at line 351. Not sure, what is wrong. Thanks 
for you help.

Greg


  
My configuration is as follows:

       <form-bean name="SiteEditorForm" type="com.wsa.core.view.SiteEditorForm">
            <form-property name="site"        type="java.lang.String"/>
            <form-property name="arraylist"   
type="com.blacklake.business.db.Site"/>
            <form-property name="sitename"    type="java.lang.String" 
initial=""/>
            <form-property name="sitedesc"    type="java.lang.String" 
initial=""/>
        </form-bean>


Partial listing of Site class that I am using:

   /**************************************************************************
    *  
    *
    **************************************************************************/
    public static Collection getArraylist() {
        
        Collection          sitecollection = new ArrayList();
        DatabaseConnection  conn = null;
        String              emessage = "";
        tbSite              dbsitelist = null;
        tbSite              dbsite = null;
        
        try {
            
            // Initialize the database and tbAddress class.
            conn = new DatabaseConnection( "development" );
            dbsitelist = new tbSite( conn.getConnection(), "default" );
            
            // Get the list from the database.
            sitecollection.add( new LabelValueBean( "--add--","0") );
            for( Iterator e=dbsitelist.searchAndRetrieveList().iterator(); 
e.hasNext(); ) {
                
                dbsite = (tbSite)e.next();
                sitecollection.add( new LabelValueBean(dbsite.getField
("SiteName"),
                                                                                
  dbsite.getField("PK_Site")) );
           }//for
            
       }//try
        catch( Exception e ) {
            emessage += e.getMessage();
        }//catch
        finally {
            // Release the object for GC.
            dbsitelist = null;
            dbsite = null;

            // Close the database cleanly.
            conn.closeConnection();
            conn = null;
        }//finally
        
return( sitecollection );
	    
    } // getArraylist
    

    /**************************************************************************
    *  
    *
    **************************************************************************/
    public String toString() {

        ArrayList sites = (ArrayList)Site.getArraylist();
        return( sites.toString() );

    } // toString


    /**************************************************************************
    *  
    *
    **************************************************************************/
    public Iterator iterator() {

        ArrayList sites = (ArrayList)Site.getArraylist();
        return( sites.iterator() );
        
        //Vector sites = Site.getSiteOptions();
        //return( sites.iterator() );

    } // toString




Reported exception:

javax.servlet.ServletException: Cannot create iterator for [LabelValueBean[--
add--, 0], LabelValueBean[development, 1], LabelValueBean[test, 2], 
LabelValueBean[production, 3]]
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
	org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
	org.apache.jsp.wsa.siteEditor_jsp._jspService(siteEditor_jsp.java:140)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter
(MonitorFilter.java:362)

root cause

javax.servlet.jsp.JspException: Cannot create iterator for [LabelValueBean[--
add--, 0], LabelValueBean[development, 1], LabelValueBean[test, 2], 
LabelValueBean[production, 3]]
	org.apache.struts.taglib.html.OptionsCollectionTag.getIterator
(OptionsCollectionTag.java:351)
	org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag
(OptionsCollectionTag.java:185)
	org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_optionsCollection_0
(siteEditor_jsp.java:386)
	org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_select_0
(siteEditor_jsp.java:358)
	org.apache.jsp.wsa.siteEditor_jsp._jspx_meth_html_form_0
(siteEditor_jsp.java:257)
	org.apache.jsp.wsa.siteEditor_jsp._jspService(siteEditor_jsp.java:101)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter
(MonitorFilter.java:362)

note The full stack trace of the root cause is available in the Apache 
Tomcat/5.0.28 logs.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org