Java Mailing List Archive

Home » FreeMarker-user »

BeansWrapper.populateClassMapWithPropertyDescriptor failing to create
property descriptors

Donnchadh Ó Donnabháin


Replies: Find Java Web Hosting

Author LoginPost Reply
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

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
©2008 - Jax Systems, LLC, U.S.A.