【问题标题】:Apache Oak - Import Failue on XML With Exception not a valid JCR name exceptionApache Oak - 在 XML 上导入失败,异常不是有效的 JCR 名称异常
【发布时间】:2015-09-01 15:57:37
【问题描述】:

晚上好

我是 JCR 和 Apache Oak (v1.2.3) 的新手,在导入我的 Oak 存储库表单 XML 时似乎遇到了问题。 (我将存储库填充到一个 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) 在 org.apache.jackrabbit.commons.xml.DefaultContentHandler.startElement(DefaultContentHandler.java:161) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506) 在 com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182) 在 com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2768) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) 在 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" 

【问题讨论】:

    标签: java apache jcr jackrabbit


    【解决方案1】:


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

    【讨论】:

      猜你喜欢
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 2016-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多