AEM asCS ACS-Commons javax.jcr.ValueFormatException: Can not assign a single value to multi-valued property: | Community
Skip to main content
New Participant
March 26, 2024
Solved

AEM asCS ACS-Commons javax.jcr.ValueFormatException: Can not assign a single value to multi-valued property:

  • March 26, 2024
  • 2 replies
  • 914 views

Hi ,

We are trying to import data from manage-controlled-processes.html getting below error

Caused by: javax.jcr.ValueFormatException: Can not assign a single value to multi-valued property:org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.setProperty(NodeDelegate.java:501) at org.apache.jackrabbit.oak.jcr.session.NodeImpl$38.perform(NodeImpl.java:1448) at org.apache.jackrabbit.oak.jcr.session.NodeImpl$38.perform(NodeImpl.java:1435) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:229) at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:113) at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1435) at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:377) at

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by abhishekanand_

Hi @neo-silicon 
If you’re dealing with a multi-valued property (e.g., a tag field), make sure you’re providing an array or list of values, not a single value. For example, if you’re setting tags, use an array of tag strings 

setProperty("tags", new String[]{"tag1", "tag2", "tag3"})


Check the specific line of code where the error occurs (e.g., NodeImpl.setProperty(NodeImpl.java:377)). Inspect the property name and value being set to identify any discrepancies.

2 replies

abhishekanand_
abhishekanand_Accepted solution
New Participant
March 27, 2024

Hi @neo-silicon 
If you’re dealing with a multi-valued property (e.g., a tag field), make sure you’re providing an array or list of values, not a single value. For example, if you’re setting tags, use an array of tag strings 

setProperty("tags", new String[]{"tag1", "tag2", "tag3"})


Check the specific line of code where the error occurs (e.g., NodeImpl.setProperty(NodeImpl.java:377)). Inspect the property name and value being set to identify any discrepancies.

Abhishek Anand
sateaswa94
New Participant
March 27, 2024

The root cause of the above exception is because you trying to set non array value to a multifield property. Initialise an array and add the required value to the array and set the array as the value of the property.

sateaswa94
New Participant
March 27, 2024


Use any one of the below condition before updating the property value

Sling API String val = "test"; ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if(modifiableValueMap.get("someproperty").getClass().isArray()) { modifiableValueMap.put("someproperty", new String[]{val}); } else { modifiableValueMap.put("someproperty", val); } JCR API Property property = node.getProperty("someproperty"); if(property.isMultiple()) { node.setProperty("someproperty", new String[]{val}); } else { node.setProperty("someproperty", val); }