java.lang.IllegalArgumentException: Value for key (property name) can't be put into node | Community
Skip to main content
Level 2
Jan 25, 2018 2:51 PM UTC

java.lang.IllegalArgumentException: Value for key (property name) can't be put into node

Hi everyone,

                     i am trying to add/update new/existing property with value to asset metadata and when i say resolver.commit(), it results in following exception

java.lang.IllegalArgumentException: Value for key (property name here) can't be put into node: [Ljava.lang.String;@1455d8b2

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:458)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:47)

aused by: javax.jcr.version.VersionException: Cannot set property. Node [path/to/asset/jcr:content/metadata] is checked in.

at org.apache.jackrabbit.oak.jcr.session.NodeImpl$36.checkPreconditions(NodeImpl.java:1404)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:615)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:205)

at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1399)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:378)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:453)

... 19 common frames omitted

E2: java.lang.IllegalArgumentException: Value for key (some other property)  can't be put into node: update (value)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:458)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:47)

aused by: javax.jcr.version.VersionException: Cannot set property. Node [path/to/asset/jcr:content/metadata] is checked in.

at org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.checkPreconditions(NodeImpl.java:1368)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:615)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:205)

at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1363)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:351)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:455)

... 21 common frames omitted

When i reprocess the same asset for creating/updating same metadata property, it works well. Please suggest any improvements here.

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

21 replies

sriramking
New Participant
Jan 9, 2019 6:47 PM UTC

This happens when the map already has key with same name. to update you have to remove it and then put new values like map.remove(propertyname); map.put(propertyname,value);resourceResolver.commit();

Hope it helps.

Translate
joerghoh
Employee
Jan 30, 2018 10:09 PM UTC

Have you seen that the exception contains this line:

> javax.jcr.version.VersionException: Cannot set property. Node [path/to/asset/jcr:content/metadata] is checked in.

You need to check out that node first to continue to save() properties. Not sure why it has been checked-in without being checked-out.

Jörg

Translate
Level 2
Jan 31, 2018 3:06 AM UTC

Hi Jörg Hoh,

                        yes, i could see version exception as follows,

Caused by: javax.jcr.version.VersionException: Cannot set property. Node [/content/dam/path/to/asset/jcr:content/metadata] is checked in.

at org.apache.jackrabbit.oak.jcr.session.NodeImpl$36.checkPreconditions(NodeImpl.java:1404)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:615)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:205)

at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1399)

at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:378)

at org.apache.sling.jcr.resource.internal.JcrModifiableValueMap.put(JcrModifiableValueMap.java:453)

I am wondering who is checking in this asset. Is there any way to figure out?

Thanks & Regards,

Radhakrishna.

Translate
joerghoh
Employee
Jan 31, 2018 7:25 AM UTC

Hi,

that's not immediately visible. I remember cases where this happened for pages on "pagemanager.createVersion()", could be for assets the same. In general, node.checkin() and node.checkout() are part of the versioning. Maybe this can help you to track down suspect log entries.

Jörg

Translate
BrijeshYadav
Level 5
Jan 26, 2018 10:41 AM UTC

Try Asset API. Asset ("The Adobe AEM Quickstart and Web Application.")

Asset is created by AssetManager and can be retrieved either via AssetManager or by adapting a asset Resource to an Asset.

     eg:

     // to create an asset

     AssetManager assetManager = resolver.adaptTo(AssetManager.class);

     Asset newAsset = assetManager.createAsset("/path/to/asset/document.pdf");

     // to get an existing asset

     Asset asset = assetManager.getAsset("/path/to/asset/document.pdf");

     // to get asset by adapting

     Asset asset = resource.adaptTo(Asset.class);

Asset properties can be retrieved or set by adapting it to a ValueMap.

     eg:

     // to get Asset properties value map

     ValueMap map = asset.adaptTo(ValueMap.class);

/Brijesh Yadav

Translate
Level 2
Jan 26, 2018 11:19 AM UTC

Hi Yadav Brijesh,

                            thanks for your suggestion. I would look to understand your suggestion using Asset API. What advantage are we going to get when compared to Resource. Can you please help putting your view here and how that helps this problem to be solved?

Thanks & Regards,

Radhakrishna.

Translate
smacdonald2008
Level 10
Jan 26, 2018 2:11 PM UTC

When working with AEM - if there is a corresponding API - like Asset Manager API, Tag Manager API, etc, you should ways use these strongly types APIs when programmatically working with AEM.

Here is URL to the Javadocs - "The CQ5 Quickstart and Web Application."

** MAY MAKE A GOOD Ask the AEM Community Session**

Translate
Level 2
Jan 25, 2018 5:05 PM UTC

Thanks for letting me know, smacdonald2008

Here is the code snippet for the same,

String customValue = "update";

Resource assetRsc = resolver.getResource("path/to/asset/metadata");

if(assetRsc !=null) {

    ModifiableValueMap properties = assetRsc.adaptTo(ModifiableValueMap.class);

     properties.put("custom_property", customValue );

     // some more properties to be set here

     saveToRepo(resolver);

}

private void saveToRepo(ResourceResolver resolver){

try {

resolver.commit();

} catch (PersistenceException e) {

logger.error("Exception while saving changes :", e);

}

}

I hope this helps understanding. Please let me know, if any other information is required.

Translate
rmahendra
Employee
Jan 26, 2018 10:29 AM UTC

The code looks good. What is the exact value you are trying to put?

Translate
Level 2
Jan 26, 2018 11:13 AM UTC

Hi rmahendr

                          the values(create/update/delete) i use are of string type. The second property takes string[] type values.

Thanks & Regards,

Radhakrishna.

Translate
smacdonald2008
Level 10
Jan 25, 2018 3:56 PM UTC

Please provide the exact steps you are performing so community can try and reduplicate this issue.

Translate