Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1822

VersionManager.checkin throws exception in the transaction when using JTA transaction manager

XMLWordPrintable

    The following code will work with DummyTransacationManager but not real JTA transaction manager (Atomisk)

            @Transactional
            public void createNewNode(JCRSessionHolder sessionHolder) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
                VersionManager vm = sessionHolder.getSession().getWorkspace().getVersionManager();
    
                Node node = sessionHolder.getSession().getRootNode().addNode("Test3", "pd:product");
                node.addMixin("mix:versionable");
                node.setProperty("name", "lalalal");
                node.setProperty("code", "lalalal");
                sessionHolder.getSession().save();
                vm.checkin(node.getPath());
            }
    

    Exception in thread "main" javax.jcr.InvalidItemStateException: This operation cannot be performed when the session has pending changes
    at org.modeshape.jcr.JcrVersionManager.checkin(JcrVersionManager.java:321)
    at org.modeshape.jcr.JcrVersionManager.checkin(JcrVersionManager.java:304)
    at JTATest$JCRTest.createNewNode(JTATest.java:76)
    at JTATest.main(JTATest.java:56)

    For VersionManager.checkout, if I call it in the beginning of the method and then make some change to the node, and save(), ModeShape will complain the node is not checkout.

      1. jprofiler_mode_1822.zip
        329 kB
      2. no-transaction.nps
        37 kB
      3. no-transaction.png
        no-transaction.png
        103 kB
      4. transaction.nps
        39 kB
      5. transaction.png
        transaction.png
        99 kB

          rhauch Randall Hauch (Inactive)
          ozhou_jira Oliver Zhou (Inactive)
          Votes:
          1 Vote for this issue
          Watchers:
          4 Start watching this issue

            Created:
            Updated:
            Resolved: