You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joseph Prosser <jo...@yahoo.com> on 2003/07/26 17:11:10 UTC

lazyList + GenericFactory = NoSuchMethodError

Hey Folks,
I'm trying to implement the lazyList + GenericFactory 
solution for posting forms w/ nested collections.

I'm using the GenericFactory implementation (included 
below) that was posted on this list.

I make it into the GenericFactory constructor, but it 
looks to be crashing in lazyList.

Below is the exception.  If anyone has run into this,
I'd sure appreciate learning about how they handled
it.

[INFO] DataDetailForm - -DataDetailForm Constructor
[INFO] GenericFactory - -Generic factory constructor
for 
class=net.nocmanage.coreserver.beans.InterfaceBean
java.lang.NoSuchMethodError: 
org.apache.commons.collections.ListUtils.lazyList(Ljava/util/List;Lorg/apache/commons/collections/F
actory;)Ljava/util/List;
         at 
net.nocmanage.coreserver.struts.forms.DataDetailForm.<init>(DataDetailForm.java:54)


Thanks,
-Joe Prosser



public class DataDetailForm extends ModelForm {

  private static Log log = 
   LogFactory.getLog("struts.forms.DataDetailForm");
   Collection interfaces;
   public DataDetailForm() {
   super();
   log.info("DataDetailForm Constructor" );

   interfaces = ListUtils.lazyList(
     new ArrayList(),
     new
net.nocmanage.coreserver.common.GenericFactory
    
("net.nocmanage.coreserver.beans.InterfaceBean"));
   }

     public ArrayList getInterfaces() {
         log.info("getinterfaces() " );
         return (ArrayList) interfaces;
     }


 public void setInterfaces(ArrayList al) {

   this.interfaces = ListUtils.lazyList(
         new ArrayList(al),new GenericFactory  
   ("net.nocmanage.coreserver.beans.InterfaceBean"));

   log.info("setinterfaces()" );
 }


}




-------------------------------------
package org.apache.commons.collections;

import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.collections.Factory;
/**
  *
  * This is a simple GenericFactory that uses
  * reflection to
  * instantiate a new object that will populate a 
   * lazyList
  *
  * @author  <a href="mailto:mail@phase.ws">Brandon 
   * Goodin</a>
  */
public class GenericFactory implements Factory {

     private static final Log log = 
LogFactory.getLog(GenericFactory.class);
     
     private String className;
     private Object object;

     /**
      *  Create a new instance of GenericFactory
      *
      *  @param className value is a fully 
      *  qualified class name of
      *  the class the create method will instantiate
      *
      **/
     public GenericFactory(String className) {
       this.className = className;
       log.info("Generic factory constructor for
class=" + className);
     }

     /**
      *
      * Returns object to calling method
      *
      */
     public Object create() {
         log.info("Generic factory create");
         try {
             object = null;
             Class classDefinition =
Class.forName(className);
             object = classDefinition.newInstance();
         } catch (InstantiationException ex) {
             log.error( "ERROR: Exception: " + ex );
         } catch (IllegalAccessException ex) {
             log.error( "ERROR: Exception: " + ex );
         } catch (ClassNotFoundException ex) {
             log.error( "ERROR: Exception: " + ex );
         }
         return object;

     }

}



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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