Thanks Wolfgand Laun. Finally it worked. It was indeed a translation error
as the VM was not able to find the DSL file. I changed the content as
suggested, included an expander statement and it worked fine.
On Fri, Mar 21, 2014 at 10:33 PM, laune [via Drools] <
ml-node+s46999n4028907h99(a)n3.nabble.com> wrote:
The corrected version of dsl and dslr works fine.
-----------
[condition][]There is a Customer with first name {name}=
$customer : Customer(firstName == {name})
[consequence][]Greet Customer=
System.out.println("Hello " +
$customer.getFirstName());
-----------
package dsltest;
rule "hello rule"
when
There is a Customer with first name "David"
then
Greet Customer
end
------------
You don't have to write the DSL all in one line. (I fixed that some time
ago.)
The error message suggests that translation fails.
1) Make sure the DSLR is *exactly* as above. (The package could be
different, and there is tolerance w.r.t. spacing between words.)
2) ALWAYS print builder errors (see below).
3) Make sure you pass resources correctly to the builder. This is how
it is done for 5.x:
KnowledgeBaseConfiguration kBaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
KnowledgeBuilderConfiguration kbConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder( kbConfig );
Resource dsl = ResourceFactory.newFileResource( dslPath );
Resource dslr = ResourceFactory.newFileResource( dslrPath );
long t0 = System.currentTimeMillis();
kBuilder.add( dsl, ResourceType.DSL );
kBuilder.add( dslr, ResourceType.DSLR );
if( kBuilder.hasErrors() ){
System.err.println( ">>> compilation errors >>>"
);
KnowledgeBuilderErrors errors = kBuilder.getErrors();
for( KnowledgeBuilderError err: errors ){
System.err.println( err.getMessage() );
}
System.err.println( "<<< compilation errors <<<"
);
throw new IllegalStateException( "compile errors" );
}
kBase = KnowledgeBaseFactory.newKnowledgeBase( kBaseConfig );
kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
kSession = kBase.newStatefulKnowledgeSession();
-W
-----
-- Ankit
--
View this message in context:
http://drools.46999.n3.nabble.com/Not-able-to-detect-how-to-correct-ERR-1...
Sent from the Drools: User forum mailing list archive at
Nabble.com.