jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "alban seurat (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-2626) Merge with transaction prevent to have modified and deleted reference between 2 nodes
Date Tue, 11 May 2010 09:17:43 GMT
Merge with transaction prevent to have modified and deleted reference between 2 nodes

                 Key: JCR-2626
                 URL: https://issues.apache.org/jira/browse/JCR-2626
             Project: Jackrabbit Content Repository
          Issue Type: Bug
          Components: jackrabbit-core
    Affects Versions: 1.6.1
         Environment: Windows XP 
            Reporter: alban seurat
            Priority: Critical

I've created a test case to reproduce the issue. 

In short, I have 2 artifacts where one has a reference on the second one. I want to copy/delete
the second one and update the reference, save my operation and do a copy/delete of the first
artefact afterward. 

Here is the test case 

package com.testjcr;

import java.io.IOException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.jcr.ItemExistsException;
import javax.jcr.LoginException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.apache.jackrabbit.api.XASession;
import org.apache.jackrabbit.core.TransientRepository;
import org.apache.jackrabbit.rmi.remote.RemoteRepository;
import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;

 * Hello world!
public class App {

    public static final String userNodeName = "User";
    public static final String sharedNodeName = "Shared";

    public static final String node1Name = "Node1";
    public static final String node2Name = "Node2";

    public static void main(String[] args) throws IOException, LoginException, RepositoryException,
RemoteException, NotBoundException, XAException, Exception {

        TransientRepository repository = new TransientRepository();

        RemoteAdapterFactory factory = null;

        factory = new ServerAdapterFactory();

        RemoteRepository remote = factory.getRemoteRepository(repository);

        Registry reg;
        try {
            reg = LocateRegistry.createRegistry(2100);
        } catch (RemoteException ex) {
            reg = LocateRegistry.getRegistry(2100);
        reg.rebind("alban", remote);

        Session session = repository.login(new SimpleCredentials("", "".toCharArray()));

        Node rootNode = session.getRootNode();

        Node userNode = rootNode.addNode(userNodeName);
        Node sharedNode = rootNode.addNode(sharedNodeName);

        Node node1 = userNode.addNode(node1Name);

        Node node2 = userNode.addNode(node2Name);

        node1.setProperty("reference", node2);




    private static void moveNode(Session xaSession, Node sharedNode, Node node) throws Exception

        Node copyNode = sharedNode.addNode(node.getName());

        PropertyIterator it = node.getReferences();
        while (it.hasNext()) {



    private static void doOperation(TransientRepository repository) throws Exception {
        XASession xaSession = (XASession) repository.login(new SimpleCredentials("", "".toCharArray()));
        Xid xid = new Xid() {

            public byte[] getBranchQualifier() {
                return new byte[0];

            public int getFormatId() {
                return 0;

            public byte[] getGlobalTransactionId() {
                return new byte[0];

        XAResource xaResource = xaSession.getXAResource();
        xaResource.start(xid, XAResource.TMNOFLAGS);


        Node rootNode = xaSession.getRootNode();
        Node sharedNode = rootNode.getNode(sharedNodeName);
        Node userNode = rootNode.getNode(userNodeName);

        moveNode(xaSession, sharedNode, userNode.getNode(node2Name));

        moveNode(xaSession, sharedNode, userNode.getNode(node1Name));


        // Finally commit this transaction to persist the changes made to xaSession.
        xaResource.end(xid, XAResource.TMSUCCESS);
        xaResource.commit(xid, false);


This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message