Apache Oak - XML上的导入失败,异常不是有效的JCR名称异常

时间:2015-09-01 15:57:37

标签: java apache jcr jackrabbit

晚安

我是JCR和Apache Oak(v1.2.3)的新手,似乎在从XML导入我的Oak存储库时遇到了问题。 (我将存储库填充到jdbc支持的节点,但无法理解为什么我可以在导出到XML之后将其重新导入新实例)。

XML文件太长了,无法在此处发布,但如果有人有任何想法会很棒。非常感谢

示例导入代码:

    try {
      String tesExampleXML = FileUtils.readFileToString(new File("/testRepository.xml"));

    Repository repo = new Jcr(new Oak()).createRepository();
   Session  sesh = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
    sesh.importXML("/",new StringBufferInputStream(tesExampleXML),0);
    Node root = sesh.getRootNode();
    NodeIterator it = root.getNodes();
    while (it.hasNext()){
            Node n = it.nextNode();
            System.out.println(n.getName());

    }
    //By this point not all of the nodes in root were printed
    assertTrue(root != null);

导入时记录的无提示异常..... javax.jcr.nodetype.ConstraintViolationException:不是有效的JCR名称 ' JCR:propertyDefinition [2]'

2015-09-01 16:36:01.0224 WARN main xml.DocViewImportHandler:206 - 遇到非法解码名称' propertyDefinition [1]' javax.jcr.nodetype.ConstraintViolationException:不是有效的JCR名称' jcr:propertyDefinition [1]'     在org.apache.jackrabbit.oak.namepath.JcrNameParser.checkName(JcrNameParser.java:210)     在org.apache.jackrabbit.oak.jcr.xml.DocViewImportHandler.processName(DocViewImportHandler.java:202)     在org.apache.jackrabbit.oak.jcr.xml.DocViewImportHandler.startElement(DocViewImportHandler.java:230)     在org.apache.jackrabbit.oak.jcr.xml.ImportHandler.startElement(ImportHandler.java:183)     at org.apache.jackrabbit.commons.xml.DefaultContentHandler.startElement(DefaultContentHandler.java:161)     在com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)     at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)     at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2768)     at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)     at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)     在com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)...

我得到了调试器 调试器中的第一个可疑异常位置propertyDefinition_x005b_1_x005d _

XML: propertyDefinition_x005b_1_x005d _

