我正在实现一个包含搜索服务(AbstractService)的 osgi 包。该服务包含一个获取内容节点列表作为 NodeIterator 对象的方法。
public NodeIterator getNodes(Session session, String query, long count) throws RepositoryException{
NodeIterator nodeIterator = null;
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query qry = queryManager.createQuery(query, Query.SQL);
qry.setLimit(count);
QueryResult result = qry.execute();
nodeIterator = result.getNodes();
return nodeIterator;
}
我有一个错误在线:
QueryManager queryManager = session.getWorkspace().getQueryManager();
错误
org.apache.sling.api.SlingException: An exception occurred processing JSP page /apps/IMEApp/Content/Category/../../General/html_marketCommentary.jsp at line 49
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:571)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:496)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
at org.apache.sling.scripting.jsp.JspServletWrapperAdapter.service(JspServletWrapperAdapter.java:59)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:173)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:84)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:388)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:358)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:170)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:456)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:529)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.jcr.Workspace.getQueryManager()Ljavax/jcr/query/QueryManager;" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class, org/dapa/ime/service/AbstractService, and the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) for resolved class, javax/jcr/Workspace, have different Class objects for the type javax/jcr/query/QueryManager used in the signature
at org.dapa.ime.service.AbstractService.getNodes(AbstractService.java:43)
at org.dapa.ime.service.NewsService.getListOfNews(NewsService.java:35)
at org.dapa.ime.service.NewsService.getListOfTopNews(NewsService.java:57)
at org.apache.jsp.apps.IMEApp.Content.Category.html_jsp._jspService(html_jsp.java:1995)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
... 37 more
我无法理解由部分引起的:
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.jcr.Workspace.getQueryManager()Ljavax/jcr/query/QueryManager;" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class, org/dapa/ime/service/AbstractService, and the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) for resolved class, javax/jcr/Workspace, have different Class objects for the type javax/jcr/query/QueryManager used in the signature
任何身体都可以帮忙吗?提前致谢。