Java Mailing List Archive

Home » FreeMarker-user »

Re: [FreeMarker-user]
BeansWrapper.populateClassMapWithPropertyDescriptor failing to create
property descriptors

Newman, John W


Replies: Find Java Web Hosting

Author LoginPost Reply
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
Unfortunately the link from Attila in there is currently dead, but I found it here:

Take a look at those and let us know what you think.

-----Original Message-----
From: Donnchadh Ó Donnabháin [mailto:donnchadh@(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 (
    at java.beans.PropertyDescriptor.setWriteMethod (
    at java.beans.PropertyDescriptor.<init>(
    at freemarker.ext.beans.BeansWrapper.populateClassMapWithPropertyDescriptor (
    at freemarker.ext.beans.BeansWrapper.populateClassMapWithBeanInfo (
    at freemarker.ext.beans.BeansWrapper.populateClassMap (
    at freemarker.ext.beans.BeansWrapper.introspectClassInternal (
    at freemarker.ext.beans.BeansWrapper.introspectClass (
    at freemarker.ext.beans.BeanModel.<init>(
    at freemarker.ext.beans.StringModel.<init>(
    at freemarker.ext.beans.StringModel$1.create(
    at freemarker.ext.beans.BeansModelCache.create (
    at freemarker.ext.util.ModelCache.getInstance (
    at freemarker.ext.beans.BeansWrapper.wrap (
    at freemarker.template.DefaultObjectWrapper.handleUnknownType (
    at freemarker.template.DefaultObjectWrapper.wrap (
    at freemarker.template.WrappingTemplateModel.wrap (
    at freemarker.template.SimpleHash.get (

Maybe this code on line 1255 of (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?


RSA(R) Conference 2012
Save $700 by Nov 18
Register now
FreeMarker-user mailing list

RSA(R) Conference 2012
Save $700 by Nov 18
Register now
FreeMarker-user mailing list
©2008 - Jax Systems, LLC, U.S.A.