gpt4 book ai didi

java - Apache 长耳大野兔 : RepositoryException: This session has been closed

转载 作者:行者123 更新时间:2023-12-01 14:27:19 25 4
gpt4 key购买 nike

我正在使用 Apache Jackrabbit。

我发现了一个异常,我尝试了很多,但没有得到这个异常背后的原因。

请帮我解决这个问题。

异常(exception):-

javax.jcr.RepositoryException: This session has been closed.
at org.apache.jackrabbit.jcr2spi.SessionImpl.checkIsAlive(SessionImpl.java:922)
at org.apache.jackrabbit.jcr2spi.ItemImpl.checkStatus(ItemImpl.java:436)
at org.apache.jackrabbit.jcr2spi.NodeImpl.getProperties(NodeImpl.java:489)
at edu.uci.ics.crawler4j.frontier.DocIDServer.getDocId(DocIDServer.java:112)
at edu.uci.ics.crawler4j.crawler.WebCrawler.processPage(WebCrawler.java:286)
at edu.uci.ics.crawler4j.crawler.WebCrawler.run(WebCrawler.java:189)
at java.lang.Thread.run(Thread.java:722)

编辑1

代码如下,

Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));

// Obtain the query manager for the session via the workspace ...
QueryManager queryManager = session.getWorkspace().getQueryManager();

// Create a query object ...
String expression = "SELECT * FROM [sling:OrderedFolder] AS s WHERE ISDESCENDANTNODE([/docIDsDB])";
Query query = queryManager.createQuery(expression, javax.jcr.query.Query.JCR_SQL2);

// Execute the query and get the results ...
QueryResult result = query.execute();

// Iterate over the nodes in the results ...
NodeIterator nodeIter = result.getNodes();

session.logout();

while(nodeIter.hasNext()){
Node node = nodeIter.nextNode();
System.out.println(node.getProperty("url").getString());
System.out.println(node.getProperty("docid").getString());

}

异常

javax.jcr.RepositoryException: This session has been closed.
at org.apache.jackrabbit.jcr2spi.SessionImpl.checkIsAlive(SessionImpl.java:922)
at org.apache.jackrabbit.jcr2spi.ItemImpl.checkStatus(ItemImpl.java:436)
at org.apache.jackrabbit.jcr2spi.NodeImpl.getProperty(NodeImpl.java:471)
at jackrabbit.JackRabbit.main(JackRabbit.java:111)

111行是

System.out.println(node.getProperty("url").getString());

在 Jackrabbit 中,节点和子节点都是 sling:orderedFolder 类型。

最佳答案

只要您访问 JCR session 提供的节点,就保持 JCR session 打开即可。

您应该将 Session.logout() 调用移至 finally 子句,该子句位于使用 Session 提供的所有代码之后。

关于java - Apache 长耳大野兔 : RepositoryException: This session has been closed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17101966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com