0

嘿,第三种选择有问题,因为循环在JcrServiceFactory搜索以 jcr.* 开头的属性(其他没有传递),但在RepositoryFactoryImpl(Jackrabbit impl) 之后搜索“org.apache.jackrabbit .repository.home”在传递的属性集合中......这没有意义。即使 org.apache.jackrabbit.repository.home 在那里,它也不会开始,PREFIX_JCR_CONFIG所以它不会被放入jcrConfig集合中去RepositoryFactoryImpl.getRepository()

Map<String, String> map = null;如果因为存在if (parameters == null)条件,那将是有道理的RepositoryFactoryImpl,但这并不

它发生在init方法中

JcrServiceFactory.java

 private TypeManager typeManager;
    private Map<String, String> jcrConfig;
    private String mountPath;
    private JcrRepository jcrRepository;

    @Override
    public void init(Map<String, String> parameters) {
        typeManager = new TypeManager();
        readConfiguration(parameters);
        jcrRepository = new JcrRepository(acquireJcrRepository(jcrConfig), mountPath, typeManager);
    }

Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: No JCR repository factory for configured parameters
    at org.apache.chemistry.opencmis.jcr.JcrServiceFactory.acquireJcrRepository(JcrServiceFactory.java:95)
    at org.apache.chemistry.opencmis.jcr.JcrServiceFactory.init(JcrServiceFactory.java:61)
    at org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi.getSpiInstance(CmisLocalSpi.java:94)
    ... 34 more

 private void readConfiguration(Map<String, String> parameters) {
        Map<String, String> map = new HashMap<String, String>();
        List<String> keys = new ArrayList<String>(parameters.keySet());
        Collections.sort(keys);

/* the loop is searching for properties starting with jcr.* */

        for (String key : keys) {
            if (key.startsWith(PREFIX_JCR_CONFIG)) {
                String jcrKey = key.substring(PREFIX_JCR_CONFIG.length());
                String jcrValue = replaceSystemProperties(parameters.get(key));
                map.put(jcrKey, jcrValue);
            }

            else if (MOUNT_PATH_CONFIG.equals(key)) {
                mountPath = parameters.get(key);
                log.debug("Configuration: " + MOUNT_PATH_CONFIG + '=' + mountPath);
            }

            else {
                log.warn("Configuration: unrecognized key: " + key);
            }
        }

        jcrConfig = Collections.unmodifiableMap(map);
        log.debug("Configuration: jcr=" + jcrConfig);
    }

但是这里的参数 Map 是空的 {} 并且它返回 null; 因为它正在搜索 RepositoryFactoryImpl.REPOSITORY_HOME,即 org.apache.jackrabbit.repository.home

RepositoryFactoryImpl.java

/* parameters = jcrConfig */
public Repository getRepository(Map parameters) throws RepositoryException {
        if (parameters == null) {
            return getRepository(null, Collections.emptyMap());
        } else if (parameters.containsKey(REPOSITORY_HOME)) {
            String home = parameters.get(REPOSITORY_HOME).toString();
            return getRepository(home, parameters);
        } else if (parameters.containsKey(JcrUtils.REPOSITORY_URI)) {
            Object parameter = parameters.get(JcrUtils.REPOSITORY_URI);
            try {
                URI uri = new URI(parameter.toString().trim());
                String scheme = uri.getScheme();
                if (("file".equalsIgnoreCase(scheme)
                        || "jcr-jackrabbit".equalsIgnoreCase(scheme))
                        && uri.getAuthority() == null) {
                    File file = new File(uri.getPath());
                    if (file.isFile()) {
                        return null; // Not a (possibly missing) directory
                    } else {
                        return getRepository(file.getPath(), parameters);
                    }
                } else {
                    return null; // not a file: or jcr-jackrabbit: URI
                }
            } catch (URISyntaxException e) {
                return null; // not a valid URI
            }
        } else {
            return null; // unknown or insufficient parameters
        }
    }

<dependencies>

        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
            <version>2.0</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-core</artifactId>
            <version>2.2.4</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-api</artifactId>
            <version>2.2.4</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.11</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>5.14</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.chemistry.opencmis</groupId>
            <artifactId>chemistry-opencmis-server-jcr</artifactId>
            <version>0.3.0-incubating-SNAPSHOT</version>
            <classifier>classes</classifier>
        </dependency>

        <dependency>
            <groupId>org.apache.chemistry.opencmis</groupId>
            <artifactId>chemistry-opencmis-client-bindings</artifactId>
            <version>0.3.0-incubating-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.apache.chemistry.opencmis</groupId>
            <artifactId>chemistry-opencmis-client-api</artifactId>
            <version>0.3.0-incubating-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.apache.chemistry.opencmis</groupId>
            <artifactId>chemistry-opencmis-client-impl</artifactId>
            <version>0.3.0-incubating-SNAPSHOT</version>
        </dependency>
4

2 回答 2

1

答案就在我抱怨的循环中:-)

String jcrKey = key.substring(PREFIX_JCR_CONFIG.length());

它是一个子字符串,所以它会削减 jcr。的,其余的继续……

parameters.put("jcr.org.apache.jackrabbit.repository.home", repositoryHome);

这是一个棘手的问题,需要从调试中弄清楚所有这些。

于 2011-03-23T10:49:17.203 回答
0

您需要使用以下条目在“WEB-INF/classes”中配置您的“repository.properties”。

jcr.org.apache.jackrabbit.repository.home={user.home}\jcr-repository(您的存储库位置)。

干杯。

于 2011-05-19T14:22:03.823 回答