Skip to content

SpringBeanELResolver - setValue throws PropertyNotWritableException [SPR-11502] #16127

@spring-projects-issues

Description

@spring-projects-issues

Amit opened SPR-11502 and commented

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?


Affects: 3.2.2

Backported to: 3.2.9

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions