Expand my Community achievements bar.

SOLVED

javax.jcr.ItemExistsException: Same name siblings are not allowed

Avatar

Level 4

Hi,

I am trying to move pages from one place to another place using seesion. But I am getting javax.jcr.ItemExistsException: Same name siblings are not allowed. 

Below is my code:

String sourcePath = "/content/a/b1";
String destinationPath = "/content/a/b2";

 session.move(sourcePath, destinationPath);
 session.save();

1 Accepted Solution

Avatar

Correct answer by
Level 10

Move items in the JCR using the AssetManager API:

https://helpx.adobe.com/experience-manager/using/graniteAPI.html

In this example - we are moving nodes that represent PDF. But it will work for other nodes. 

View solution in original post

6 Replies

Avatar

Level 10
  An ItemExistsException is thrown if a property already exists at destination path or a node already exists there and same-name siblings are not allowed.

Avatar

Employee

Hi,

apologies if I am stating the obvious and you have already checked. But could it be possible that you ran the code once and it was successful, but on subsequent runs you got an exception because the new node had already been created?

Please go to the new target path and delete the new node, "/content/a/b2",  and run you code again.

Regards,

Opkar

Avatar

Level 10
Its node with same name. Two child node with same name is not allowed under one parent

Avatar

Correct answer by
Level 10

Move items in the JCR using the AssetManager API:

https://helpx.adobe.com/experience-manager/using/graniteAPI.html

In this example - we are moving nodes that represent PDF. But it will work for other nodes. 

Avatar

Level 4

edubey wrote...

An ItemExistsException is thrown if a property already exists at destination path or a node already exists there and same-name siblings are not allowed.

It doesn't have any common property. What is meant by same name siblings ?

Avatar

Level 4

Using assetManager its working fine.

But while using Session source and destination paths should be as below :

String sourcePath = "/content/a/b1";
String destinationPath = "/content/a/b2/b1"; 

to move b1 under b2 node you should mention b1 node under b2 in destination path.