You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by sir�ne vip <si...@hotmail.com> on 2006/01/29 16:54:35 UTC

ConstraintViolationException

Hello Everyone,

This becoming really annoying!

I have verified my program thousands of time and made all possible changes 
but keep having the exception "ConstraintViolationException:[other 
application_specific information]  mandatory property 
{http://www.jcp.org/jcr/1.0}created does not exist"

My code consists in the following:

public void store(String feName, String document) {

  Node root = session.getRootNode();
  Node n = root.addNode(feName, "nt:file");
  Node content = expNode.addNode("jcr:content", "nt:resource");
  content.setProperty("jcr:mimeType", "text/xml");
  content.setProperty("jcr:encoding", "");
  content.setProperty("jcr:data", document);

  Calendar lastModified = Calendar.getInstance ();
  long currentTime = System.currentTimeMillis();
  final long duration = currentTime - start;
  lastModified.setTimeInMillis(duration);
  content.setProperty("jcr:lastModified", lastModified);
   session.save();
}

Any help is truly appreciated. Thank you!
Best Regards.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


Re: ConstraintViolationException

Posted by Tobias Bocanegra <to...@day.com>.
well, i could reproduce this behaviour, but only once, but now i'm not
able to get the error anymore. this is certainly strange.

sirene, can you strip down your code to some simple class that always
reproduces this behaviour? with this, we could better debug the
problem.

regards, toby

On 1/30/06, Stefan Guggisberg <st...@gmail.com> wrote:
> On 1/29/06, sirène vip <si...@hotmail.com> wrote:
> > Hello Everyone,
> >
> > This becoming really annoying!
> >
> > I have verified my program thousands of time and made all possible changes
> > but keep having the exception "ConstraintViolationException:[other
> > application_specific information]  mandatory property
> > {http://www.jcp.org/jcr/1.0}created does not exist"
> >
> > My code consists in the following:
> >
> > public void store(String feName, String document) {
> >
> >   Node root = session.getRootNode();
> >   Node n = root.addNode(feName, "nt:file");
> >   Node content = expNode.addNode("jcr:content", "nt:resource");
> >   content.setProperty("jcr:mimeType", "text/xml");
> >   content.setProperty("jcr:encoding", "");
> >   content.setProperty("jcr:data", document);
> >
> >   Calendar lastModified = Calendar.getInstance ();
> >   long currentTime = System.currentTimeMillis();
> >   final long duration = currentTime - start;
> >   lastModified.setTimeInMillis(duration);
> >   content.setProperty("jcr:lastModified", lastModified);
> >    session.save();
> > }
>
>
> >   Node content = expNode.addNode("jcr:content", "nt:resource");
>
> where does 'expNode' come from?
>
> here's a code fragment that i works perfectly
> (tested with the latest svn rev.):
>
>            // file to be stored in repository
>            File file = new File("repository.xml");
>
>            Node fileNode = root.addNode(file.getName(), "nt:file");
>            Node content = fileNode.addNode("jcr:content", "nt:resource");
>            FileInputStream fin = new FileInputStream(file);
>            try {
>                content.setProperty("jcr:data", fin);
>            } finally {
>                fin.close();
>            }
>            content.setProperty("jcr:lastModified", Calendar.getInstance());
>            content.setProperty("jcr:mimeType", "text/plain");
>
>            session.save();
>
>
> btw: who is it? sirène? celina? susanne? it would be nice to know
> who we're talking to...
>
> cheers
> stefan
>
> >
> > Any help is truly appreciated. Thank you!
> > Best Regards.
> >
> > _________________________________________________________________
> > FREE pop-up blocking with the new MSN Toolbar - get it now!
> > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> >
> >
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: ConstraintViolationException

Posted by Stefan Guggisberg <st...@gmail.com>.
On 1/29/06, sirène vip <si...@hotmail.com> wrote:
> Hello Everyone,
>
> This becoming really annoying!
>
> I have verified my program thousands of time and made all possible changes
> but keep having the exception "ConstraintViolationException:[other
> application_specific information]  mandatory property
> {http://www.jcp.org/jcr/1.0}created does not exist"
>
> My code consists in the following:
>
> public void store(String feName, String document) {
>
>   Node root = session.getRootNode();
>   Node n = root.addNode(feName, "nt:file");
>   Node content = expNode.addNode("jcr:content", "nt:resource");
>   content.setProperty("jcr:mimeType", "text/xml");
>   content.setProperty("jcr:encoding", "");
>   content.setProperty("jcr:data", document);
>
>   Calendar lastModified = Calendar.getInstance ();
>   long currentTime = System.currentTimeMillis();
>   final long duration = currentTime - start;
>   lastModified.setTimeInMillis(duration);
>   content.setProperty("jcr:lastModified", lastModified);
>    session.save();
> }


>   Node content = expNode.addNode("jcr:content", "nt:resource");

where does 'expNode' come from?

here's a code fragment that i works perfectly
(tested with the latest svn rev.):

            // file to be stored in repository
            File file = new File("repository.xml");

            Node fileNode = root.addNode(file.getName(), "nt:file");
            Node content = fileNode.addNode("jcr:content", "nt:resource");
            FileInputStream fin = new FileInputStream(file);
            try {
                content.setProperty("jcr:data", fin);
            } finally {
                fin.close();
            }
            content.setProperty("jcr:lastModified", Calendar.getInstance());
            content.setProperty("jcr:mimeType", "text/plain");

            session.save();


btw: who is it? sirène? celina? susanne? it would be nice to know
who we're talking to...

cheers
stefan

>
> Any help is truly appreciated. Thank you!
> Best Regards.
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>

Re: ConstraintViolationException

Posted by sir�ne vip <si...@hotmail.com>.
>I'm not setting that jcr:created property for adding nt:resource nodes, and
>I do not get that ConstraintViolationException. I suppose that you have not
>added manually that property definition.

Would you give me more precisions on what you mean by "you have not added 
manually that property definition."?

Isn't sufficient what I have done? As it was described in my first mail?

I would appreciate your help. I'm not very familiar with jackrabbit and 
seems I'm missing something.

Isn't sufficient to use JCR Node Interface to define nodes and properties of 
predefined primary/mixin node types?

Thank you in advance.
Best Regards.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Re: ConstraintViolationException

Posted by Martin Perez <mp...@gmail.com>.
It's curious.

I'm not setting that jcr:created property for adding nt:resource nodes, and
I do not get that ConstraintViolationException. I suppose that you have not
added manually that property definition.

Martin


On 1/29/06, sirène vip <si...@hotmail.com> wrote:
>
>
> > > then you need to look harder :-) but i can't see where you set the
> > > "created" property.
> >
> >he shouldn't have to - according to the spec, jcr:created is not
> >mandatory and is supposed to be autocreated.
>
> You are absolutely right!
>
> By the way, I'm "she" not "he" ;-)
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>