原始XML :(抱歉它不会让我发布整个事情......

<jcr:root jcr:primaryType="rep:root" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:rep="internal"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
<hello jcr:primaryType="nt:unstructured" count="2" />
<jcr:system jcr:primaryType="rep:system">
    <jcr:activities jcr:primaryType="rep:Activities" />
    <jcr:nodeTypes jcr:primaryType="rep:nodeTypes">
        <mix:atomicCounter jcr:primaryType="rep:NodeType"
            jcr:hasOrderableChildNodes="false" jcr:isAbstract="false"
            jcr:isMixin="true" jcr:isQueryable="true" jcr:nodeTypeName="mix:atomicCounter"
            rep:hasProtectedResidualChildNodes="false"
            rep:hasProtectedResidualProperties="false">
            <jcr:propertyDefinition_x005b_1_x005d_
                jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="true"
                jcr:isFullTextSearchable="true" jcr:isQueryOrderable="true"
                jcr:mandatory="false" jcr:multiple="false" jcr:name="oak:counter"
                jcr:onParentVersion="COPY" jcr:protected="true" jcr:requiredType="LONG" />
            <rep:namedPropertyDefinitions
                jcr:primaryType="rep:NamedPropertyDefinitions">
                <oak:counter jcr:primaryType="rep:PropertyDefinitions">
                    <LONG jcr:primaryType="rep:PropertyDefinition"
                        jcr:autoCreated="true" jcr:isFullTextSearchable="true"
                        jcr:isQueryOrderable="true" jcr:mandatory="false" jcr:multiple="false"
                        jcr:name="oak:counter" jcr:onParentVersion="COPY" jcr:protected="true"
                        jcr:requiredType="LONG" rep:declaringNodeType="mix:atomicCounter" />
                </oak:counter>
            </rep:namedPropertyDefinitions>
        </mix:atomicCounter>
        <mix:created jcr:primaryType="rep:NodeType"
            jcr:hasOrderableChildNodes="false" jcr:isAbstract="false"
            jcr:isMixin="true" jcr:isQueryable="true" jcr:nodeTypeName="mix:created"
            rep:hasProtectedResidualChildNodes="false"
            rep:hasProtectedResidualProperties="false">
            <jcr:propertyDefinition_x005b_1_x005d_
                jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="true"
                jcr:isFullTextSearchable="true" jcr:isQueryOrderable="true"
                jcr:mandatory="false" jcr:multiple="false" jcr:name="jcr:created"
                jcr:onParentVersion="COPY" jcr:protected="true" jcr:requiredType="DATE" />
            <jcr:propertyDefinition_x005b_2_x005d_
                jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="true"
                jcr:isFullTextSearchable="true" jcr:isQueryOrderable="true"
                jcr:mandatory="false" jcr:multiple="false" jcr:name="jcr:createdBy"
                jcr:onParentVersion="COPY" jcr:protected="true" jcr:requiredType="STRING" />
            <rep:namedPropertyDefinitions
                jcr:primaryType="rep:NamedPropertyDefinitions">
                <jcr:created jcr:primaryType="rep:PropertyDefinitions">
                    <DATE jcr:primaryType="rep:PropertyDefinition"
                        jcr:autoCreated="true" jcr:isFullTextSearchable="true"
                        jcr:isQueryOrderable="true" jcr:mandatory="false" jcr:multiple="false"
                        jcr:name="jcr:created" jcr:onParentVersion="COPY" jcr:protected="true"
                        jcr:requiredType="DATE" rep:declaringNodeType="mix:created" />
                </jcr:created>
                <jcr:createdBy jcr:primaryType="rep:PropertyDefinitions">
                    <STRING jcr:primaryType="rep:PropertyDefinition"
                        jcr:autoCreated="true" jcr:isFullTextSearchable="true"
                        jcr:isQueryOrderable="true" jcr:mandatory="false" jcr:multiple="false"
                        jcr:name="jcr:createdBy" jcr:onParentVersion="COPY"
                        jcr:protected="true" jcr:requiredType="STRING"
                        rep:declaringNodeType="mix:created" />
                </jcr:createdBy>
            </rep:namedPropertyDefinitions>
        </mix:created>
        <mix:etag jcr:primaryType="rep:NodeType"
            jcr:hasOrderableChildNodes="false" jcr:isAbstract="false"
            jcr:isMixin="true" jcr:isQueryable="true" jcr:nodeTypeName="mix:etag"
            rep:hasProtectedResidualChildNodes="false"
            rep:hasProtectedResidualProperties="false">
            <jcr:propertyDefinition_x005b_1_x005d_
                jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="true"
                jcr:isFullTextSearchable="true" jcr:isQueryOrderable="true"
                jcr:mandatory="false" jcr:multiple="false" jcr:name="jcr:etag"
                jcr:onParentVersion="COPY" jcr:protected="true" jcr:requiredType="STRING" />
            <rep:namedPropertyDefinitions
                jcr:primaryType="rep:NamedPropertyDefinitions">
                <jcr:etag jcr:primaryType="rep:PropertyDefinitions">
                    <STRING jcr:primaryType="rep:PropertyDefinition"
                        jcr:autoCreated="true" jcr:isFullTextSearchable="true"
                        jcr:isQueryOrderable="true" jcr:mandatory="false" jcr:multiple="false"
                        jcr:name="jcr:etag" jcr:onParentVersion="COPY" jcr:protected="true"
                        jcr:requiredType="STRING" rep:declaringNodeType="mix:etag" />
                </jcr:etag>
            </rep:namedPropertyDefinitions>
        </mix:etag>
        <mix:language jcr:primaryType="rep:NodeType"
            jcr:hasOrderableChildNodes="false" jcr:isAbstract="false"
            jcr:isMixin="true" jcr:isQueryable="true" jcr:nodeTypeName="mix:language"
            rep:hasProtectedResidualChildNodes="false"
            rep:hasProtectedResidualProperties="false">
            <jcr:propertyDefinition_x005b_1_x005d_
                jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="false"
                jcr:isFullTextSearchable="true" jcr:isQueryOrderable="true"
                jcr:mandatory="false" jcr:multiple="false" jcr:name="jcr:language"
                jcr:onParentVersion="COPY" jcr:protected="false" jcr:requiredType="STRING" />
            <rep:namedPropertyDefinitions
                jcr:primaryType="rep:NamedPropertyDefinitions">
                <jcr:language jcr:primaryType="rep:PropertyDefinitions">
                    <STRING jcr:primaryType="rep:PropertyDefinition"
                        jcr:autoCreated="false" 

1 个答案:

答案 0 :(得分:0)


从堆栈跟踪中,代码似乎也覆盖了系统节点(propertyDefinition_x005b_1_x005d_)。
我建议您只导出自定义根文件夹并重新导入它,而不触及任何系统文件夹(rep:security,jcr:system,oak:index),如果有帮助的话。