Hide Forgot
Created attachment 550253 [details] camel jaxb insert CCE reproducer I have this camel-drools configuration: camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { JaxbDataFormat jdf = new JaxbDataFormat(); jdf.setContextPath("com.redhat.jaxbinsert.domain"); jdf.setPrettyPrint(true); from("direct:test-session").policy(new DroolsPolicy()).unmarshal(jdf).to("drools://testnode/ksession").marshal(jdf); from("direct:unmarshall").policy(new DroolsPolicy()).unmarshal(jdf); from("direct:marshall").policy(new DroolsPolicy()).marshal(jdf); } }); I am trying to insert single fact into session this way: //command creation, marshalling into XML and sending to drools Person p = new Person("Alice", "spicy meals", 30); p.setId(1); List<Command> commands = new ArrayList<Command>(); commands.add(CommandFactory.newInsert(p, "tempPerson")); BatchExecutionCommand command = CommandFactory.newBatchExecution(commands); String xmlCommand = template.requestBody("direct:marshall", command, String.class); String xml = template.requestBody("direct:test-session", xmlCommand, String.class); ExecutionResults res = (ExecutionResults) template.requestBody("direct:unmarshall", xml); FactHandle handle = (FactHandle)res.getFactHandle("tempPerson"); ClassCastException is thrown on the last line of code - when retrieving FactHandle from unmarshalled ExecutionResult: Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to org.drools.runtime.rule.FactHandle at com.redhat.jaxbinsert.JaxbCamel.testInsert(JaxbCamel.java:105) at com.redhat.jaxbinsert.App.main(App.java:12) ------------------------------------------------------------------------------- Instead of FactHandle instance, only it's String reprezentation is returned. See an attachment for the details, build it and run it as maven project.
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.
ERD states that the Camel integration is being productized. (https://docspace.corp.redhat.com/docs/DOC-76523)
The attached testcode makes use of drools-grid. Drools Grid is not supported and likely broken (from what I 've heard). It should not be in BRMS 5.3.0.BRMS.ER1 and I don't think it's in the latest productized builds any more. Offending code: GridImpl grid = new GridImpl(); grid.addService(WhitePages.class, new WhitePagesImpl()); GridNode node = grid.createGridNode("testnode"); Context context = new JndiContext();
I've rewritten the reproducing most of the code as a test in CamelEndpointTest and cherry-picked it to 5.3.x: https://github.com/droolsjbpm/droolsjbpm-integration/commit/449596510458de442cacea0542b0ec965658bb0b It makes use of CommandFactory.newBatchExecution and response.getFactHandle, yet doesn't throw a CCE. Please check if you can reproduce the CCE without using drools-grid. Optional: Even better would be if you could send in a github pull request that adds a unit test to droolsjbpm-integration that fails with the CCE. https://github.com/droolsjbpm/droolsjbpm-integration
Here is a pull request with reproducers for these 3 connected issues: https://github.com/droolsjbpm/droolsjbpm-integration/pull/12
The other 2 issues are fixed (weeks ago), but this one is still open. It's this currently @Ignored test: org.drools.camel.component.JaxbInsertTest#testInsert() in /home/gdesmet/projects/jboss/droolsjbpm/droolsjbpm-integration/drools-camel/src/test/java/org/drools/camel/component/JaxbInsertTest.java The main problem is that ExecutionResultImpl.facts is of type HashMap<String, Object> but should probably be of type Map<String, FactHandle>.
The bug is in JaxbMapAdapter, which changes a FactHandle into a String during marshalling, but doesn't do the same during unmarshalling. The problem is that the reverse operation is not possible, because not every String in a JAXB map is a FactHandle...
Fixed. Applied on 5.3, 5.4 and master. It turns out that the normal FactHandle implementations are JAXB ready, so JaxbMapAdapter should not do any dirty hacks like converting it to a String externalForm.
Update status to ON_QA. Please verify them against ER6.
Confirmed that not picked in ER6. Change status back.
This fix has actually been committed to project branch which BRMS 5.3 used. The commit had been done before the blocker cut off date. So this requires to request block+ flag.
CCE is fixed, but another problem occurs. FactHandle is returned as expected: ExecutionResults res = (ExecutionResults) template.requestBody("direct:unmarshall", xml); FactHandle fh = (FactHandle) res.getFactHandle("tempPerson"); But the returned fact handle has external form [fact 0:0:0:0:0:null:null] - and of course null object is returned from knowledge session by calling session.getObject(fh); Other command formats (json, xstream, pojo) return right fact handle which points to the inserted object in the knowledge session. Please take a look at the org.drools.camel.component.JaxbInsertTest#testInsert() and inspect the returned fact handle.
For the record, here's the first change commit: https://github.com/droolsjbpm/drools/commit/8e6551a3decf62f96cbe24049a5633d5f22950be This issue has no blocker+ tag, so I cannot fix it on 5.3.x (so not prioritizing it at the moment). I 'll fix it for master 5.5 and 5.4.x after my PTO.
Reassign to the guvnor team, now that I am working full time on planner. So these issues aren't forgotten.