tonybaines/gestalt

Custom types fail to parse

Closed this issue · 7 comments

Following these instructions https://github.com/tonybaines/gestalt#custom-types, I was expecting the following code to work

import com.github.tonybaines.gestalt.Configurations;
import com.github.tonybaines.gestalt.Default;
import com.google.common.base.Strings;

/**
 * Created by 702161900 on 16/03/2015.
 */
public class GestaltSpike {


    public interface AppConfig {

        @Default.String("ooo")
        SimpleType getSimpleType();
    }


    public static class SimpleType {
        private final int v;

        public static final SimpleType fromString(String s) {
            return new SimpleType(s.length());
        }

        public SimpleType(int v) {
            this.v = v;
        }

        public int getValue() {
            return v;
        }

        public String toString() {
            return Strings.repeat("o", v);
        }
    }

    public static void main(String[] args) {
        SimpleType st = SimpleType.fromString("---");
        System.out.println("st: " + st.getValue());
        AppConfig config = Configurations.definedBy(AppConfig.class).fromProperties(System.getProperties()).without(Configurations.Feature.ExceptionOnNullValue).done();

        Configurations.toXml(config, AppConfig.class);

        System.out.println("st: " + config.getSimpleType().getValue());
    }
}

But, when executed this is the output:

st: 3
2015-03-16 14:58:13,104 [WARN] [main] Failed to find a definition for getSimpleType in Properties
Exception in thread "main" com.google.common.util.concurrent.ExecutionError: java.lang.VerifyError: Bad <init> method call from inside of a branch
Exception Details:
  Location:
    com/github/tonybaines/gestalt/ConfigurationException.<init>([Ljava/lang/String;)V @99: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: b800 164d 04bd 0029 5903 2c12 6f32 2b12
    0000010: 71b9 0075 0300 5359 10ff 1204 b800 4a2a
    0000020: 5fab 0000 0000 00b0 0000 0005 8794 83a0
    0000030: 0000 0033 aad3 b1ff 0000 0048 c783 a456
    0000040: 0000 005b f0c1 c756 0000 0088 0000 9b75
    0000050: 0000 00a7 5f5a 5903 3212 4cb8 0050 c000
    0000060: 4c5f 57b7 0053 a700 755f 5a59 0332 b800
    0000070: 3fc0 0032 5f57 b700 56a7 0062 5f5a 5903
    0000080: 32b8 003f c000 325f 5904 3212 4cb8 0050
    0000090: c000 4c5f 5905 32b8 005c 5f59 0632 b800
    00000a0: 5c5f 57b7 005f a700 355f 5a59 0332 b800
    00000b0: 3fc0 0032 5f59 0432 124c b800 50c0 004c
    00000c0: 5f57 b700 18a7 0016 5f5a 57b7 0062 a700
    00000d0: 0dbb 0064 5912 66b7 0067 bf57 2ab6 001c
    00000e0: 4e2d 2a5f b500 1e2d 57b1               
  Stackmap Table:
    full_frame(@84,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@105,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@124,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@169,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@200,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@209,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@219,{Object[#2],Object[#120],Object[#107]},{Object[#109]})

    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
    at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4736)
    at com.google.common.cache.Cache$get.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.github.tonybaines.gestalt.sources.features.CachingDecorator.lookup(CachingDecorator.groovy:24)
    at com.github.tonybaines.gestalt.ConfigSource$lookup.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.github.tonybaines.gestalt.DynoClass$_getMapAsInterface_closure1_closure3.doCall(DynoClass.groovy:21)
    at com.github.tonybaines.gestalt.DynoClass$_getMapAsInterface_closure1_closure3.call(DynoClass.groovy)
    at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:50)
    at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:81)
    at com.sun.proxy.$Proxy4.getSimpleType(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1722)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3458)
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:173)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:452)
    at com.github.tonybaines.gestalt.serialisation.ConfigXmlSerialiser$_interfaceToClosure_closure1_closure2.doCall(ConfigXmlSerialiser.groovy:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at groovy.lang.Closure.call(Closure.java:423)
    at groovy.lang.Closure.call(Closure.java:439)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
    at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.github.tonybaines.gestalt.serialisation.ConfigXmlSerialiser$_interfaceToClosure_closure1.doCall(ConfigXmlSerialiser.groovy:33)
    at com.github.tonybaines.gestalt.serialisation.ConfigXmlSerialiser$_interfaceToClosure_closure1.doCall(ConfigXmlSerialiser.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at groovy.lang.Closure.call(Closure.java:423)
    at groovy.lang.Closure.call(Closure.java:417)
    at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:143)
    at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:907)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:884)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:164)
    at com.github.tonybaines.gestalt.serialisation.ConfigXmlSerialiser.toXmlString(ConfigXmlSerialiser.groovy:24)
    at com.github.tonybaines.gestalt.serialisation.ConfigXmlSerialiser$toXmlString.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.github.tonybaines.gestalt.Configurations$SerialisationBuilder.toXml(Configurations.groovy:166)
    at com.github.tonybaines.gestalt.Configurations$SerialisationBuilder$toXml$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.github.tonybaines.gestalt.Configurations.toXml(Configurations.groovy:134)
    at com.github.tonybaines.gestalt.Configurations.toXml(Configurations.groovy:133)
    at com.bt.uta.broker.spikes.GestaltSpike.main(GestaltSpike.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.VerifyError: Bad <init> method call from inside of a branch
Exception Details:
  Location:
    com/github/tonybaines/gestalt/ConfigurationException.<init>([Ljava/lang/String;)V @99: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: b800 164d 04bd 0029 5903 2c12 6f32 2b12
    0000010: 71b9 0075 0300 5359 10ff 1204 b800 4a2a
    0000020: 5fab 0000 0000 00b0 0000 0005 8794 83a0
    0000030: 0000 0033 aad3 b1ff 0000 0048 c783 a456
    0000040: 0000 005b f0c1 c756 0000 0088 0000 9b75
    0000050: 0000 00a7 5f5a 5903 3212 4cb8 0050 c000
    0000060: 4c5f 57b7 0053 a700 755f 5a59 0332 b800
    0000070: 3fc0 0032 5f57 b700 56a7 0062 5f5a 5903
    0000080: 32b8 003f c000 325f 5904 3212 4cb8 0050
    0000090: c000 4c5f 5905 32b8 005c 5f59 0632 b800
    00000a0: 5c5f 57b7 005f a700 355f 5a59 0332 b800
    00000b0: 3fc0 0032 5f59 0432 124c b800 50c0 004c
    00000c0: 5f57 b700 18a7 0016 5f5a 57b7 0062 a700
    00000d0: 0dbb 0064 5912 66b7 0067 bf57 2ab6 001c
    00000e0: 4e2d 2a5f b500 1e2d 57b1               
  Stackmap Table:
    full_frame(@84,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@105,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@124,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@169,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@200,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@209,{UninitializedThis,Object[#120],Object[#107]},{Object[#109],UninitializedThis})
    full_frame(@219,{Object[#2],Object[#120],Object[#107]},{Object[#109]})

    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
    at java.lang.Class.getDeclaredConstructors(Class.java:1906)
    at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:69)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:66)
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
    at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:258)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:189)
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:193)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:158)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:148)
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:131)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:209)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:241)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:859)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)
    at com.github.tonybaines.gestalt.sources.BaseConfigSource.lookup(BaseConfigSource.groovy:53)
    at com.github.tonybaines.gestalt.ConfigSource$lookup.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.github.tonybaines.gestalt.sources.features.ValidatingDecorator.lookup(ValidatingDecorator.groovy:22)
    at com.github.tonybaines.gestalt.ConfigSource$lookup.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.github.tonybaines.gestalt.sources.CompositeConfigSource.tryAll(CompositeConfigSource.groovy:21)
    at com.github.tonybaines.gestalt.sources.CompositeConfigSource$tryAll.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
    at com.github.tonybaines.gestalt.sources.CompositeConfigSource.lookup(CompositeConfigSource.groovy:16)
    at com.github.tonybaines.gestalt.ConfigSource$lookup.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.github.tonybaines.gestalt.sources.features.CachingDecorator$1.call(CachingDecorator.groovy:26)
    at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4739)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
    ... 80 more

