jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Problem when trying to reuse version label in transaction
Date Fri, 09 May 2008 14:23:39 GMT
Hi Roman,

this is probably a bug in jackrabbit. can you please file a jira issue? thank you.

regards
  marcel

Roman Puchkovskiy wrote:
> Hi.
> 
> There's a problem with reusage of version label. If version (which has label
> assigned) is removed inside a transaction, and after this same label is
> tried to be assigned to another version (in same transaction), exception is
> thrown.
> 
> Maven project with test case is here:
> http://rpuch.narod.ru/test-reassign-version-label-in-tx.zip
> When you run 'mvn test', test using transaction fails, following exception
> is thrown:
> 
> org.springframework.dao.DataIntegrityViolationException: Invalid version
> graph operation; nested exception is javax.jcr.version.VersionException:
> State has been marked destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2:
> State has been marked destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2:
> State has been marked destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2
> 	at
> org.springmodules.jcr.SessionFactoryUtils.translateException(SessionFactoryUtils.java:230)
> 	at
> org.springmodules.jcr.JcrAccessor.convertJcrAccessException(JcrAccessor.java:58)
> 	at org.springmodules.jcr.JcrTemplate.execute(JcrTemplate.java:82)
> 	at org.springmodules.jcr.JcrTemplate.execute(JcrTemplate.java:108)
> 	at
> ReassignVersionLabelInTxTest$3.doInTransaction(ReassignVersionLabelInTxTest.java:91)
> 	at
> org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
> 	at
> ReassignVersionLabelInTxTest.testReassignVersionLabelInTxThreeTransactions(ReassignVersionLabelInTxTest.java:89)
> Caused by: javax.jcr.version.VersionException: State has been marked
> destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2: State has been marked
> destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2: State has been marked
> destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2
> 	at
> org.apache.jackrabbit.core.version.InternalVersionHistoryImpl.setVersionLabel(InternalVersionHistoryImpl.java:438)
> 	at
> org.apache.jackrabbit.core.version.AbstractVersionManager.setVersionLabel(AbstractVersionManager.java:511)
> 	at
> org.apache.jackrabbit.core.version.XAVersionManager.setVersionLabel(XAVersionManager.java:411)
> 	at
> org.apache.jackrabbit.core.version.XAVersionManager.setVersionLabel(XAVersionManager.java:183)
> 	at
> org.apache.jackrabbit.core.version.VersionHistoryImpl.addVersionLabel(VersionHistoryImpl.java:139)
> 	at
> ReassignVersionLabelInTxTest$3$1.doInJcr(ReassignVersionLabelInTxTest.java:101)
> 	at org.springmodules.jcr.JcrTemplate.execute(JcrTemplate.java:76)
> 	... 30 more
> Caused by: javax.jcr.RepositoryException: State has been marked destroyed:
> 8d73b533-a938-4795-96f6-9fd263d73569/{}2: State has been marked destroyed:
> 8d73b533-a938-4795-96f6-9fd263d73569/{}2
> 	at
> org.apache.jackrabbit.core.version.NodeStateEx.store(NodeStateEx.java:505)
> 	at
> org.apache.jackrabbit.core.version.InternalVersionHistoryImpl.setVersionLabel(InternalVersionHistoryImpl.java:436)
> 	... 36 more
> Caused by: org.apache.jackrabbit.core.state.NoSuchItemStateException: State
> has been marked destroyed: 8d73b533-a938-4795-96f6-9fd263d73569/{}2
> 	at org.apache.jackrabbit.core.state.ChangeLog.get(ChangeLog.java:116)
> 	at
> org.apache.jackrabbit.core.state.XAItemStateManager.getItemState(XAItemStateManager.java:223)
> 	at
> org.apache.jackrabbit.core.version.NodeStateEx.store(NodeStateEx.java:523)
> 	at
> org.apache.jackrabbit.core.version.NodeStateEx.store(NodeStateEx.java:503)
> 	... 37 more
> 
> Failing test method is:
> 
>     public void testReassignVersionLabelInTxThreeTransactions() {
>         final String v1 = (String) transactionTemplate.execute(new
> TransactionCallback() {
>             public Object doInTransaction(TransactionStatus status) {
>                 return (String) jcrTemplate.execute(new JcrCallback() {
>                     public Object doInJcr(Session session) throws
> IOException,
>                             RepositoryException {
>                         Node target =
> session.getRootNode().addNode("target3");
>                         target.addMixin("mix:versionable");
>                         session.save();
>                         VersionHistory vh = target.getVersionHistory();
>                         Version v1 = target.checkin();
>                         vh.addVersionLabel(v1.getName(), "1", false);
>                         return v1.getName();
>                     }
>                 });
>             }
>         });
>         final String v2 = (String) transactionTemplate.execute(new
> TransactionCallback() {
>             public Object doInTransaction(TransactionStatus status) {
>                 return jcrTemplate.execute(new JcrCallback() {
>                     public Object doInJcr(Session session) throws
> IOException,
>                             RepositoryException {
>                         Node target =
> session.getRootNode().getNode("target3");
>                         VersionHistory vh = target.getVersionHistory();
>                         target.checkout();
>                         Version v2 = target.checkin();
>                         vh.addVersionLabel(v2.getName(), "2", false);
>                         return v2.getName();
>                     }
>                 });
>             }
>         });
>         transactionTemplate.execute(new TransactionCallback() {
>             public Object doInTransaction(TransactionStatus status) {
>                 jcrTemplate.execute(new JcrCallback() {
>                     public Object doInJcr(Session session) throws
> IOException,
>                             RepositoryException {
>                         Node target =
> session.getRootNode().getNode("target3");
>                         VersionHistory vh = target.getVersionHistory();
>                         target.restore(v1, true);
>                         vh.removeVersion(v2);
>                         // creating again
>                         target.checkout();
>                         Version v2 = target.checkin();
>                         vh.addVersionLabel(v2.getName(), "2", false); //
> this fails
>                         return null;
>                     }
>                 });
>                 return null;
>             }
>         });
>     }
> 
> This method creates a node and its first version (which is assigned a label)
> in first transaction, then creates second version (which is assigned another
> label) in second transaction. Then in the third transaction node is restored
> to state stored in first version, second version is removed, new version is
> created and assigned a label which was assigned to second version. This last
> assignment of label fails.
> 
> Please note that same sequence executes successfully if no transactions are
> used.


Mime
View raw message