Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-11502

SpringBeanELResolver - setValue throws PropertyNotWritableException

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Complete
    • 3.2.2
    • 3.2.9, 4.0.3
    • None
    • true

    Description

      I am trying to upgrade spring from 3.2.1 to 4.0.2 which requires us to use <el-resolver> instead of <variable-resolver> (it was deprecated from quite sometime). The upgrade throws an PropertyNotWritableException after using SpringBeanFacesELResolver. The exception is thrown by the setValue() method which checks if the requested bean is present in the BeanFactory. If found, a PropertyNotWritableException is thrown. I would like to understand the root cause of the exception which is not clear from its implementation.

      public void setValue(ELContext elContext, Object base, Object property, Object value) throws ELException {
      		if (base == null) {
      			String beanName = property.toString();
      			BeanFactory bf = getBeanFactory(elContext);
      			if (bf.containsBean(beanName)) {
      				throw new PropertyNotWritableException(
      						"Variable '" + beanName + "' refers to a Spring bean which by definition is not writable");
      			}
      		}
      	}
      

      The setValue() implementation doesn't set the value but just do a check. On debugging I found the value of beanName, value and property refer to the same backing bean. Does that cause the issue? If so why?

      Attachments

        Activity

          People

            juergen.hoeller Juergen Hoeller
            table1 Amit
            Archiver:
            tmarshall Trevor Marshall
            Spring Issues Spring Issues

            Dates

              Created:
              Updated:
              Resolved:
              Archived:
              4 years, 21 weeks, 1 day ago