cancel
Showing results for 
Search instead for 
Did you mean: 

jcr-xpath 'Unknown Query Language'

topherjohnson
Champ in-the-making
Champ in-the-making
I have a webscript that's using seach.query:

var def =
   {
      query: "*//.[@wca:parentformname='formname']",
      store: "avm://" + args.storeid,
      language: "jcr-xpath"
   };
   var results = search.query(def);

And when I run it, I get this error:

Exception:   org.alfresco.repo.search.SearcherException - Unknown query language: jcr-xpath

org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl.query(ADMLuceneSearcherImpl.java:500)
org.alfresco.repo.search.SearcherComponent.query(SearcherComponent.java:84)
sun.reflect.GeneratedMethodAccessor839.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:148)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy24.query(Unknown Source)
org.alfresco.repo.jscript.Search.query(Search.java:700)

I am using Enterprise - v3.2.0 (304).   Why isn't this working.  The query works in the node browser when I select "selectnodes" as the language.  How do I enable jcr-xpath so that I can query for attributes?
1 REPLY 1

royboerner
Champ in-the-making
Champ in-the-making
Hello,

I have the same issue using Alfresco Community v3.3.0 (g 2860).

That is what I'm trying inside a web script:

// xpath query example
var searchStr3 = {
   query: "//*[@cm:name='sample-file-a.txt']",
   language: "jcr-xpath"
}
var xpathSearchNodes = search.query(searchStr3);
logger.log("xpath query found " + xpathSearchNodes.length + " node(s)");
model.xpathResult = xpathSearchNodes;

That's the stack trace I get:

Caused by: org.alfresco.error.AlfrescoRuntimeException: 07030274 Failed to execute search: //*[@cm:name='sample-file-a.txt']
        at org.alfresco.repo.jscript.Search.query(Search.java:758)
        at org.alfresco.repo.jscript.Search.query(Search.java:628)
        at sun.reflect.GeneratedMethodAccessor1089.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
        at org.mozilla.javascript.gen.c98._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/search.get.js:23)
        at org.mozilla.javascript.gen.c98.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/search.get.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c98.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/search.get.js)
        at org.mozilla.javascript.gen.c98.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/search.get.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:453)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:179)
        … 25 more
Caused by: org.alfresco.repo.search.SearcherException: Unknown query language: jcr-xpath
        at org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl.query(ADMLuceneSearcherImpl.java:489)
        …

Is this a bug?

The feature is working in principle via Node Browser. Furthermore its described in the Wiki (http://wiki.alfresco.com/wiki/Search_Documentation#XPath_search_using_the_node_service).
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.