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

SpringBeanELResolver - setValue throws PropertyNotWritableException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.2.2
    • Fix Version/s: 3.2.9, 4.0.3
    • Component/s: None
    • Labels:
    • Last commented by a User:
      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

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            table1 Amit
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 31 weeks, 3 days ago