Tested on brms-standalone-5.3.0 and the problem described in JIRA still occurs.
This issue should have been fixed only on the 5.3.1.ER1 indeed. Could you please verify?
I did try with brms-standalone-5.3.1 I just wrote the comment wrong. Sorry about confusion.
It works for me. Could you please attach the test you used to verify it?
Created attachment 613628 [details] Repository export I manually created this repository to verify bug. It is impossible to build the testPackage.
That repository works for me. Also I added a further unit test in the code base of the 5.3.x branch using exactly the same DRL generated by that repository and it passes without any problem. I am pasting the source code of that test below: @Test public void testMvelFunctionWithDeclaredTypeArg() { // JBRULES-3562 String rule = "package testPackage\n" + "declare Person\n" + "name: String\n" + "age: Integer\n" + "end\n" + "\n" + "function String PersonToString(Person p) {\n" + "String result = \"\";\n" + "result = p.getName() + \", age: \" + p.getAge();\n" + "return result;\n" + "}\n" + "\n" + "rule \"testRule1\"\n" + "dialect \"mvel\"\n" + "when\n" + "p : Person( )\n" + "then\n" + "System.out.println(PersonToString(p));\n" + "end\n" + "\n" + "rule 'testRule2'\n" + "dialect 'mvel'\n" + "when\n" + "$p : Person()\n" + "then\n" + "System.out.println(PersonToString($p));\n" + "end"; KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( ResourceFactory.newByteArrayResource(rule.getBytes()), ResourceType.DRL ); if ( kbuilder.hasErrors() ) { fail( kbuilder.getErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); }
Created attachment 613683 [details] Error messages I tried again with this [1] version of BRMS using these steps: 1) imported repository 2) opened testPackage 3) tried to build All I got is attached exception (including BRMS version for clarity). [1] http://jawa05.englab.brq.redhat.com/candidate/BRMS-5.3.1-ER1/brms-p-5.3.1.ER1-standalone.zip
Sorry, but I am really not able to reproduce this issue- I don't know how to proceed about it.
I had a colleague of mine trying the same thing and we got the exactly same behaviour as I did. Are you sure, you tried importing the repository into BRMS-5.3.1-ER1? I used the standalone version as it works out of the box, could you please try to download and run the same?
I reproduced the problem, but now it seems a Guvnor issue, so I talked to Toni and assigned this ticket to him.
I managed to isolate what Guvnor does in this unit test: @Test public void testMvelFunctionWithDeclaredTypeArg2() throws IOException, DroolsParserException { String function = "function String getFieldValue(Bean bean) {" + " return bean.getField();" + "}"; String declaredFactType = "declare Bean \n" + " field : String \n" + "end \n"; String rule = "rule R2 \n" + "dialect 'mvel'\n" + "when \n" + " $bean : Bean( ) \n" + "then \n" + " System.out.println( getFieldValue($bean) ); \n" + "end"; PackageBuilder packageBuilder = new PackageBuilder(); packageBuilder.addPackageFromDrl(new StringReader(declaredFactType)); packageBuilder.addPackageFromDrl(new StringReader(function)); packageBuilder.addPackageFromDrl(new StringReader(rule)); for (KnowledgeBuilderError error : packageBuilder.getErrors()) { System.out.println("ERROR:"); System.out.println(error.getMessage()); } assertFalse(packageBuilder.hasErrors()); } Currently the test fails to pass. If the dialect for the Rule R2 is removed it works. There are few solutions: #1 We remove the PackageBuilder from Guvnor and replace it with KnowledgeBuilder. This is a not a small task and will take a week or more. #2 We make PackageBuilder work with how Guvnor is using it. Mario is taking a look at #2. Hopefully there is an easy fix.
#2 is not easy. I have an idea that might work, but the problem is that it will change how Guvnor packages are being built. So there is a possibility that the end result will not be 100% the same as before.
Thank to the test provided by Toni, I've been able to fix this issue in Drools (no need to change Guvnor). Toni also helped me to check that the attached repository export compiles without error now.
In BRMS-5.3.1-ER2 the problem is gone. Thank you
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.