You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by zevon <sa...@expedia.com> on 2008/01/30 21:08:56 UTC

Unable to update item exception while trying to checkin()


I copied the below code(versioningBasics method) from 
http://wiki.apache.org/jackrabbit/ExamplesPage examplesPage  and I am
calling it with:

<snip>
Repository repository = new TransientRepository();
		Session session = repository.login(new SimpleCredentials("username",
				"password".toCharArray()));
		try {
			Node root = session.getRootNode();

			versioningBasics(root, session);
</snip>

private static void versioningBasics (Node parentNode, Session session)
throws RepositoryException
    {
          //create versionable node
          Node n = parentNode.addNode("childNode", "nt:unstructured");
          n.addMixin("mix:versionable");
          n.setProperty("anyProperty", "Blah");
          session.save();
          Version firstVersion = n.checkin();

          //add new version
          Node child = parentNode.getNode("childNode");
          child.checkout();
          child.setProperty("anyProperty", "Blah2");
          session.save();
          child.checkin();

          //print version history
          VersionHistory history = child.getVersionHistory();
          for (VersionIterator it = history.getAllVersions(); it.hasNext();)
{
            Version version = (Version) it.next();
            System.out.println(version.getCreated().getTime());
          }
          
          //restoring old version
          child.checkout();
          child.restore(firstVersion, true);          
    }

This is the exception I get, what am I doing wrong?

Exception in thread "main" javax.jcr.RepositoryException: /childNode: unable
to update item.: 8c2ba7f9-7509-433c-99e3-6f28de86b77d:
8c2ba7f9-7509-433c-99e3-6f28de86b77d
	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1252)
	at org.apache.jackrabbit.core.NodeImpl.checkin(NodeImpl.java:2966)
	at SecondHop.versioningBasics(SecondHop.java:249)
	at SecondHop.main(SecondHop.java:59)


-- 
View this message in context: http://www.nabble.com/Unable-to-update-item-exception-while-trying-to-checkin%28%29-tp15190742p15190742.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Unable to update item exception while trying to checkin()

Posted by zevon <sa...@expedia.com>.
Looks like the actual exception is
org.apache.jackrabbit.core.state.NoSuchItemStateException. I looked in the
db, and was able to find the UUID which cannot be found through the code.
Why can't it be found during checkin()?


zevon wrote:
> 
> 
> I copied the below code(versioningBasics method) from 
> http://wiki.apache.org/jackrabbit/ExamplesPage examplesPage  and I am
> calling it with:
> 
> <snip>
> Repository repository = new TransientRepository();
> 		Session session = repository.login(new SimpleCredentials("username",
> 				"password".toCharArray()));
> 		try {
> 			Node root = session.getRootNode();
> 
> 			versioningBasics(root, session);
> </snip>
> 
> private static void versioningBasics (Node parentNode, Session session)
> throws RepositoryException
>     {
>           //create versionable node
>           Node n = parentNode.addNode("childNode", "nt:unstructured");
>           n.addMixin("mix:versionable");
>           n.setProperty("anyProperty", "Blah");
>           session.save();
>           Version firstVersion = n.checkin();
> 
>           //add new version
>           Node child = parentNode.getNode("childNode");
>           child.checkout();
>           child.setProperty("anyProperty", "Blah2");
>           session.save();
>           child.checkin();
> 
>           //print version history
>           VersionHistory history = child.getVersionHistory();
>           for (VersionIterator it = history.getAllVersions();
> it.hasNext();) {
>             Version version = (Version) it.next();
>             System.out.println(version.getCreated().getTime());
>           }
>           
>           //restoring old version
>           child.checkout();
>           child.restore(firstVersion, true);          
>     }
> 
> This is the exception I get, what am I doing wrong?
> 
> Exception in thread "main" javax.jcr.RepositoryException: /childNode:
> unable to update item.: 8c2ba7f9-7509-433c-99e3-6f28de86b77d:
> 8c2ba7f9-7509-433c-99e3-6f28de86b77d
> 	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1252)
> 	at org.apache.jackrabbit.core.NodeImpl.checkin(NodeImpl.java:2966)
> 	at SecondHop.versioningBasics(SecondHop.java:249)
> 	at SecondHop.main(SecondHop.java:59)
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unable-to-update-item-exception-while-trying-to-checkin%28%29-tp15190742p15194663.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Unable to update item exception while trying to checkin()

Posted by zevon <sa...@expedia.com>.
Any ideas please

Thanks
-Sateesh


zevon wrote:
> 
> 
> I copied the below code(versioningBasics method) from 
> http://wiki.apache.org/jackrabbit/ExamplesPage examplesPage  and I am
> calling it with:
> 
> <snip>
> Repository repository = new TransientRepository();
> 		Session session = repository.login(new SimpleCredentials("username",
> 				"password".toCharArray()));
> 		try {
> 			Node root = session.getRootNode();
> 
> 			versioningBasics(root, session);
> </snip>
> 
> private static void versioningBasics (Node parentNode, Session session)
> throws RepositoryException
>     {
>           //create versionable node
>           Node n = parentNode.addNode("childNode", "nt:unstructured");
>           n.addMixin("mix:versionable");
>           n.setProperty("anyProperty", "Blah");
>           session.save();
>           Version firstVersion = n.checkin();
> 
>           //add new version
>           Node child = parentNode.getNode("childNode");
>           child.checkout();
>           child.setProperty("anyProperty", "Blah2");
>           session.save();
>           child.checkin();
> 
>           //print version history
>           VersionHistory history = child.getVersionHistory();
>           for (VersionIterator it = history.getAllVersions();
> it.hasNext();) {
>             Version version = (Version) it.next();
>             System.out.println(version.getCreated().getTime());
>           }
>           
>           //restoring old version
>           child.checkout();
>           child.restore(firstVersion, true);          
>     }
> 
> This is the exception I get, what am I doing wrong?
> 
> Exception in thread "main" javax.jcr.RepositoryException: /childNode:
> unable to update item.: 8c2ba7f9-7509-433c-99e3-6f28de86b77d:
> 8c2ba7f9-7509-433c-99e3-6f28de86b77d
> 	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1252)
> 	at org.apache.jackrabbit.core.NodeImpl.checkin(NodeImpl.java:2966)
> 	at SecondHop.versioningBasics(SecondHop.java:249)
> 	at SecondHop.main(SecondHop.java:59)
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unable-to-update-item-exception-while-trying-to-checkin%28%29-tp15190742p15212085.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.