Hello, I am new to CMIS and I am presently looking at handling query functionality in our CMIS Server,. To this end, I am attempting to implement the code specified in section 1.7 entitled "Parsing a CMIS Query" in chapter 14 of the text CMIS and Apache Chemistry in Action. While this example code seems very straight forward, I am getting the following error when invoking it for the CMIS SQL statement: Select * from cmis:document where cmis:name = 'My_Document-0-0'. I have tried variations such as ending the SQL statement with a semicolon and others, but the result has been the same.
<faultstring>Query String has illegal tokens after end of statement: [@15,63:63='<EOF>',<-1>,1:63]</faultstring> <detail> <cmisFault:cmisFault xmlns:ns2="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns:cmisFault="http://docs.oasis-open.org/ns/cmis/messaging/200908/"> <type>invalidArgument</type> <code>0</code> <message>Query String has illegal tokens after end of statement: [@15,63:63='<EOF>',<-1>,1:63]</message> <stacktrace:stacktrace xmlns="http://chemistry.apache.org/opencmis/exception" xmlns:stacktrace="http://chemistry.apache.org/opencmis/exception">org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Query String has illegal tokens after end of statement: [@15,63:63='<EOF>',<-1>,1:63] at org.apache.chemistry.opencmis.server.support.query.QueryUtil.getWalker(QueryUtil.java:83) at org.apache.chemistry.opencmis.server.support.query.QueryUtil.traverseStatement(QueryUtil.java:112) Based on debugging that I've performed, the CMIS SQL statement looks like it is getting into the code unaltered, but it goes off the rails somewhere. The following is the QueryUtil::getWalker() method that is failing, specifically the highlighted code: public static CmisQueryWalker getWalker(String statement) throws RecognitionException { CharStream input = new ANTLRStringStream(statement); TokenSource lexer = new CmisQlStrictLexer(input); TokenStream tokens = new CommonTokenStream(lexer); CmisQlStrictParser parser = new CmisQlStrictParser(tokens); CommonTree parserTree; // the ANTLR tree after parsing phase query_return parsedStatement = parser.query(); if (parser.hasErrors()) { throw new CmisInvalidArgumentException(parser.getErrorMessages()); } else if ( tokens.index()!=tokens.size() ) { throw new CmisInvalidArgumentException("Query String has illegal tokens after end of statement: " + tokens.get(tokens.index())); } parserTree = (CommonTree) parsedStatement.getTree(); CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree); nodes.setTokenStream(tokens); CmisQueryWalker walker = new CmisQueryWalker(nodes); return walker; } I did notice that the QueryUtil class is deprecated. Further, as a result of digging around, I have discovered an OpenCMIS Query Parser Example directory. The parsing done in these files uses the QueryUtilStrict class and seems to be done a little differently. Should I use this example code for CMIS SQL parsing instead of the example in the text? Thanks in advance for any and all assistance!