Hi, I've been trying to play with latest CRX night build for a few days. Unfortunately I found a strange result after trying to remove referenced node. My test case is as fallow:
1. Create my root node (MY_ROOT). 2. Add node (MY_NODE_0) below node created in step 1 (MY_ROOT). 3. Add one more node (MY_NODE_1) below node created in step 1 (MY_ROOT). In this node (MY_NODE_1) create reference property to node from step 2 (MY_NODE_0). 4. Try to remove MY_NODE_0. It must fail as this node is referenced by MY_NODE_1. 5. Try to remove MY_ROOT. Everything should go ok, but on step 5 I get en exception: javax.jcr.ItemNotFoundException I attached my source togethet with empty repository (I created my types: my:root and my:nood). All that you need, you have to define path to repository. <<<< DeleteTest.java >>>>>>>>>> package com.prototyping.it5; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import javax.jcr.Node; import javax.jcr.ReferentialIntegrityException; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; import org.apache.jackrabbit.core.RepositoryImpl; import org.apache.jackrabbit.core.config.RepositoryConfig; public class DeleteTest { private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(DeleteTest.class); public static String REPOSITORY_HOME = "d:/repo_embeded/"; public static String REPOSITORY_CONFIG = REPOSITORY_HOME + "repository.xml"; public static void main(String[] args) throws RepositoryException, FileNotFoundException, IOException { System.setProperty("java.security.auth.login.config", "jaas_jcr.config"); log.info("Creating EmbeddedRepository."); RepositoryConfig config = RepositoryConfig.create(REPOSITORY_CONFIG, REPOSITORY_HOME); Repository repository = RepositoryImpl.create(config); log.info("Created EmbeddedRepository successfully."); Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); testRemovingReferences(session); session.logout(); ((RepositoryImpl) repository).shutdown(); log.info("Done."); } private static void testRemovingReferences(Session session) throws RepositoryException { Node root = session.getRootNode(); // create department node Node myRoot = root.addNode("myRoot", "my:root"); root.save(); myRoot.checkin(); log.info("myRoot node created."); // create one more node below myRoot.checkout(); Node myNode0 = myRoot.addNode("myNode0", "my:node"); myRoot.save(); myNode0.checkin(); myRoot.checkin(); log.info("myNode0 node created."); // create node with reference to myNode0 myRoot.checkout(); Node myNode1 = myRoot.addNode("myNode1", "my:node"); myNode1.setProperty("my:reference", myNode0); myRoot.save(); myNode1.checkin(); myRoot.checkin(); log.info("myNode1 node created."); // trying to remove myNode0. Must fail as myNode0 is referenced by myNode1. try { myRoot.checkout(); myNode0.remove(); myRoot.save(); } catch (ReferentialIntegrityException e) { log.info("Can not remove specialty primary"); } finally { myRoot.checkin(); } // try to remove department myRoot.remove(); log.info("Subtree removed."); } } <<<< custom_nodetypes.xml >>>>>>>> <?xml version="1.0" encoding="UTF-8"?> <nodeTypes xmlns:fn="http://www.w3.org/2004/10/xpath-functions" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:my="com.prototyping" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:rep="internal" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- my:root --> <nodeType hasOrderableChildNodes="false" isMixin="false" name="my:root" primaryItemName=""> <supertypes> <supertype>nt:base</supertype> <supertype>mix:versionable</supertype> </supertypes> <childNodeDefinition autoCreated="false" defaultPrimaryType="" mandatory="false" name="*" onParentVersion="VERSION" protected="false" sameNameSiblings="false"> <requiredPrimaryTypes> <requiredPrimaryType>my:node</requiredPrimaryType> </requiredPrimaryTypes> </childNodeDefinition> </nodeType> <!-- my:node --> <nodeType hasOrderableChildNodes="false" isMixin="false" name="my:node" primaryItemName=""> <supertypes> <supertype>nt:base</supertype> <supertype>mix:versionable</supertype> </supertypes> <propertyDefinition autoCreated="false" mandatory="false" multiple="false" name="my:reference" onParentVersion="COPY" protected="false" requiredType="Reference"/> </nodeType> </nodeTypes> -- Tomasz Dabrowski email: [EMAIL PROTECTED] skype: tomekdab www: www.cognifide.com