为了创建JCR节点,我们尝试使用JcrUtils.getRepository(...)
方法以编程方式连接到远程AEM实例,以获取存储库实例的句柄。
此实例是安全的,并检查请求中的cookie以允许用户进入。
有没有办法将cookie传递给JcrUtils
(或其他连接到AEM存储库的方法)?
现在,当运行代码JcrUtils.getRepository("http://host:port/crx/server");
时,它只会抛出以下异常:
javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: https://<host>:<port>/crx/server
The following RepositoryFactory classes were consulted:
org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory: declined
org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory: declined
org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
org.apache.jackrabbit.core.RepositoryFactoryImpl: declined
org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
because of RemoteRuntimeException: java.rmi.RemoteException: Failed to read the resource at URL https://<host>:<port>/crx/server; nested exception is:
java.io.StreamCorruptedException: invalid stream header: 3C21444F
because of RemoteException: Failed to read the resource at URL https://<host>:<port>/crx/server; nested exception is:
java.io.StreamCorruptedException: invalid stream header: 3C21444F
because of StreamCorruptedException: invalid stream header: 3C21444F
Perhaps the repository you are trying to access is not available at the moment.
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
...
答案 0 :(得分:1)
无法通过JcrUtils.getRepository(...)
传递Cookie,它接受URI作为字符串。
在您的日志中,应用程序类路径中不存在 org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory 。 确保添加到libs之后的依赖项
如果您使用的是Maven:
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr2dav</artifactId>
<version>2.10.1</version>
</dependency>
答案 1 :(得分:1)
我遇到与@ user3239244类似的问题,但仅限于https。 我试图从独立的Java应用程序访问存储库
repository = JcrUtils.getRepository(url)
适用于http
,但https
来自日志:
javax.jcr.RepositoryException:无法使用。访问存储库 以下设置: org.apache.jackrabbit.repository.uri: https://localhost:5433/crx/server以下RepositoryFactory 咨询了课程: org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory:谢绝了 org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory:谢绝了 org.apache.jackrabbit.commons.JndiRepositoryFactory:谢绝了 org.apache.jackrabbit.core.RepositoryFactoryImpl:谢绝了 org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory:失败了 因为RepositoryException:无法读取URL https://localhost:5433/crx/server处的资源 因为SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 找到所请求目标的有效证书路径 因为ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法 找到所请求目标的有效证书路径 因为SunCertPathBuilderException:无法找到所请求目标的有效证书路径