Re: ConstraintViolationException

Posted by sir�ne vip <si...@hotmail.com>.
> > then you need to look harder :-) but i can't see where you set the
> > "created" property.
>
>he shouldn't have to - according to the spec, jcr:created is not
>mandatory and is supposed to be autocreated.

You are absolutely right!

By the way, I'm "she" not "he" ;-)

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Re: ConstraintViolationException

Posted by sir�ne vip <si...@hotmail.com>.
> > then you need to look harder :-) but i can't see where you set the
> > "created" property.
>
>he shouldn't have to - according to the spec, jcr:created is not
>mandatory and is supposed to be autocreated.

You are absolutely right!

By the way, I'm "she" not "he" ;-)

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Re: ConstraintViolationException

Posted by Brian Moseley <bc...@osafoundation.org>.
On 1/29/06, Tobias Bocanegra <to...@day.com> wrote:

> then you need to look harder :-) but i can't see where you set the
> "created" property.

he shouldn't have to - according to the spec, jcr:created is not
mandatory and is supposed to be autocreated.

Re: ConstraintViolationException

Posted by Tobias Bocanegra <to...@day.com>.
> This becoming really annoying!
well....

> I have verified my program thousands of time and made all possible changes
> but keep having the exception "ConstraintViolationException:[other
> application_specific information]  mandatory property
> {http://www.jcp.org/jcr/1.0}created does not exist"
then you need to look harder :-) but i can't see where you set the
"created" property.

>
> My code consists in the following:
>
> public void store(String feName, String document) {
>
>  Node root = session.getRootNode();
>  Node n = root.addNode(feName, "nt:file");
>  Node content = expNode.addNode("jcr:content", "nt:resource");
>  content.setProperty("jcr:mimeType", "text/xml");
>  content.setProperty("jcr:encoding", "");
>  content.setProperty("jcr:data", document);
>
>  Calendar lastModified = Calendar.getInstance ();
>  long currentTime = System.currentTimeMillis();
>  final long duration = currentTime - start;
>  lastModified.setTimeInMillis(duration);
>  content.setProperty("jcr:lastModified", lastModified);
>   session.save();
> }
>
> Any help is truly appreciated. Thank you!
> Best Regards.
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---