Seems to be an interaction with default values, passing in a value for simpleConfig=xxxx works

Fixed for v0.8.7

hi - looks like I am having a different problem

2015-03-20 17:25:17,861 [ERROR][Launcher(main)] Error running application
groovy.lang.MissingPropertyException: No such property: toString for class: com.bt.uta.broker.common.types.SimpleDuration
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:454)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$_recursiveValidation_closure1.doCall(ReflectionValidator.groovy:26)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy:23)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.this$2$recursiveValidation(ReflectionValidator.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$_recursiveValidation_closure1.doCall(ReflectionValidator.groovy:42)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy:23)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.this$2$recursiveValidation(ReflectionValidator.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$_recursiveValidation_closure1.doCall(ReflectionValidator.groovy:42)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy:23)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.this$2$recursiveValidation(ReflectionValidator.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$_recursiveValidation_closure1.doCall(ReflectionValidator.groovy:42)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy:23)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.this$2$recursiveValidation(ReflectionValidator.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$_recursiveValidation_closure1.doCall(ReflectionValidator.groovy:42)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:439)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy:23)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.recursiveValidation(ReflectionValidator.groovy)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.this$2$recursiveValidation(ReflectionValidator.groovy)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$this$2$recursiveValidation$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
at com.github.tonybaines.gestalt.validation.ReflectionValidator.validate(ReflectionValidator.groovy:18)
at com.github.tonybaines.gestalt.validation.ReflectionValidator$validate.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at com.github.tonybaines.gestalt.Configurations.validate(Configurations.groovy:41)

Can you share the code for SimpleDuration ?

Can't reproduce this, the test below throws no exception. What does the config interface look like?

import spock.lang.Specification

class BugReportSpec extends Specification {
  interface Bug18Config {
    SimpleDuration getDuration()
  }
  def "Issue 18"() {
    given:
    Properties props = new Properties() {{
      put("duration", "1s")
    }}
    when:
    Bug18Config config = Configurations.definedBy(Bug18Config).fromProperties(props).done()
    Configurations.validate(config, Bug18Config)
    Configurations.serialise(config, Bug18Config).toXml()

    then:
    thrown(groovy.lang.MissingPropertyException)

  }
}

I did get a similar error by putting a toString in the config interface though

  interface Bug18Config {
    Sub getSub()
    String toString()
  }

Is there a chance that you've accidentally done the same?