我正在使用 Apache Jackrabbit。
我发现了一个异常,我尝试了很多但没有得到这个异常背后的原因。
请帮我解决这个问题。
例外 :-
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 类型。