Please help me to fix the AgendaFilter related issue
by Sanjib Karmakar
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.spi.Activation;
import org.drools.spi.AgendaFilter;
.
.
.
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(
ResourceFactory.newClassPathResource(resourceIndicator),
ResourceType.XDRL
);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
.
.
.
public Object getSpecificRuleReport(
Object requestDTO,
Object responseDTO,
final String ruleAry[]
)
throws Exception
{
AgendaFilter agendafilter =
new StatefulKnowledgeSessionImpl.AgendaFilterWrapper(null)
{
public boolean accept(Activation activation)
{
boolean returnFlag = false;
int ruleArySize = ruleAry.length;
for (int cnt=0; cnt<ruleArySize; cnt++)
{
if (activation.getRule().getName().equals(ruleAry[cnt]))
returnFlag = false;
else
returnFlag = true;
}
return returnFlag;
}
};
try
{
ksession.insert(requestDTO);
ksession.insert(responseDTO);
ksession.fireAllRules(agendafilter);
}catch(Exception t)
{
_logger.error(t.getMessage()+"\n"+t);
}
return responseDTO;
}
Eclipse is showing that there is a method fireAllRules() which takes
AgendaFilter as a parameter
but I am getting error "The method fireAllRules(int) in the type
StatefulRuleSession is not applicable for the arguments (AgendaFilter)" at
'ksession.fireAllRules(agendafilter);'
I am trying to execute specific rules out of set of rules. Please help me to
fix this issue.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Please-help-me-to-fix...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
IAE when calling constructor from RHS
by Wolfgang Laun
In Java, a constructor with package level visibility can be called from some
other class in the same package.
It seems that this is not possible from the RHS of a rule that is in a .DRL
file that has the same "package" declaration as the package of the class
that should be instantiated. An IllegalAccessException is thrown.
This looks as if the constructor called reflectively from another package?!
xception in thread "main" java.lang.IllegalAccessError: tried to access
method
rss.ixl.route.TrainStartGoalConn.<init>(Lrss/ixl/cfg/jaxb/elrep/FrontBackType;Lrss/ixl/cfg/jaxb/elrep/FrontBackType;Ljava/lang/String;Lrss/ixl/cfg/jaxb/elrep/ElemType;)V
from class rss.ixl.route.Rule_concatenateRoutes_0
at
rss.ixl.route.Rule_concatenateRoutes_0.consequence(Rule_concatenateRoutes_0.java:12)
at
rss.ixl.route.Rule_concatenateRoutes_0ConsequenceInvoker.evaluate(Rule_concatenateRoutes_0ConsequenceInvoker.java:38)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:682)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:649)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183)
at rss.aws.engine.impl.DroolsEngine.runUntilIdle(DroolsEngine.java:85)
at rss.aws.init.Main.exec(Main.java:133)
at rss.aws.init.Main.main(Main.java:199)
Best
-W
14 years, 3 months
Drools flow - foreach element
by Miloslav Vlach
Hi,
I have to use the for each element:
<forEach id="7" name="pro všechny PM" x="5" y="16" width="650" height="773"
variableName="projectManager" collectionExpression="invoice.pmArray" >
</forEach>
the variable projectManager shlould be addressable in the forEach node. But
the variable cannot be used in the split element (there is created drl
content which cannot access the projectManger variable name)
<split id="22" name="Schvaleno/Neschvaleno" x="409" y="188" width="49"
height="49" type="2" >
<constraints>
<constraint toNodeId="7" toType="DROOLS_DEFAULT" name="pokračování"
priority="1" type="rule" dialect="mvel" >eval(false)</constraint>
<constraint toNodeId="27" toType="DROOLS_DEFAULT" name="neschváleno"
priority="1" type="rule" dialect="mvel"
>eval("mvlach".equals(projectManager))</constraint>
</constraints>
</split>
Where is the problem, can somebody help me ?
Thanks Miloslav Vlach
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-flow-foreach-e...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
How has JPAKnowledgeService changed from 5.1.0.M2 to 5.1.0.FINAL?
by Alan.Gairey@tessella.com
We're using stateful knowledge sessions created by
JPAKnowledgeService.newStatefulKnowledgeSession to execute Drools Flow
rule flows, mainly consisting of a sequence of work items.
With 5.1.0.M2, everything works as expected.
However, with 5.1.0 (final release), when the rule flow starts the
following is output by log4j:
2010-08-20 16:59:41,264 WARN
[org.drools.persistence.session.JtaTransactionManager] - Participating in
existing JTA transaction, but no JTA TransactionManager or
TransactionSychronizationRegistry available:
Then the rule stops before completion with:
2010-08-20 17:01:12,500 WARN [org.hibernate.util.JDBCExceptionReporter] -
SQL Error: 0, SQLState: null
2010-08-20 17:01:12,500 ERROR [org.hibernate.util.JDBCExceptionReporter] -
error enlisting a JdbcConnectionHandle of a JdbcPooledConnection from
datasource jdbc/BitronixJTADataSource in state ACCESSIBLE wrapping
oracle.jdbc.driver.T4CXAConnection@1c47258 on
oracle.jdbc.driver.LogicalConnection@2f1a5f
The configuration is pretty standard (Bitronix transaction manager, Oracle
11g database). We'd like to use the final release of 5.1.0 rather than a
milestone, but this problem is holding us back. Does anyone have any idea
what the problem is? What's changed with Drools Flow state persistence
between 5.1.0.M2 and 5.1.0? Any help would be gratefully received. Thank
you.
Alan
14 years, 3 months
nodeInstanceID from taskID
by Eugenio Abello
As I can determine nodeInstanceID associated with a task (HumanTask). from
the taskID.
I am working with drools 5.1
thanks
14 years, 3 months
Drools scalability
by S Feseha
Can one session be shared amongst multiple threads? In the book Drools JBoss Rules 5.0 Developer's Guide it says that sessions cannot be shared as they contain state which i understand but in chapter 12 they say that "Drools supports parallel execution mode. One session can be executed by multiple threads." using Knowledge partitioning what exactly does this mean?
Thanks in advance
14 years, 3 months
Steps for uploading model jar and decision table in guvnor
by Swapnil Sawant
Hi,
PFA the model jar and decision table that I have created .
myTest.jar contains my model class 'AmountPojo' and currently I have written only one PF rule using this 'AmountPojo' class
I have done following things successfully on guvnor GUI :
- uploading of model jar in a package(named Test)
- uploading decision table xls in same package
- 'save and validate configuration' and 'building package'after above steps
- Creating test scenario for testing that my rule is working fine
Now, I wish to utilize this package in my application through changeset.xml. For this, I wrote something like :
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd' >
<add>
<resource source='https://ofbiz.apache.org:8443/drools-guvnor/org.drools.guvnor.Guvnor/pack...' type='DRL' />
</add>
</change-set>
Also, in my code I have created knowledge agent like dis :
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyRuleAgent" );
String changesetUrl = "file:"+currentWorkingDirectory+"/framework/drools/config/changeset.xml";
kagent.applyChangeSet( ResourceFactory.newUrlResource( changesetUrl ) );
Using this 'kagent' I have created knowledge base like dis :
if(kbase==null){
kbase = kagent.getKnowledgeBase();
}
When kagent.applychaneset line executes, it throws following error :
[Error: Failed to compile: 4 compilation error(s):
- (1,9) unqualified type in strict mode for: amtEntity
- (1,9) unqualified type in strict mode for: amtEntity
- (1,15) unqualified type in strict mode for: basic
- (1,40) unable to resolve method using strict-mode: java.lang.Object.setHra(java.lang.Object)]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:78)
at org.drools.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:365)
at org.drools.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:288)
at org.drools.base.mvel.MVELConsequence.compile(MVELConsequence.java:49)
at org.drools.rule.builder.dialect.mvel.MVELConsequenceBuilder.build(MVELConsequenceBuilder.java:107)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1168)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:654)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:291)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:489)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:387)
at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:121)
at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:110)
at org.ofbiz.drools.event.drool.RuleIntegrate.createKnowledgeBase(RuleIntegrate.java:46)
at org.ofbiz.drools.event.drool.RuleIntegrate.createWorkingMemory(RuleIntegrate.java:29)
at org.ofbiz.payroll.DroolsRule.callRuleJava(DroolsRule.java:42)
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 org.ofbiz.service.engine.StandardJavaEngine.serviceInvoker(StandardJavaEngine.java:100)
at org.ofbiz.service.engine.StandardJavaEngine.runSync(StandardJavaEngine.java:57)
at org.ofbiz.service.ModelServiceReader$GenericInvokerImpl.runSync(ModelServiceReader.java:761)
at _$gen.file_58$.D_58$.Swapnil_95$Data.ofbiz_95$trunk_95$06_95$22.applications.payroll.servicedef.services_46$xml_3
at org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:399)
at org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:226)
at org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:165)
at org.ofbiz.webapp.event.ServiceEventHandler.invoke(ServiceEventHandler.java:336)
at org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:633)
at org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:379)
at org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224)
at org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:271)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
[2010:08:233 16:08:734:debug] KnowledgeAgent building resource=[UrlResource path='https://ofbiz.apache.org:8443/drools-guvno
[2010:08:233 16:08:359:debug] KnowledgeAgent has KnowledgeBuilder errors object=Unable to resolve ObjectType 'AmountPojo' :
Unable to resolve ObjectType 'AmountPojo' : [Rule name='HRA rule']
Unable to build expression for 'consequence': Failed to compile: 4 compilation error(s):
- (1,9) unqualified type in strict mode for: amtEntity
- (1,9) unqualified type in strict mode for: amtEntity
- (1,15) unqualified type in strict mode for: basic
- (1,40) unable to resolve method using strict-mode: java.lang.Object.setHra(java.lang.Object) ' amtEntity.setHra( am
' : [Rule name='HRA rule']
Error importing : 'com.sample.AmountPojo'Error importing : 'com.sample.PFRules'Error importing : 'com.sample.SpreadsheetComp
Test/Rule_PF_Rules_11_0.java (2:22) : Only a type can be imported. com.sample.SpreadsheetCompiler resolves to a pack
Test/Rule_PF_Rules_11_0.java (2:60) : Only a type can be imported. com.sample.AmountPojo resolves to a package
Test/Rule_PF_Rules_11_0.java (2:89) : Only a type can be imported. com.sample.PFRules resolves to a package
Test/Rule_PF_Rules_11_0.java (7:371) : a cannot be resolved
Test/Rule_PF_Rules_11_0.java (7:379) : a cannot be resolved
Test/Rule_PF_Rules_11_0.java (8:460) : a cannot be resolved
It seems that it is not able to recognize 'AmountPojo' class.thereby considering it as 'Object' type and applying setHra() on it.
Any idea why this is occuring ? How to communicate about 'AmountPojo' Type in code ?
Also,
After this, I wanted to know the steps for 'inserting fact type object for AmountPojo' in the session created.
For this I read in docs that use following lines of code :
// Retrieve the generated fact type
FactType cheeseFact = ruleBase.getFactType( "org.drools.generatedbeans.Cheese" );
// Create a new Fact instance
Object cheese = cheeseFact.newInstance();
cheeseFact.set( cheese,
"type",
"stilton" );
But, I didnt find any method like KnowledgeBase.getFactType(String fullyQualifiedfactTypePath) . There is only one KnowledgeBase.getFactType(String pckname,String factTypeName) method in it
Please let me the know the right way of achieving this .
Thanks,
Swapnil Sawant
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
14 years, 3 months
Migration from drools 5.0 to 5.1
by Swapnil Sawant
Hi,
Using drools 5.0 APIs, I have written a kind of framework component code using which I am able to achieve following functionalities successfully :
- Running rules using changeset.xml
- Executing workflow
Example of framework component code can be :
- Creating knowledge agent
- Applying changeset to it
- Building knowledge base out of that agent
- Creating stateful knowledge session
- Inserting fact types into this session , fire rules and get result
Now that 5.1 stable version has been released, I want to know if I just replace the 5.0 jars with 5.1 jars in my framework code, would I be able to achieve same results as they were when I was using 5.0 API ?
Or there is/are some change/s in the APIs ?
Thanks & Regards,
Swapnil Sawant
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
14 years, 3 months