Exception in thread "main" org.drools.rule.InvalidRulePackage: Unable to create Field Extractor for 'CantSegundos' : [Rule name=Valida Duracion nula, agendaGroup=MAIN, salience=0, no-loop=false]
org.drools.RuntimeDroolsExceptionorg.drools.RuntimeDroolsException
: org.drools.RuntimeDroolsException: java.lang.NullPointerExceptionat org.drools.rule.Package.checkValidity(
Package.java:408)at org.drools.common.AbstractRuleBase.addPackage(
AbstractRuleBase.java:288)at prototipo.Prueba.main(
Prueba.java:27)the class main is:
public
static final void main(String[] args) throws Exception { final PackageBuilder builder = new PackageBuilder();builder.addPackageFromDrl(
new InputStreamReader( Prueba.class .getResourceAsStream( "regla.drl" ) ) ); final RuleBase ruleBase = RuleBaseFactory.newRuleBase();ruleBase.addPackage( builder.getPackage() );
final StatefulSession session = ruleBase.newStatefulSession();Integer segundos =
new Integer(5);validaciones valida =
new validaciones();valida.setCantSegundos(segundos);
session.insert( valida);
session.fireAllRules();
in the rules is:
package
prototipo import prototipo.validaciones; rule "Valida Duracion nula" when v : validaciones(CantSegundos == 0) thenv.setResultado(
"I");System.out.println(
"obtenemos" + v.getResultado() ); end rule "valida Duracion " when v : validaciones(CantSegundos > 0) thenv.setResultado(
"S");System.out.println(
"obtenemos" + v.getResultado()); endThank you for helping me.