有时当我在一个函数中使用多个 Modeshape 动作时,我会收到此错误:
javax.jcr.RepositoryException:ID 为“060742fc6”的会话已关闭,无法再使用。
我在网上找不到任何对此的解释。这就是我所说的:
myFunction( service.doSomething ( service.getStuff ( id, "en_EN" ).getPath() ) );
做某事,getStuff:
@Interceptors({Foo.class, TraceInterceptor.class})
@Override
public Node doSomething(final String bar) throws RepositoryException {
return modeshape.execute(new JcrHandler<Node>() {
@Override
public Node execute(Session session) throws RepositoryException {
return session.getNode(bar);
}
});
}
@Interceptors(TraceInterceptor.class)
@Override
public ObjectExtended getStuff(final String query, final String language)
throws RepositoryException {
return modeshape.execute(new JcrHandler<ObjectExtended>() {
@Override
public ObjectExtendedexecute(Session session)
throws RepositoryException {
QueryManager queryManager = session.getWorkspace().getQueryManager();
ObjectExtendeditem = null;
String queryWrapped =
"select * from [th:this] as c where name(c)='lang_"
+ language + "' and c.[th:mylabel] "
+ "= '" + queryStr + "'";
LOGGER.debug("Query: " + queryWrapped);
Query query =
queryManager.createQuery(queryWrapped,Query.JCR_SQL2);
QueryResult result = query.execute();
NodeIterator iter = result.getNodes();
while (iter.hasNext()) {
Node node = iter.nextNode().getParent();
if (node.isNodeType("th:term")) {
item = new ObjectExtended();
item.setLabel(getLabel(language, node));
item.setPath(node.getPath());
}
}
return item;
}
});
}
请问为什么会这样?我究竟做错了什么?