Bug 771193 - Camel integration: exception occurs when launching query command with arguments in JSON format
Summary: Camel integration: exception occurs when launching query command with argumen...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.3.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: BRMS 5.3.0.GA
Assignee: Nobody
QA Contact: Radovan Synek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-02 11:57 UTC by Radovan Synek
Modified: 2022-11-15 23:14 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: ---


Attachments (Terms of Use)
camel json query command reproducer (6.84 KB, application/zip)
2012-01-02 11:57 UTC, Radovan Synek
no flags Details

Description Radovan Synek 2012-01-02 11:57:36 UTC
Created attachment 550239 [details]
camel json query command reproducer

With camel routes defined as follows:

camelContext.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:test-session").policy(new DroolsPolicy()).unmarshal("json").to("drools://testnode/ksession").marshal("json");
                from("direct:unmarshall").policy(new DroolsPolicy()).unmarshal("json");
                from("direct:marshall").policy(new DroolsPolicy()).marshal("json");
            }
 
        });

, trying to execute query command through the first route ("direct:test-session"). To be sure JSON command format is right, first step is creating query command through API, second is marshalling this command to JSON and third step is sending marshalled command to drools.

String queryStr = template.requestBody("direct:marshall", CommandFactory.newQuery("persons", "people over the age of x", new Object[]{30}), String.class);

        String json = template.requestBody("direct:test-session", queryStr, String.class);
        ExecutionResults res = (ExecutionResults) template.requestBody("direct:unmarshall", json);
        return (QueryResults) res.getValue("persons");

I am expecting query results in JSON (unmarshalling these result is the last step), but this exception occurs:

Exception in thread "main" org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: QueryCommand{outIdentifier='persons', name='people over the age of x', arguments=[]}]
	at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1142)
	at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:452)
	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:441)
	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:119)
	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:135)
	at org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:283)
	at org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:313)
	at com.redhat.cameljsonreproducer.JsonCamel.query(JsonCamel.java:109)
	at com.redhat.cameljsonreproducer.JsonCamel.testQuery(JsonCamel.java:100)
	at com.redhat.cameljsonreproducer.App.main(App.java:12)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
	at org.drools.base.extractors.ArrayElementReader.isNullValue(ArrayElementReader.java:189)
	at org.drools.rule.VariableRestriction$LongVariableContextEntry.updateFromTuple(VariableRestriction.java:451)
	at org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:108)
	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:91)
	at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:197)
	at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:146)
	at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:158)
	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
	at org.drools.reteoo.EntryPointNode.assertQuery(EntryPointNode.java:146)
	at org.drools.reteoo.ReteooWorkingMemory.getQueryResults(ReteooWorkingMemory.java:195)
	at org.drools.impl.StatefulKnowledgeSessionImpl.getQueryResults(StatefulKnowledgeSessionImpl.java:769)
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:104)
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:36)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
	at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:809)
	at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:781)
	at org.drools.camel.component.DroolsExecuteProducer.process(DroolsExecuteProducer.java:100)
	at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)
	at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:290)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:202)
	at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:256)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:143)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:78)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:58)
	at org.drools.camel.component.DroolsPolicy$DroolsProcess.process(DroolsPolicy.java:344)
	at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:290)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:202)
	at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:256)
	at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:113)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
	at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:99)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
	at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
	at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:333)
	at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:304)
	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:208)
	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:303)
	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:171)
	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:114)
	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:118)
	... 6 more

------------------------------------------------------------------------------

See an attachment for the details. Build it and run as maven application.

Comment 2 Mark Proctor 2012-01-19 01:03:20 UTC
Camel isn't being productised yet. So check with prakash/johng before progressing further on this one. If the bug seems genuine, please re-open a jira for .org and we'll make sure it's fixed there.

Comment 3 Lukáš Petrovický 2012-01-19 07:38:33 UTC
ERD states that the Camel integration is being productized. (https://docspace.corp.redhat.com/docs/DOC-76523)

Comment 5 Geoffrey De Smet 2012-02-08 15:34:59 UTC
This reproduce code uses the drools-grid stuff too:

        GridImpl grid = new GridImpl();
        grid.addService(WhitePages.class, new WhitePagesImpl());
        GridNode node = grid.createGridNode("testnode");
 Context context = new JndiContext();
 context.bind("testnode", node);
        node.set("ksession", session);

        CamelContext camelContext = new DefaultCamelContext(context);

Please see the comments in this issue for more information:
  https://bugzilla.redhat.com/show_bug.cgi?id=771203
Drools-grid is not support (or stable for that matter).

Would you mind creating a reproduce test case without using drools-grid?

Comment 6 Radovan Synek 2012-02-09 13:39:05 UTC
here is a pull request with reproducers for these 3 connected issues:
https://github.com/droolsjbpm/droolsjbpm-integration/pull/12

Comment 7 Geoffrey De Smet 2012-03-15 14:36:10 UTC
Fixed the unmarshalling issue in master and 5.3.x.
The testcase is only on master currently.
Fixed an import problem in the testcase on master.

But, the API of the QueryResults object returned doesn't make much sense to me. How is user suppose to use that? Check with the documentation and/or Mark if that's a problem.

https://github.com/droolsjbpm/drools/commit/142cc1dc7d0d3109d7f0b851fa9563733a067326
https://github.com/droolsjbpm/droolsjbpm-integration/commit/d5bdac6baa4db4411e5777251e4f182850fa9f56

Comment 8 Ryan Zhang 2012-03-21 09:55:17 UTC
Please verify this issue on ER5.


Note You need to log in before you can comment on or make changes to this bug.