book
Article ID: KB0090346
calendar_today
Updated On:
Description
Resolution:
Description:
============
If a query sql contains hardcoded String value and is surrounded by single quote, TIBCO BusinessEvents Query agent would throw MismatchedTokenException.
i.e,, the query SQL is:
String query_sql = "select * from /Concepts/ProductOrder where order_id = 'order-1234'"
or
String query_sql = "select * from /Concepts/ProductOrder where order_id in ('order-1', 'order-2')"
BE Agent would throw the following error:
2013 Apr 24 18:37:33:138 GMT +8 std-query Error [main] - [query.service] [std-query] Got runtime exception while invoking Action com.tibco.cep.runtime.session.impl.RuleFunctionsExecAction@60d479d9 Objects <>
java.lang.RuntimeException: com.tibco.cep.query.api.QueryException: MismatchedTokenException(114!=39)
at com.tibco.cep.query.functions.QueryFunctions.createInternal(QueryFunctions.java:120)
at com.tibco.cep.query.functions.QueryFunctions.create(QueryFunctions.java:81)
at be.gen.RuleFunctions.nullinitQuery$.initQuery(nullinitQuery$.java:27)
at be.gen.RuleFunctions.initQuery.invoke(initQuery.java:13)
at com.tibco.cep.runtime.session.impl.RuleFunctionsExecAction.execute(RuleFunctionsExecAction.java:38)
at com.tibco.cep.kernel.core.rete.ReteWM$2.doTxnWork(SourceFile:455)
at com.tibco.cep.kernel.core.rete.BeTransaction.run(SourceFile:155)
at com.tibco.cep.kernel.core.rete.BeTransaction.execute(SourceFile:100)
at com.tibco.cep.kernel.core.rete.ReteWM.invoke(SourceFile:426)
at com.tibco.cep.kernel.core.rete.ReteWM.start(SourceFile:175)
at com.tibco.cep.runtime.session.impl.RuleSessionImpl.start(RuleSessionImpl.java:347)
at com.tibco.cep.query.stream.impl.rete.service.QueryAgent.onPrepareToActivate(QueryAgent.java:153)
at com.tibco.cep.runtime.service.cluster.agent.AbstractCacheAgent.prepareToActivate(AbstractCacheAgent.java:126)
at com.tibco.cep.runtime.service.cluster.agent.AbstractCacheAgent.start(AbstractCacheAgent.java:164)
at com.tibco.cep.runtime.service.cluster.agent.AgentRuntimePolicyManager.tryActivateAgent(AgentRuntimePolicyManager.java:169)
at com.tibco.cep.runtime.service.cluster.agent.AgentRuntimePolicyManager.stabilizeCluster(AgentRuntimePolicyManager.java:245)
at com.tibco.cep.runtime.service.cluster.agent.AgentRuntimePolicyManager.tryActivateLocalAgents(AgentRuntimePolicyManager.java:293)
at com.tibco.cep.runtime.service.cluster.agent.DefaultAgentManager.start(DefaultAgentManager.java:99)
at com.tibco.cep.runtime.service.cluster.MultiAgentCluster.start(MultiAgentCluster.java:253)
at com.tibco.cep.runtime.session.impl.RuleServiceProviderImpl.startCluster(RuleServiceProviderImpl.java:786)
at com.tibco.cep.runtime.session.impl.RuleServiceProviderImpl.configure(RuleServiceProviderImpl.java:261)
at com.tibco.cep.container.standalone.BEMain.jumpStart(SourceFile:151)
at com.tibco.cep.container.standalone.BEMain.main(SourceFile:69)
Caused by: com.tibco.cep.query.api.QueryException: MismatchedTokenException(114!=39)
at com.tibco.cep.query.service.impl.QueryImpl.<init>(QueryImpl.java:111)
at com.tibco.cep.query.service.impl.QueryRuleSessionImpl.createQuery(QueryRuleSessionImpl.java:219)
at com.tibco.cep.query.functions.QueryFunctions.createInternal(QueryFunctions.java:97)
... 22 more
Caused by: MismatchedTokenException(114!=39)
at org.antlr.runtime.Lexer.match(Lexer.java:188)
at com.tibco.cep.query.ast.parser.BEOqlLexer.mCharLiteral(BEOqlLexer.java:6675)
at com.tibco.cep.query.ast.parser.BEOqlLexer.mTokens(BEOqlLexer.java:8096)
at com.tibco.cep.query.ast.parser.BEOqlLexer.nextToken(BEOqlLexer.java:251)
at org.antlr.runtime.CommonTokenStream.fillBuffer(CommonTokenStream.java:119)
at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:238)
at com.tibco.cep.query.ast.parser.BEOqlParser.query(BEOqlParser.java:287)
at com.tibco.cep.query.ast.parser.ParserUtil.parse(ParserUtil.java:66)
at com.tibco.cep.query.ast.parser.ParserUtil.getAST(ParserUtil.java:93)
at com.tibco.cep.query.service.impl.QueryImpl.parseOql(QueryImpl.java:160)
at com.tibco.cep.query.service.impl.QueryImpl.<init>(QueryImpl.java:97)
... 24 more
Environment:
===========
TIBCO BusinessEvents: 5.x
OS: All
Cause:
===========
In PSQL or TSQL, a string value is surrounded by single quote. However, unlike PSQL or TSQL, in BQL hardcoded String values should be surrounded by double quotes instead of single quotes.
Resolution:
=========
Change single quote to double quotes, and prepend a backslash to escape special characters when necessary:
String query_sql = "select * from /Concepts/ProductOrder where order_id =\"order-1234\""
or
String query_sql = "select * from /Concepts/ProductOrder where order_id in (\"order-1\", \"order-2\")"
:lso refer to document:
TIBCO BusinessEvents Event Stream Processing Developer’s guide -> Chapter 6 Query Language Reference -> Wildcards, Datatypes, Literals, Identifiers, and Keywords -> Datatypes
>>>>>>>>>>>>>>>
String literals are surrounded by double quotes. To escape double quote and backslash characters, prefix them with a backslash.
<<<<<<<<<<<<<<<
Issue/Introduction
TIBCO BusinessEvents Query agent threw MismatchedTokenException when string value is hardcoded and surrounded by double quotes in the query.