Re: BeansWrapper.populateClassMapWithPropertyDescriptor failing to create property descriptors
"Newman, John W" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <721876F56F42304A8CB1CCFF9BFC09BB12985B3F@MSXMBXNSPRD09.acct.upmchs.net> |
I have ran into this a few times myself. I still have the issue in our bug tracker back from 2008. It looks like the same block of code you posted. One complaint I had in there was that the NAME of the property isn't written into the log. It was very difficult to figure out exactly what introspection couldn't be performed. If I just had the name of the property in there, it would have been much easier to isolate the problem. I closed at as "fixed, with a patch in freemarker 2.3.14". Here's the thread I made http://freemarker.624813.n4.nabble.com/Beanswrapper-java-beans-IntrospectionException-type-mismatch-between-read-and-write-methods-td626427.html#none Unfortunately the link from Attila in there is currently dead, but I found it here: http://freemarker.624813.n4.nabble.com/BeansWrapper-issue-with-quot-overlapping-quot-getters-td627804.html Take a look at those and let us know what you think. -----Original Message----- From: Donnchadh Ó Donnabháin [mailto:[email protected]] Sent: Tuesday, November 15, 2011 10:27 To: FreeMarker-user Subject: [FreeMarker-user] BeansWrapper.populateClassMapWithPropertyDescriptor failing to create property descriptors Hi guys, This isn't a huge issue for us at the moment but it generates an ugly warning and prevents us from using certain properties in our FreeMarker. Some of our domain model classes use generics, with some accessor methods using type parameters. The java compiler generates bridge methods in subclasses of our generic classes and these bridge methods have a return type that doesn't match the setter in the parent class, resulting in the following exception: WARN beans:116 - Failed creating a publicly-accessible property descriptor for ... java.beans.IntrospectionException: type mismatch between read and write methods at java.beans.PropertyDescriptor.findPropertyType(PropertyDescriptor.java:603) at java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:270) at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:117) at freemarker.ext.beans.BeansWrapper.populateClassMapWithPropertyDescriptor(BeansWrapper.java:1255) at freemarker.ext.beans.BeansWrapper.populateClassMapWithBeanInfo(BeansWrapper.java:1152) at freemarker.ext.beans.BeansWrapper.populateClassMap(BeansWrapper.java:1072) at freemarker.ext.beans.BeansWrapper.introspectClassInternal(BeansWrapper.java:1010) at freemarker.ext.beans.BeansWrapper.introspectClass(BeansWrapper.java:969) at freemarker.ext.beans.BeanModel.<init>(BeanModel.java:140) at freemarker.ext.beans.StringModel.<init>(StringModel.java:90) at freemarker.ext.beans.StringModel$1.create(StringModel.java:75) at freemarker.ext.beans.BeansModelCache.create(BeansModelCache.java:45) at freemarker.ext.util.ModelCache.getInstance(ModelCache.java:115) at freemarker.ext.beans.BeansWrapper.wrap(BeansWrapper.java:468) at freemarker.template.DefaultObjectWrapper.handleUnknownType(DefaultObjectWrapper.java:144) at freemarker.template.DefaultObjectWrapper.wrap(DefaultObjectWrapper.java:128) at freemarker.template.WrappingTemplateModel.wrap(WrappingTemplateModel.java:134) at freemarker.template.SimpleHash.get(SimpleHash.java:224) Maybe this code on line 1255 of BeansWrapper.java (FreeMarker 2.3.17): pd = new PropertyDescriptor(pd.getName(), publicReadMethod, pd.getWriteMethod()); could be replaced with something like this: Method writeMethod = pd.getWriteMethod(); if (writeMethod != null && (pd.getWriteMethod().getParameterTypes().length != 1 || pd.getWriteMethod().getParameterTypes()[0] != publicReadMethod.getReturnType())) { writeMethod = null; } pd = new PropertyDescriptor(pd.getName(), publicReadMethod, writeMethod); What do you think? Donnchadh ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1