Index: dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java (revision 972) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java (working copy) @@ -1413,10 +1413,21 @@ List nodeDefs = new ArrayList( nodeType.getDeclaredChildNodeDefinitions().length); + for (JcrNodeDefinition nodeDef : nodeType.getDeclaredChildNodeDefinitions()) { + nodeDefs.add(nodeDef.with(this.context).with(this)); + } + // Create a new node type that also has the correct property and child node definitions associated + JcrNodeType newNodeType = new JcrNodeType(this.context, this, nodeType.getInternalName(), supertypes, + nodeType.getInternalPrimaryItemName(), nodeDefs, propertyDefs, + nodeType.isMixin(), nodeType.hasOrderableChildNodes()); + typesPendingRegistration.add(newNodeType); + } + + // Make sure the nodes have primary types that are either already registered, or pending registration ... + for (JcrNodeType nodeType : typesPendingRegistration) { for (JcrNodeDefinition nodeDef : nodeType.getDeclaredChildNodeDefinitions()) { JcrNodeType[] requiredPrimaryTypes = new JcrNodeType[nodeDef.requiredPrimaryTypeNames().length]; - int i = 0; for (Name primaryTypeName : nodeDef.requiredPrimaryTypeNames()) { requiredPrimaryTypes[i] = findTypeInMapOrList(primaryTypeName, typesPendingRegistration); @@ -1427,15 +1438,7 @@ } i++; } - - nodeDefs.add(nodeDef.with(this.context).with(this)); } - - // Create a new node type that also has the correct property and child node definitions associated - JcrNodeType newNodeType = new JcrNodeType(this.context, this, nodeType.getInternalName(), supertypes, - nodeType.getInternalPrimaryItemName(), nodeDefs, propertyDefs, - nodeType.isMixin(), nodeType.hasOrderableChildNodes()); - typesPendingRegistration.add(newNodeType); } // Graph.Batch batch = graph.batch();