Hmm... let us take a closer look at the stack trace then

Looks like type converter null threw an exception.
java.lang.NoSuchMethodException:
net.sourceforge.stripes.action.FileBean.<init>(java.lang.String)
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getConstructor(Class.java:1657)
        at 
net.sourceforge.stripes.controller.DefaultActionBeanPropertyBinder.convert(DefaultActionBeanPropertyBinder.java:961)
        at 
net.sourceforge.stripes.controller.DefaultActionBeanPropertyBinder.bind(DefaultActionBeanPropertyBinder.java:290)


                if (!"".equals(value)) {
                try {
                    if (validationInfo != null && validationInfo.encrypted()) {
                        value = CryptoUtil.decrypt(values[i]);
                    }

                    Object retval = null;
                    if (converter != null) {
                        retval = converter.convert(value, propertyType, errors);
                    }
                    else {
                        Constructor constructor = 
propertyType.getConstructor(String.class);
                        if (constructor != null) {
                            retval = constructor.newInstance(value);
                        }
                        else {
                            log.debug("Could not find a way to convert the 
parameter ",
                                    propertyName.getName(), " to a ", 
propertyType.getSimpleName(),
                                    ". No TypeConverter could be found and the 
class does not ",
                                    "have a constructor that takes a single 
String parameter.");
                        }
                    }

                    // If we managed to get a non-null converted value, add it 
to the return set
                    if (retval != null) {
                        returns.add(retval);
                    }

                    // Set the field name and value on the error
                    for (ValidationError error : errors) {
                        error.setFieldName(propertyName.getStrippedName());
                        error.setFieldValue(value);
                    }
                }
                catch (Exception e) {
                    // TODO: figure out what to do, if anything, with these 
exceptions
                    log.warn(e, "Looks like type converter ", converter, " 
threw an exception.");
                }


Ok I would guess that the offending line is Constructor constructor = 
propertyType.getConstructor(String.class);  .. it isn't surrounded by any 
checking right?  Either a) this should be prevented from running in this case 
way up in the call stack, or b) it should make sure it exists first (you say it 
does that already, but I don't see that (looking at freshly updated trunk))


I would change that to Constructor constructor = 
ReflectUtil.getConstructor(propertyType, String.class);

class ReflectUtil  {

        public static <T> Constructor<T> getConstructor(Class<T> clazz,
                        Class<?>... desiredArgs) {
                for (Constructor<T> constructor : clazz.getConstructors()) {
                        Class<?>[] constructorArgs = 
constructor.getParameterTypes();
                        if ((constructorArgs == null && desiredArgs == null)
                                        || (constructorArgs.length == 0 && 
desiredArgs.length == 0)) {
                                return constructor;   // default no arg
                        }

                        if ((constructorArgs != null && desiredArgs != null)
                                        && (constructorArgs.length == 
desiredArgs.length)) {
                                boolean matched = true;
                                for (int i = 0; i < constructorArgs.length; 
++i) {
                                        if 
(!constructorArgs[i].equals(desiredArgs[i])) {
                                                matched = false;
                                        }
                                }
                                if (matched) {
                                        return constructor;   // all args 
matched
                                }
                        }
                }
                return null;  // no match
        }

}

^ should work but is completely untested and may need a little tweaking...

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Freddy D.
Sent: Tuesday, April 15, 2008 10:41 AM
To: stripes-users@lists.sourceforge.net
Subject: Re: [Stripes-users] java.lang.NoSuchMethodException: 
net.sourceforge.stripes.action.FileBean.<init>

> The property binding engine tries to make that call reflectively.  Really it
> should check to see if such a constructor exists before just calling it and
> then spitting out an exception.  Some things were changed in
> this area between 1.4.3 and 1.5, I'm not sure if all were for the better,
> or at least done with the proper supporting code to handle such corner cases.

Not sure what's going on here, but for what it's work, the property binding
engine /does/ check the existence of the Constructor(String) before trying
to call it, and has been that way since 1.4.3 or earlier.

The type converter is null as per the logs.. I would put Stripes in debug
mode and check all the traces for more information on what's happening.

Cheers,
Freddy


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to