[JBoss JIRA] Created: (JBRULES-2930) KnowledgeAgentDefinitionParser can get NPEs
by stevearoonie (JIRA)
KnowledgeAgentDefinitionParser can get NPEs
-------------------------------------------
Key: JBRULES-2930
URL: https://issues.jboss.org/browse/JBRULES-2930
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-spring
Affects Versions: 5.1.1.FINAL
Reporter: stevearoonie
Assignee: Mark Proctor
KnowledgeAgentDefinitionParser assumes that a spring bean definition has a bean class name, however when the bean extends a parent then it may not, as in the following example:
<bean id="messageTemplateService" class="au.com.promedicus.template.freemarker.FreemarkerTemplateService">
<constructor-arg ref="workflowFreemarkerConfiguration"/>
</bean>
<bean id="workflowFreemarkerConfiguration" parent="freemarkerConfiguration">
<property name="templateLoader">
<bean class="au.com.promedicus.core.messaging.freemarker.FreemarkerMessageLayoutTemplateLoader" />
</property>
</bean>
The BeanDefinition for bean "workflowFreemarkerConfiguration" has a null bean class name which causes KnowledgeAgentDefinitionParser.parseInternal to throw an NPE. Specifically this line:
if ( def.getBeanClassName().equals( StatelessKnowledgeSessionBeanFactory.class.getName() ) ) {
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-3000) Free form expression <field> != <object>.<method>(...) fails to parse
by Wolfgang Laun (JIRA)
Free form expression <field> != <object>.<method>(...) fails to parse
---------------------------------------------------------------------
Key: JBRULES-3000
URL: https://issues.jboss.org/browse/JBRULES-3000
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 3.0.4
Reporter: Wolfgang Laun
Assignee: Mark Proctor
According to Drools Introduction 2.1.3.1. Free Form expressions in Constraints (New Parser) "free form" expressions should be possible. However, the rule shown below does not compile and a stack dump is printed, (The legacy form using a return value restriction works correctly.)
public abstract class BinOp {
private Pin inPin1;
private Pin inPin2;
private Pin outPin;
public BinOp( Pin inPin1, Pin inPin2, Pin outPin ){
this.inPin1 = inPin1;
this.inPin2 = inPin2;
this.outPin = outPin;
}
public Pin getInPin1() { return inPin1; }
public Pin getInPin2() { return inPin2; }
public Pin getOutPin() { return outPin; }
protected abstract boolean op( boolean x, boolean y );
public boolean op( Pin x, Pin y ){
return op( x.isValue(), y.isValue() );
}
}
public class Pin {
private boolean value;
public Pin(){
}
public boolean isValue(){
return value;
}
public void setValue( boolean value ){
this.value = value;
}
}
rule "gate with two inputs"
when
$binOp : BinOp( $inPin1 : inPin1, $inPin2 : inPin2, $outPin : outPin )
Pin( this == $inPin1 )
Pin( this == $inPin2 )
Pin( this == $outPin, value != ( $binOp.op( $inPin1, $inPin2 ) ) )
then
//...
end
Error message + stack dump:
Exception in thread "main" [Error: Failed to compile: 2 compilation error(s):
- (1,5) unable to resolve method using strict-mode: appl.circuit.BinOp.$inPin1()
- (1,5) unqualified type in strict mode for: $inPin1]
[Near : {... op( $inPin1, $inPin2 ) ....}]
^
[Line: 1, Column: 5]
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:95)
at org.mvel2.MVEL.compileExpression(MVEL.java:829)
at org.drools.base.extractors.MVELClassFieldReader.<init>(MVELClassFieldReader.java:64)
at org.drools.rule.builder.PatternBuilder.createDeclarationObject(PatternBuilder.java:976)
at org.drools.rule.builder.PatternBuilder.createDeclarationObject(PatternBuilder.java:939)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:582)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:242)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:61)
at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:81)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1546)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:653)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:295)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:471)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-3042) KnowledgeAgent.applyChangeSet(notExistingResource) should throw an understandable exception instead of a NullPointerException
by Geoffrey De Smet (JIRA)
KnowledgeAgent.applyChangeSet(notExistingResource) should throw an understandable exception instead of a NullPointerException
-----------------------------------------------------------------------------------------------------------------------------
Key: JBRULES-3042
URL: https://issues.jboss.org/browse/JBRULES-3042
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Reporter: Geoffrey De Smet
Fix For: 5.3.0.M1
Discovered by the guvnor-examples MortgageClientExample
The exception is essentially eaten here in KnowledgeAgentImpl:
{code}
try {
changeSet = reader.read( resource.getReader() );
} catch ( Exception e ) {
this.listener.exception( new RuntimeException(
"Unable to parse ChangeSet",
e ) );
}
{code}
OK, it logs it, but it doesn't throw an exception (might be related to use of the Agent in spring??? where we don't want it to die on a network IO problem?).
Instead a NPE occurs later because the changeSet is still null:
{code}
Exception in thread "main" java.lang.NullPointerException
at org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgentImpl.java:223)
at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:189)
at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:174)
at org.drools.guvnor.examples.mortgage.client.MortgageClientExample.readKnowledgeBase(MortgageClientExample.java:81)
at org.drools.guvnor.examples.mortgage.client.MortgageClientExample.main(MortgageClientExample.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-3057) Misleading error message for missing constructor
by Wolfgang Laun (JIRA)
Misleading error message for missing constructor
------------------------------------------------
Key: JBRULES-3057
URL: https://issues.jboss.org/browse/JBRULES-3057
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.2.0.CR1
Reporter: Wolfgang Laun
Assignee: Mark Proctor
Fix For: 5.2.0
If an undeclared constructor is called in a consequence, a very strange error message is produced:
- error text is "Failed to compileShared" ("Shared" is not used by the app)
- The message part meant ot identify the location of the error is misleanding, e.g.,
Near : {... p3.setName( "Paul" ); ....}
with the marker ("^") pointing to "Paul".
public static class Person {
private String name;
public Person(String name){
this.name = name;
}
public String getField1() {
return field1;
}
public void setName( String name ) {
this.name = name;
}
public String getName() {
return name;
}
}
@Test
public void testExistsIterativeModifyBug() {
String str = "";
str += "package org.simple ";
str += "import Person ";
str += "rule xxx ";
str += "when ";
str += "then ";
str += " Person = new Person() ";
str += "end ";
KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
assertFalse( kBuilder.hasErrors() );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.fireAllRules();
ksession.dispose();
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months