Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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

Avatar

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
radhakrishnan72
Level 2

25-01-2018

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.

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

25-01-2018

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

Avatar

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
radhakrishnan72
Level 2

25-01-2018

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.

Avatar

Avatar
Give Back 5
Employee
rmahendra
Employee

Likes

26 likes

Total Posts

39 posts

Correct Reply

14 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Give Back 5
Employee
rmahendra
Employee

Likes

26 likes

Total Posts

39 posts

Correct Reply

14 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Boost 5
Boost 3
View profile
rmahendra
Employee

26-01-2018

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

Avatar

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile
BrijeshYadav
Level 4

26-01-2018

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

Avatar

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
radhakrishnan72
Level 2

26-01-2018

Hi rmahendr

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

Thanks & Regards,

Radhakrishna.

Avatar

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
radhakrishnan72
Level 2

26-01-2018

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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

26-01-2018

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**

Avatar

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
radhakrishnan72
Level 2

Likes

4 likes

Total Posts

28 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
radhakrishnan72
Level 2

26-01-2018

Hi smacdonald2008,

                                    thanks for making a point to use specific API when using corresponding functionality. I do follow Yadav Brijesh and your recommendations here on. It would be great information for everyone, if we have exact difference between them.

I am very much interested to know about this exception.

Thanks & Regards,

Radhakrishna.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

26-01-2018

I am checking this use case with the team.