A) Sling expects the mixin types to passed as their raw String values
and not as the JCR NameValue type.
The fact that the JCR NameValue type is being utilized instead is
causing the error you are seeing as the Sling functionality converted
it to a String (incorrectly) causing it to become invalid to the JCR
expectations causing an exception on trying to add the corrupted mixin
B) jcr:created is specifically handled by the JCR system, so Sling
refuses to be the writer/modifier of the property, silently ignoring
any attempts at setting/modifying the value.
Therefore, once you remove the attempt at setting jcr:created and
correct the jcr:mixinTypes value, you should be allowed to create the
>From there, the JCR system should automatically add the jcr:created
due to the mixin Type.
On Tue, Sep 20, 2016 at 9:46 PM, Roy Teeuwen <r...@teeuwen.be> wrote:
> Hello all,
> I am trying to create an nt:unstructured resource programatically, which
> contains a jcr:created property, but I don’t seem to find a way to add this
> programatically, nor how to add a jcr:mixinType (which would make it
> I tried the following, but it isn’t working:
> Resource myResource = resourceResolver.getResource("/myresource");
> Map<String,Object> properties = new HashMap<String,Object>();
> properties.put("jcr:primaryType", "nt:unstructured”);
> properties.put("jcr:mixinTypes", new NameValue
> properties.put(“jcr:created”, Calendar.getInstance());
> Resource dummy = resourceResolver.create(myResource, "dummy", properties);
> I get the following exception:
> java.lang.IllegalArgumentException: Value can't be stored in the repository:
> Can anyone tell me on how to add this on creation time?