Need Sample Java Code
by ashok kumar
Hi Team,
I need sample java code that on Drools v5.0.. can anyone share the rule XML
file format along with the sample code
that fires the rules defined in XML? Do i need to save the file with
'.xml' extension or it will be XML data in .drl file?
Please throw some light on this..
Thanks,
JFly.
14 years, 6 months
expert: usage of ruleflow-groups
by Miguel Machado
Hi there,
I'm having some trouble implementing the desired workflow of rule firing in an application using drools expert. I've read the thread about the difference between ruleflow groups and agenda groups, but it is still unclear to me how to achieve what i need.
What i intend to have is the ability to fire a specific set of rules according to the object i'm inserting into the ksession.
I do not want to use agenda-groups because it stacks all the agenda groups declared on the rule file (as far as i understand) and therefore it may fire activations i do not want to be fired. Instead, i want to isolate them completely. I tried using ruleflow groups for this, but i cannot find a way to activate a specific group programmatically, before calling fireAllRules(), the way i can with agenda-groups (setFocus() method).
That being said, i'm asking for help in trying to use either one of ruleflow/agenda groups or even both in order to get things working the way i described.
Thanks in advance,
_ miguel
14 years, 6 months
Can NOT map variable to "User Task" in BPMN2
by nanic23
Hi All,
1. I have the following BPMN2 flow.
http://n3.nabble.com/file/n780238/flow.jpg
2. With a String type flow variable called "firstName".
http://n3.nabble.com/file/n780238/props.jpg
3. "Work Handler" has a WorkItemHandler behind it that just prints out the
value of "firstName". Variable "firstName" is mapped in "Parameter Mapping".
4. "User Task" is a Human Task node with just a regular WorkItemHandler
behind it that as well just prints out the value of "firstName". There is NO
Mina Server involvement, just a common WorkItemHandler. Variable "firstName"
is mapped in "Parameter Mapping".
5. "Finished Script" just access "firstName" directly.
Results:
1. "Work Handler" executes just fine and prints the value of "firstName".
2. "Finished Script" executes just fine and prints the value of "firstName".
3. "User Task" can NOT find "firstName" and shows the following error:
http://n3.nabble.com/file/n780238/error1.jpg
Comments:
1. I don't believe it is a mapping problem as I have declared the variable
at the flow level and mapped it accordingly to each node. Is not a typo
error either as I checked that like more than 100 times :)
2. I have the same example in a Ruleflow (.rf) instead of BPMN2 (.bpmn) and
it works just fine.
Questions:
1. Is there any difference in mapping in variables to a "User Task" node in
BPMN2 vs Ruleflow? Specially when not using the Mina Server and just
registering a regular WorkItemHandler?
2. Do I have to declare any kind of "scope" for the variable? "Work Handler"
doesn't seem to have any problems and doesn't complain about "scope".
3. Any other ideas why the WorkItemHandler behind "User Task" cannot find
"firstName"?
I appreciate any comments or ideas.
Thanks,
Nick.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Can-NOT-map-variable-...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Error running Drools example : org.drools.WorkingMemory not found
by devyani.sapre@wipro.com
Hi
I am new to Drools (using version 4.0.7). I download eclipse workbench
and am trying to run the default example in it. But I get the following
error
java.lang.NoClassDefFoundError: org/drools/WorkingMemory
When I looked at the drools-core jar; It seems to be missing
WorkingMemory package. What should I do?
Using eclipse version 3.4.0.
Thanks
Devyani
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
14 years, 6 months
FIXED: Changing Guvnor PresistantManager to MSSQL
by eyal edri
OK,
after changing the default workspace.xml file PersistantManager to also
MSSQL settings,
things look a lot better... (created another tables on Drools db).
thanks :)
Eyal.
On Wed, May 5, 2010 at 2:52 PM, eyal edri <eyal.edri(a)gmail.com> wrote:
> Getting there..
>
> I've manged to make drools find the jdbc.jar and even start successfully!!
> :)
> so it auto-created some VERSION_x tables in the Drools DB.
>
> the conf i'm using is: (diff driver + url)
>
> <PersistenceManager
> class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
> <param name="driver" value="
> com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
> <param name="url" value="
> jdbc:sqlserver://my-sql:1433;databaseName=Drools;"/>
> <param name="schema" value="mssql"/>
> <param name="user" value="sa"/>
> <param name="password" value="xxx"/>
> <param name="schemaObjectPrefix" value="${wsp.name}_"/>
> <param name="externalBLOBs" value="false"/>
> </PersistenceManager>
>
>
> now, when i tell him to create a new sample project it fails with:
>
> 14:39:45,497 INFO [STDOUT] ERROR 05-05 14:39:45,496
> (RulesRepositoryAdministrator.java:clearRulesRepository:79)
> javax.jcr.RepositoryException: /: unable to update item.:
> 17528b92-d60d-48cf-82dd-7c9654effe34: 17528b92-d60d-48cf-82dd-7c9654effe34
> 14:39:54,217 INFO [STDOUT] ERROR 05-05 14:39:54,216
> (RepositoryServiceServlet.java:doUnexpectedFailure:62)
> org.drools.repository.RulesRepositoryException:
> javax.jcr.InvalidItemStateException: /: the item cannot be saved because it
> has been modified externally.
>
> ideas?
>
>
> On Wed, May 5, 2010 at 2:32 PM, eyal edri <eyal.edri(a)gmail.com> wrote:
>
>> OK,
>>
>> some progress,
>>
>> i found out that the versioning section was casuing the problem, so i
>> changed
>> <param name="schemaObjectPrefix" value="${wsp.name}_"/>
>> to <param name="schemaObjectPrefix" value="version_"/>
>>
>> now i get an exception about not finding the jdbc driver.
>>
>> Caused by: java.lang.ClassNotFoundException:
>> com.microsoft.jdbc.sqlserver.SQLServerDriver
>>
>> i put sql-jdbc.2.0.jar which i use in all my java apps in the class path
>> (/usr/lib and also in the lib dir of the jboss server). with no luck.
>>
>> is there another jar i should use for this driver?
>>
>> attached is the new stacktrace..
>>
>> thanks,
>>
>> Eyal.
>>
>> On Wed, May 5, 2010 at 2:08 PM, eyal edri <eyal.edri(a)gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm a drools newbie, and i'm trying to connect GUVNOR to MSSQL.
>>> I've followed the guide and changed repository.xml as follows (the rest i
>>> left unchanged from the default repository.xml):
>>>
>>> <Workspace name="${wsp.name}">
>>> <FileSystem
>>> class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
>>> <param name="path" value="${wsp.home}"/>
>>> <PersistenceManager
>>> class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
>>> <param name="driver"
>>> value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
>>> <param name="url"
>>> value="jdbc:microsoft:sqlserver://my-sql:1433;;DatabaseName=Drools;SelectMethod=Cursor;"/>
>>> <param name="schema" value="mssql"/>
>>> <param name="user" value="sa"/>
>>> <param name="password" value="xxx"/>
>>> <param name="schemaObjectPrefix" value="${wsp.name}_"/>
>>> <param name="externalBLOBs" value="false"/>
>>> </PersistenceManager>
>>> ....
>>>
>>> </Workspace>
>>>
>>> and versioning also:
>>>
>>> <Versioning rootPath="${rep.home}/version">
>>>
>>> <PersistenceManager
>>> class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
>>> <param name="driver"
>>> value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
>>> <param name="url"
>>> value="jdbc:microsoft:sqlserver://my-sql:1433;;DatabaseName=Drools;SelectMethod=Cursor;"/>
>>> <param name="schema" value="mssql"/>
>>> <param name="user" value="sa"/>
>>> <param name="password" value="xxx"/>
>>> <param name="schemaObjectPrefix" value="${wsp.name}_"/>
>>> <param name="externalBLOBs" value="false"/>
>>> </PersistenceManager>
>>> </Versioning>
>>>
>>>
>>>
>>> - i'm running a standalone GUVNOR package.
>>> - i created an empty Drools db in my server: my-sql
>>> - I deleted all the repository dir content
>>> - i'm getting a few exceptions:
>>>
>>> ERROR [[/drools-guvnor]] Exception sending context initialized event to
>>> listener instance of class org.jboss.seam.servlet.SeamListener
>>> org.jboss.seam.InstantiationException: Could not instantiate Seam
>>> component: repositoryConfiguration
>>>
>>> (attached is the full stacktrace)
>>>
>>> can anyone help?
>>>
>>>
>>> --
>>> Eyal Edri
>>>
>>
>>
>>
>> --
>> Eyal Edri
>>
>
>
>
> --
> Eyal Edri
>
--
Eyal Edri
14 years, 6 months
Changing Guvnor PresistantManager to MSSQL
by eyal edri
Hi,
I'm a drools newbie, and i'm trying to connect GUVNOR to MSSQL.
I've followed the guide and changed repository.xml as follows (the rest i
left unchanged from the default repository.xml):
<Workspace name="${wsp.name}">
<FileSystem
class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}"/>
<PersistenceManager
class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
<param name="driver"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<param name="url"
value="jdbc:microsoft:sqlserver://my-sql:1433;;DatabaseName=Drools;SelectMethod=Cursor;"/>
<param name="schema" value="mssql"/>
<param name="user" value="sa"/>
<param name="password" value="xxx"/>
<param name="schemaObjectPrefix" value="${wsp.name}_"/>
<param name="externalBLOBs" value="false"/>
</PersistenceManager>
....
</Workspace>
and versioning also:
<Versioning rootPath="${rep.home}/version">
<PersistenceManager
class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
<param name="driver"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<param name="url"
value="jdbc:microsoft:sqlserver://my-sql:1433;;DatabaseName=Drools;SelectMethod=Cursor;"/>
<param name="schema" value="mssql"/>
<param name="user" value="sa"/>
<param name="password" value="xxx"/>
<param name="schemaObjectPrefix" value="${wsp.name}_"/>
<param name="externalBLOBs" value="false"/>
</PersistenceManager>
</Versioning>
- i'm running a standalone GUVNOR package.
- i created an empty Drools db in my server: my-sql
- I deleted all the repository dir content
- i'm getting a few exceptions:
ERROR [[/drools-guvnor]] Exception sending context initialized event to
listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component:
repositoryConfiguration
(attached is the full stacktrace)
can anyone help?
--
Eyal Edri
14 years, 6 months
Getting an Error While Executing Rule in Drools 5.0
by Nikhil S. Kulkarni
Hi,
I have compiled some rules and added it in packages. Then I serialized those packages and stored in database in the form of CLOB data
Now I am able to get Packages back from database and loaded it in RuleBase.
But while executing Rule, I am getting the following Exception.
java.lang.NullPointerException
at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:91)
at org.drools.base.evaluators.EqualityEvaluatorsDefinition$StringEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1962)
at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:92)
at org.drools.rule.OrCompositeRestriction.isAllowed(OrCompositeRestriction.java:25)
at org.drools.rule.MultiRestrictionFieldConstraint.isAllowed(MultiRestrictionFieldConstraint.java:97)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:201)
The similar kind of issue is already logged by someone.
Please inform If anyone has an idea about this.
Waiting for Reply.
Thanks & Regards,
Nikhil S. Kulkarni
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 years, 6 months
Re: [rules-users] How to make this rule more memory efficient?
by Greg Barton
It can handle it. The limiting factor is available heap.
GreG
On May 4, 2010, at 10:55, Ryan Fitzgerald <ryan.fitzgerald(a)ericsson.com> wrote:
Hi Thomas,
You are correct in your interpretation of what I want to do.
I did consider adding the mappings as their own facts but I was concerned that the sheer number of them would overload drools. For each Cell instance, it can refer to up to 60 ProxyCell instances. With 20,000 Cell instances (in my proto-type), that means 1.2 million mappings.
Can drools handle these kinds of numbers of facts?
Thanks,
Ryan.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Swindells, Thomas
Sent: 28 April 2010 10:17
To: Rules Users List
Subject: Re: [rules-users] How to make this rule more memory efficient?
If I understand the following
What I want to do is find out where I have a reference from any
instance of Cell - cell1 - to any instance of ProxyCell - proxycell2 -
but am missing a reference from cell2 to proxycell1 where proxycell2
is a representation of
cell2 and proxycell1 is a representation of cell1.
What I think you saying is that if
C1 -> P2 then there must be a C2 -> P1
Where C2 == P2.cellId and P1 == C1.cellId.
I've not worked this through properly (It's still too early in the working day) but do you may make a win by inserting the mappings into working memory as their own facts (and so trading memory for processing time). You can then reason over these relationships which should reduce the number of combinations that are made.
So have a rules like the following:
Rule "createRelationship" salience [high]
$cell1 : Cell()
$proxy2 : Proxy($cell1.relationships contains this.name) then insert new Relationship($cell1.id, $proxy2.id); end
Rule "check inverse" salience [low]
$relationship : Relationship()
$cell1 : Cell(id == $relationship.cellId)
$proxy2 : Proxy(id == $relationship.proxyId) not exist Relationship(cellId == $relationship.proxyId, proxyId == relationship.cellId) then //raise warning or whatever end
Hopefully this does what you wants and should be more efficient processing wise and activation count wise.
Thomas
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
bounces(a)lists.jboss.org] On Behalf Of Ryan Fitzgerald
Sent: 28 April 2010 09:46
To: Rules Users List
Subject: Re: [rules-users] How to make this rule more memory efficient?
Thanks Wolfgang.
Should I conclude therefore that high memory usage is unavoidable due
to the number of facts that must be processed? I was hoping that there
might be a clever way of writing the rules so that the rules engine
can minimise the network it generates - even if it takes a little longer to execute.
All of the facts are read from a database and thus loaded into working memory.
My fallback position is to not load all these objects into working
memory but instead embed into a rule, a service call that queries the
db for all inconsistencies (effectively using SQL instead of a drools
rule). However, since I will have other rules that operate on these
objects in working memory, I was hoping to use these facts for all rules.
/Ryan.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
bounces(a)lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 27 April 2010 14:59
To: Rules Users List
Subject: Re: [rules-users] How to make this rule more memory efficient?
If there are n Cell facts,
$cell1 : Cell()
$cell2 : Cell()
needs to create n*n pairs in the network before any reduction may set in.
Using
$cell2 : Cell(this != $cell1)
reduces this by n, so we're still quadratic. Something like
$cell1 : Cell( $id1 : id )
$cell2 : Cell( id > $id1 )
reduces it to n*(n-1)/2 which is less than 50% of the original, but
still quadratic.
-W
2010/4/26 Swindells, Thomas <TSwindells(a)nds.com>:
You should probably restrict it so that
$cell2 : Cell(this != $cell1)
Thomas
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Ryan
Fitzgerald
Sent: 26 April 2010 15:34
To: rules-users(a)lists.jboss.org
Subject: [rules-users] How to make this rule more memory efficient?
Hi,
Can anyone advise me on how to make a drools rule more memory efficient?
Here is the problem:
I have a Cell and a ProxyCell object classes.
The ProxyCell represents the Cell when their internal ID's match.
Each Cell and ProxyCell however has a unique name (not same as ID).
A Cell can reference (by name) a ProxyCell (as long as the ProxyCell
does not represent that actual Cell - which would effectively be a
self-reference and is not allowed).
What I want to do is find out where I have a reference from any
instance of Cell - cell1 - to any instance of ProxyCell - proxycell2
- but am missing a reference from cell2 to proxycell1 where
proxycell2 is a representation of
cell2 and proxycell1 is a representation of cell1.
Here is the rule I have written for it:
rule "Check consistent references"
when
$cell1 : Cell()
$cell2 : Cell()
$proxycell1 : ProxyCell ( id = $cell1.id, $cell2.references
contains this.name )
$proxycell2 : ProxyCell ( id = $cell2.id, $cell1.references
not contains this.name )
then
//report an error.....
end
I have 10,000 instances of Cell and 10,000 instances of ProxyCell in
working memory. For each instance of Cell, it can have references to
60 different ProxyCell instances. Loading the Cell and ProxyCell
instances into working memory is not a problem. However, when I try
to run this rule above, the memory quickly goes above 1GB and I
eventually get
an out of memory error.
I was wondering if there is a better way to structure or write this
rule so that it doesn't use so much memory.
Thanks,
Ryan.
________________________________
********************************************************************
**
**************** This message is confidential and intended only for
the addressee. If you have received this message in error, please
immediately notify the postmaster(a)nds.com and delete it from your
system as well as any copies. The content of e-mails as well as
traffic data may be monitored by NDS for employment and security
purposes. To protect the environment please do not print this e-mail
unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex,
TW18 4EX, United Kingdom. A company registered in England and Wales.
Registered no. 3080780. VAT no. GB 603 8808 40-00
********************************************************************
**
****************
________________________________
This message is confidential and intended only for the addressee. If
you have received this message in error, please immediately notify
the postmaster(a)nds.com and delete it from your system as well as any
copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company. www.nds.com
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company. www.nds.com
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 6 months
Drools + ETL Process
by andre.fonseca@mail.com
Hi all,
I am using Drools 5.0 with Tomcat 6 and MySQL.
Now I need to insert data in the drools database but I DON'T want to use the Guvnor interface.
This is because in the future we'll need to use a kind of ETL process to populate the drools database.
Should I create a java class with JDBC access and perform a SQL direct to that tables?
I did the reverse engineering of the drools database but I could not understood yet where the data are persisted.
Any advice should be very helpful.
Thanks in advance.
14 years, 6 months
Human Task with a graphical representation
by rudolf michael
Hello there,
I was able to draw an "Incident on Workstation Process" using Drools flow
and i am going to test it today.
I have a Timer on every Human task where i need to log an OLA Exception when
the timer is due. this is easy but what is missing a graphical
representation for this.
is there a way to show/draw this information in my eclipse flow plung in so
for the business analyst to see it?
best regards,
Rudolf Michael
14 years, 6 months