[JBoss JIRA] Created: (JBRULES-2203) NullPointerException When Using Conditional Element "or" in LHS Together with a Return Value Restriction
by Christian Spurk (JIRA)
NullPointerException When Using Conditional Element "or" in LHS Together with a Return Value Restriction
--------------------------------------------------------------------------------------------------------
Key: JBRULES-2203
URL: https://jira.jboss.org/jira/browse/JBRULES-2203
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.0.1.FINAL
Environment: Drools 5.0.1 used in an Eclipse Drools project under Windows XP with Java 1.6
Reporter: Christian Spurk
Assignee: Mark Proctor
When using the conditional element "or" on the left hand side of a rule together with a return value restriction somewhere in the same rule, I get the following exception:
Exception in thread "main" java.lang.NullPointerException
at org.drools.rule.ReturnValueRestriction.equals(ReturnValueRestriction.java:304)
at org.drools.rule.ReturnValueConstraint.equals(ReturnValueConstraint.java:121)
at org.drools.reteoo.AlphaNode.equals(AlphaNode.java:218)
at org.drools.reteoo.SingleObjectSinkAdapter.getMatchingNode(SingleObjectSinkAdapter.java:48)
at org.drools.reteoo.builder.BuildUtils.attachNode(BuildUtils.java:130)
at org.drools.reteoo.builder.PatternBuilder.attachAlphaNodes(PatternBuilder.java:295)
at org.drools.reteoo.builder.PatternBuilder.attachPattern(PatternBuilder.java:117)
at org.drools.reteoo.builder.PatternBuilder.build(PatternBuilder.java:70)
at org.drools.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:126)
at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:73)
at org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:153)
at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:126)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:117)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:362)
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:618)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:500)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:379)
at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:121)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:48)
at com.sample.DroolsTest.main(DroolsTest.java:26)
Here is a simple test case which can be used to reproduce the issue:
/* JAVA FILE TO LOAD THE RULE */
package com.sample;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class DroolsTest {
private int arg;
public int getArg() {
return this.arg;
}
public void setArg(int arg) {
this.arg = arg;
}
public static final void main(String[] args) throws Exception {
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
DroolsTest test = new DroolsTest();
test.setArg(2);
ksession.insert(test);
ksession.fireAllRules();
}
/* taken verbatim from the Hello World sample */
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
/* PROBLEMATIC RULE FILE */
package com.sample
import com.sample.DroolsTest;
rule "test"
when
DroolsTest( arg == (1 + 1) );
// REMOVE THE COMMENTED PARTS BELOW TO GET THE EXCEPTION:
//(or eval(true);
eval(true);
//)
then
System.out.println( "it works!" );
end
When the above Java file is compiled and run in combination with the given rule file, everything works fine. However, if the marked parts of the rule are uncommented, then you get the exception.
PS: It seems that the issue has been existing in previous Drools versions already, see https://jira.jboss.org/jira/browse/JBSEAM-3064 for example ("Drools 4.0.7 don't like 'action == (DocumentType.USER.extendedName())' and multiple OR's - weird!").
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months
[JBoss JIRA] Created: (JBRULES-2211) StatefulKnowledgeSession leaves threads running
by Edson Tirelli (JIRA)
StatefulKnowledgeSession leaves threads running
-----------------------------------------------
Key: JBRULES-2211
URL: https://jira.jboss.org/jira/browse/JBRULES-2211
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core
Affects Versions: 5.0.1.FINAL, 5.0.0.FINAL
Reporter: Edson Tirelli
Assignee: Edson Tirelli
Fix For: 5.1.0.M1
Hi all,
I've downloaded Drools fusion sample and started to make some changes to
the code (first of all wipe out the UI so I can test it easier).
I tried to get to a minimal set so I can run a console main class and see
what happens but I am facing a strange behaviour.
As soon as I start pushing events into the WorkingMemoryEntryPoint
("StockTick stream") a Thread - not daemonized since it blocks shutdown from
ending - is spawned and this prevents my JVM from shutting down (obviously
if I call System.exit(0) it will but I am avoiding this).
I've tried both to halt and dispose the session that this entry point
belongs but with no success. Does anyone know how could I get rid of this
thread?
==================
Hi Edson!
as I've already mentioned I've modified the sample so, if you get the StockTick sample and replace the Main class this will run fine.
The sample shuts down fine but as I saw it sets the JFrame uses frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); which in turn makes the trick.
Below the code of my modified main class:
package org.drools.examples.broker;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.conf.EventProcessingOption;
import org.drools.examples.broker.model.Company;
import org.drools.examples.broker.model.CompanyRegistry;
import org.drools.examples.broker.model.StockTick;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
public class Main {
private static final String RULES_FILE = "/broker.drl";
static StatefulKnowledgeSession session;
static WorkingMemoryEntryPoint tickStream;
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// set up and show main window
CompanyRegistry companies = new CompanyRegistry();
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
try {
builder.add( ResourceFactory.newInputStreamResource( Main.class.getResourceAsStream( RULES_FILE ) ),
ResourceType.DRL);
} catch ( Exception e ) {
e.printStackTrace();
}
if( builder.hasErrors() ) {
System.err.println(builder.getErrors());
System.exit( 0 );
}
KnowledgeBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption( EventProcessingOption.STREAM );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( conf );
kbase.addKnowledgePackages( builder.getKnowledgePackages() );
session = kbase.newStatefulKnowledgeSession();
session.setGlobal( "services", new BrokerServices() {
public void log(String message) {
System.out.println(message);
}
});
for( Company company : companies.getCompanies() ) {
session.insert( company );
}
session.fireAllRules();
tickStream = session.getWorkingMemoryEntryPoint( "StockTick stream" );
for (int i=10;i>0;i--) {
tickStream.insert(new StockTick("RHT", i*10, System.currentTimeMillis()));
session.getAgenda().getAgendaGroup( "evaluation" ).setFocus();
session.fireAllRules();
}
session.dispose();
session.halt();
System.out.println("Still running...");
}
}
regards,
Rafael Ribeiro
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months
[JBoss JIRA] Created: (JBRULES-2778) Rule with timer( int: 1m 1m ( causes ArrayStoreException in PackageBuilder
by Wolfgang Laun (JIRA)
Rule with timer( int: 1m 1m ( causes ArrayStoreException in PackageBuilder
--------------------------------------------------------------------------
Key: JBRULES-2778
URL: https://jira.jboss.org/browse/JBRULES-2778
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler
Affects Versions: 5.1.1.FINAL
Reporter: Wolfgang Laun
Assignee: Mark Proctor
Fix For: 5.2.0.M1
A single rule in a DRL file:
rule "minute ticker"
timer( int: 1m 1m )
when
then
System.out.println( "Tick" );
end
causes
xception in thread "main" java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(ArrayList.java:328)
at org.drools.compiler.PackageBuilder.getErrors(PackageBuilder.java:1274)
at org.drools.builder.impl.KnowledgeBuilderImpl.getErrors(KnowledgeBuilderImpl.java:70)
at event.Main.compilePackage(Main.java:72)
at event.Main.main(Main.java:219)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months
[JBoss JIRA] Created: (JBRULES-2675) Syntax error in /trunk/src/documentation/index.html
by Lawrence Terrill (JIRA)
Syntax error in /trunk/src/documentation/index.html
---------------------------------------------------
Key: JBRULES-2675
URL: https://jira.jboss.org/browse/JBRULES-2675
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: All
Affects Versions: 5.1.0.FINAL, 5.1.0.CR1, 5.1.0.M2, 5.1.0.M1, 5.0.1.FINAL, 5.1.1.FINAL, 5.2.0.M1, FUTURE
Reporter: Lawrence Terrill
Assignee: Mark Proctor
Priority: Trivial
In in /trunk/src/documentation/index.html, in the first <tr> group for drools-introduction, the last <td> group for the pdf reference, drools-introduction/pdf/drools-docs-introduction.pdf, is commented out. The ending comment tag is malformed entered as '</td>--' instead of the intended '</td-->'
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months