[rules-users] Exception in thread main java.lang.ClassCastException:

2012-03-19 Thread srinivasasanda

Hi One and All,


I used resource scanner in my program to update changes automatically.
Every thing works fine.
I had one method Method1 to create knowledge base.

I had another method Method2 :
 with an infinite loop where i had a set of facts insert into in
command list, and ksession.execute. 
   
Now i tested the application whether the changes are applying or not :
After adding or modifying rule ,I validate and build package. 

Now from infinite loop i got an error at line
ksession.execute(CommandFactory.newBatchExecution(cmds));

Exception in thread main java.lang.ClassCastException:
pricing.specification cannot be cast to pricing.specification
at
org.drools.base.pricing.specification26362458$getSmsusage.getValue(Unknown
Source)
at
org.drools.base.extractors.BaseObjectClassFieldReader.isNullValue(BaseObjectClassFieldReader.java:179)
at 
org.drools.base.ClassFieldReader.isNullValue(ClassFieldReader.java:179)
at
org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:606)
at
org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.init(CompositeObjectSinkAdapter.java:568)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:362)
at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at 
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
at
org.drools.command.runtime.rule.InsertObjectCommand.execute(InsertObjectCommand.java:84)
at
org.drools.command.runtime.rule.InsertObjectCommand.execute(InsertObjectCommand.java:38)
at
org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
at
org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:264)
at
net.treetechnologies.bss.ruleengine.PricingRules.evaluatePriceRules(PricingRules.java:159)
at net.treetechnologies.bss.ruleengine.RunRule.price(RunRule.java:184)
at net.treetechnologies.bss.ruleengine.RunRule.main(RunRule.java:50)


Thanks and regards
Srinivasa sanda

--
View this message in context: 
http://drools.46999.n3.nabble.com/Exception-in-thread-main-java-lang-ClassCastException-tp3838503p3838503.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Exception in thread main java.lang.ClassCastException:

2012-03-19 Thread Esteban Aliverti
This is a known bug. We are trying to solve it:
https://issues.jboss.org/browse/JBRULES-2962

Best Regards,



Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Mon, Mar 19, 2012 at 9:52 AM, srinivasasanda srinivasasa...@gmail.comwrote:


 Hi One and All,


 I used resource scanner in my program to update changes automatically.
 Every thing works fine.
 I had one method Method1 to create knowledge base.

 I had another method Method2 :
 with an infinite loop where i had a set of facts insert into in
 command list, and ksession.execute.

 Now i tested the application whether the changes are applying or not :
 After adding or modifying rule ,I validate and build package.

 Now from infinite loop i got an error at line
 ksession.execute(CommandFactory.newBatchExecution(cmds));

 Exception in thread main java.lang.ClassCastException:
 pricing.specification cannot be cast to pricing.specification
at
 org.drools.base.pricing.specification26362458$getSmsusage.getValue(Unknown
 Source)
at

 org.drools.base.extractors.BaseObjectClassFieldReader.isNullValue(BaseObjectClassFieldReader.java:179)
at
 org.drools.base.ClassFieldReader.isNullValue(ClassFieldReader.java:179)
at

 org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeObjectSinkAdapter.java:606)
at

 org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.init(CompositeObjectSinkAdapter.java:568)
at

 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:362)
at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at

 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at

 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at

 org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
at

 org.drools.command.runtime.rule.InsertObjectCommand.execute(InsertObjectCommand.java:84)
at

 org.drools.command.runtime.rule.InsertObjectCommand.execute(InsertObjectCommand.java:38)
at

 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
at

 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
at

 org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:264)
at

 net.treetechnologies.bss.ruleengine.PricingRules.evaluatePriceRules(PricingRules.java:159)
at
 net.treetechnologies.bss.ruleengine.RunRule.price(RunRule.java:184)
at net.treetechnologies.bss.ruleengine.RunRule.main(RunRule.java:50)


 Thanks and regards
 Srinivasa sanda

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Exception-in-thread-main-java-lang-ClassCastException-tp3838503p3838503.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] rules-users Digest

2012-03-19 Thread Kumar, Ravendra
Hello All,

I am frustrated with error: 'Unable to load dialect 
'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration'
  xxx.drl 

This is generated by eclipse drools plugin in problem view as a error, it would 
be helpful if someone help me out. I am using following artifacts

1. eclipse ide: Indigo(3.7)
2. eclipse drools plugin: 5.2.final
4. drools runtime 5.2.final (generated in eclipse)
Thanks,
Ravi


-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of 
rules-users-requ...@lists.jboss.org
Sent: 08 March 2012 11:08 AM
To: rules-users@lists.jboss.org
Subject: rules-users Digest, Vol 64, Issue 21

Send rules-users mailing list submissions to
rules-users@lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
rules-users-requ...@lists.jboss.org

You can reach the person managing the list at
rules-users-ow...@lists.jboss.org

When replying, please edit your Subject line so it is more specific than Re: 
Contents of rules-users digest...


Today's Topics:

   1. how to invoke java method with variable arguments from drl
  file (womuji)
   2. Re: how to invoke java method with variable arguments from
  drl file (Matteo Cusmai)
   3. Simple question about String comparison in Drool (shawn)
   4. Re: Simple question about String comparison in Drool
  (Mauricio Salatino)
   5. Re: Simple question about String comparison in Drool (shawn)
   6. Persistence in fireUntilHalt() loop (Alberto R. Galdo)
   7. Re: how to invoke java method with variable arguments from
  drl file (Wolfgang Laun)


--

Message: 1
Date: Wed, 7 Mar 2012 09:09:49 -0800 (PST)
From: womuji cmregis...@gmail.com
Subject: [rules-users] how to invoke java method with variable
arguments   from drl file
To: rules-users@lists.jboss.org
Message-ID: 1331140189049-3807314.p...@n3.nabble.com
Content-Type: text/plain; charset=us-ascii

We are upgrading Drools from 5.1 to 5.3, and running into some issue when 
invoking a Java method with String variable arguments:

methodA(String... params)

how do we invoke this in a drl file? We used to call it in 5.1 as:

objA.methodA({string1});

and it works fine. Now in 5.3, it complains that 

unable to resolve method using strict-mode:
objA.methodA([Ljava.lang.Object;)]

If we tried objA.methodA(new String[]{string1}); it complains that unable to 
resolve method using strict-mode:
objA.methodA([Ljava.lang.String;)]

It passes the rule loading if we change to :

objA.methodA(string1);

but when actually running the rule, we are getting error saying  unable to 
resolve method methodA(java.lang.String)


--
View this message in context: 
http://drools.46999.n3.nabble.com/how-to-invoke-java-method-with-variable-arguments-from-drl-file-tp3807314p3807314.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


--

Message: 2
Date: Wed, 7 Mar 2012 21:41:56 +0100
From: Matteo Cusmai cusmaimat...@gmail.com
Subject: Re: [rules-users] how to invoke java method with variable
arguments from drl file
To: Rules Users List rules-users@lists.jboss.org
Message-ID:
CABd_zP_kqpoRUCaDvWLcXr7Q-4uQ9JrOdyH82wGy3=gvpio...@mail.gmail.com
Content-Type: text/plain; charset=iso-8859-1

From my experience, if you want call a method from then clause, it has 
to
be static method.
Bye bye,

Matteo Cusmai
Il giorno 07/mar/2012 18:10, womuji cmregis...@gmail.com ha scritto:

 We are upgrading Drools from 5.1 to 5.3, and running into some issue 
 when invoking a Java method with String variable arguments:

 methodA(String... params)

 how do we invoke this in a drl file? We used to call it in 5.1 as:

 objA.methodA({string1});

 and it works fine. Now in 5.3, it complains that

 unable to resolve method using strict-mode:
 objA.methodA([Ljava.lang.Object;)]

 If we tried objA.methodA(new String[]{string1}); it complains that 
 unable to resolve method using strict-mode:
 objA.methodA([Ljava.lang.String;)]

 It passes the rule loading if we change to :

 objA.methodA(string1);

 but when actually running the rule, we are getting error saying  
 unable to resolve method methodA(java.lang.String)


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/how-to-invoke-java-method-with-varia
 ble-arguments-from-drl-file-tp3807314p3807314.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

-- next part --
An HTML attachment was scrubbed...
URL: 

[rules-users] checking string property for key-words

2012-03-19 Thread Frank Langelage
Hello,

I'm working on module checking and processing incoming mails.
I'd like to use drools expert to check the mails and determine the 
target folder for the further processing.

So one of the first things is to check the subject of mail for keywords.
I'm using decision tables.

The first shot was to use regular expressions for this.
CONDITION   ACTION
javax.mail.Message
subject matches $1insert(new String($1));
.* [Ss]pam .*   Spam
.* Order .* Orders/inbox
.* Activity .*  Workflow/inbox

This works so far, but I'm not totally happy with this regular expressions.
I'd prefer to see only the key-word in the cells.

CONDITION   ACTION
javax.mail.Message
??? insert(new String($1));
spamSpam
SpamSpam
Order   Orders/inbox
ActivityWorkflow/inbox

But what to fill in for the ? ?

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] checking string property for key-words

2012-03-19 Thread Wolfgang Laun
Have you tried
subject matches .*$1.*

(A more sophisticated regex seems to be indicated, though.)

HTH
-W


On 19/03/2012, Frank Langelage fr...@lafr.de wrote:
 Hello,

 I'm working on module checking and processing incoming mails.
 I'd like to use drools expert to check the mails and determine the
 target folder for the further processing.

 So one of the first things is to check the subject of mail for keywords.
 I'm using decision tables.

 The first shot was to use regular expressions for this.
 CONDITION ACTION
 javax.mail.Message
 subject matches $1  insert(new String($1));
 .* [Ss]pam .* Spam
 .* Order .*   Orders/inbox
 .* Activity .*Workflow/inbox

 This works so far, but I'm not totally happy with this regular expressions.
 I'd prefer to see only the key-word in the cells.

 CONDITION ACTION
 javax.mail.Message
 ???   insert(new String($1));
 spam  Spam
 Spam  Spam
 Order Orders/inbox
 Activity  Workflow/inbox

 But what to fill in for the ? ?

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Doubt when modifying facts on an action

2012-03-19 Thread Zeta
Hi manstis,

finally i made as you suggested me. It works. Maybe it is not the most
elegant solution if you want a business man to update the excel file but
well... I was not able to find a better workaround.

Thanks so much!

Z.-

--
View this message in context: 
http://drools.46999.n3.nabble.com/Doubt-when-modifying-facts-on-an-action-tp3831681p3839633.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Persistence in fireUntilHalt() loop

2012-03-19 Thread Alberto R. Galdo
I'm afraid this bug is not resolved and doesn't have nothing to do with
lazy evaluation.

We've been able to get to the source of the problem and this are the facts:

   - Drools and JBPM have different persistence managers.
   - Drools uses JTA for persistence and JBPM does not.
   - When any JPA enabled object is persisted in Drools, a transaction
begins, it's EntityManager ( Hibernate ) joins the transaction and the
entity gets persisted.
   - When any JPA enabled object ( in this case a ProcessInstanceInfo ) is
persisted in JBPM, there are no transactions involved, and so the
EntityManager ( Hibernate ) decides to delay the insert ( queuing it as
there's no transaction in progress ). Then the processId never gets updated
and the NPE arises.

The problem here seems to be that both Drools and JBPM manage persistence
in different and incompatible ways. We've been able to modify
jbpm-persistence-jpa to open a JTA transaction before persisting
ProcessInstanceInfo, getting the EntityManager joining that transaction and
using the current Bitronix implementation already running in Drools ( to
assist persistence for their objects ) .. like so:

public void setKnowledgeRuntime(InternalKnowledgeRuntime kruntime) {
this.kruntime = kruntime;
Environment env = kruntime.getEnvironment();
Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
if (!(tm instanceof javax.transaction.TransactionManager)) {
try {
// get Bitronix instance inside ...
java.lang.reflect.Field field =
tm.getClass().getDeclaredField(tm);
// who says private in Java is really private ... xD
field.setAccessible(true);
tm = field.get(tm);
} catch (Exception e){
e.printStackTrace();
}
}
this.txm = new JtaTransactionManager( env.get(
EnvironmentName.TRANSACTION ), env.get(
EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ), tm );
}

public void addProcessInstance(ProcessInstance processInstance) {
ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(
processInstance, this.kruntime.getEnvironment() );
ProcessPersistenceContext context =
((ProcessPersistenceContextManager) this.kruntime.getEnvironment().get(
EnvironmentName.PERSISTENCE_CONTEXT_MANAGER
)).getProcessPersistenceContext();
this.txm.begin();
context.persist( processInstanceInfo );
this.txm.commit();



I think we can agree that the previous lines of code are not the most
elegant solution  ( at least not for me ).

So, Is there any timeline for merging DROOLS and JBPM 5 persistence
managers?

If someone gives me advice and architectural hints ( and if it is doable in
a reasonable ammount of time ) I would be eager to submit a patch for this



Alberto R. Galdo
arga...@gmail.com


On Wed, Mar 14, 2012 at 13:56, Alberto R. Galdo arga...@gmail.com wrote:

 Great news!

 We were in the process of debugging JBPM trying to find the source of the
 bug ... and maybe days away from the solution ...

 Is there any bug report in Jira and/or a patch we can apply without having
 to wait for the next release so we can quick-patch our systems?


 Alberto R. Galdo
 arga...@gmail.com



 On Wed, Mar 14, 2012 at 13:09, Marco Rietveld mriet...@redhat.com wrote:


 Hi Alberto,

 This is a bug that has been fixed in jBPM. It had to do with lazy
 initialization of a JPAProcessInstanceManager field.

 We'll be releasing a new jBPM version sometime soon (synchronous with
 Drools, I think). The bug is fixed in there.

 Regards,
 Marco

 03/08/2012 11:32 AM, Alberto R. Galdo:

 Hi,

We're running an application that uses Drools + JBPM 5 + Drools
 integration our set-up can be seen as:

Some rule fires and creates a JBPM process ( a fact gets inserted
 into drools using
 kcontext.getKnowledgeRuntime().startProcess(testProcess) ). We have a
 problem with the persistence of this processes. Persistence is implemented
 with JPA and JTA. Our application runs with fireUntilHalt() and when a
 process is launched from the consequence of any of the rules the
 persistence of the process fails. If the application runs with
 fireAllRules(), the persistence works like a charm.

   The error shown is as follow:

   Exception in thread Thread-5 Exception executing consequence for rule
 Run Process in com.sample: java.lang.NullPointerException
  at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
  at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
  at
 org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229)
  at
 org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:754)
  at
 

[rules-users] Metadata in Guvnor-created rules

2012-03-19 Thread Stephen Masters
Hi folks,I'm curious about what metadata should be on a rule when created in Guvnor. I was assuming that any of the metadata fields shown under the "Attributes" tab should be available as metadata items when the rule gets activated. i.e. Title, categories, Created date, etc...However, when I call event.getActivation().getRule().getMetaData() on an AfterActivationFiredEvent, the map returned is completely empty.Or is the "metadata" for a rule in Guvnor not the same thing? I was rather hoping to be able to take note of the categories of each rule that fires.fyi ... I'm using 5.3.0.Final.Thanks for any assistance you can provide.Steve
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Planner data / input file creation

2012-03-19 Thread ge0ffrey

hartnellg wrote
 
 Thanks for the suggestions for reading from Excel files.
 I've used poi previously, and it will be worth having a look at jexcelapi.
 
 As far as the text files in the input directory, it's about how best to
 create new ones.
 For example where I have different shifts, unwanted patterns etc to the
 examples input files 
 In particular getting the sequence numbers right.
 I'm doing this manually, but it is time consuming and error prone.
 How were these originally created.
 
 Thanks for reading and any help
 

the files are from the inrc competion who ectracted them manually from a
real hospital

--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-Planner-data-input-file-creation-tp3834703p3840198.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools silently fails when I screw up

2012-03-19 Thread ge0ffrey

barnesjd wrote
 
 Hi everyone.  I'm new to Drools (using 5.2).  I'm using it in Grails
 (2.0.1) with the drools-gorm plugin (0.5.6) (warning: Grails is also new
 for me).  I've noticed that whenever I do something that is perhaps
 syntactically invalid, my rules simply don't fire.  Given that I'm new to
 Drools, it would be nice if I could actually know what mistake I made.
 
 Are there some options I can use that will make Drools more vocal about my
 mistakes?
 
 Thanks!
 Joe
 
use knowledgebase.hasErrors()

--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-silently-fails-when-I-screw-up-tp3839290p3840204.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools silently fails when I screw up

2012-03-19 Thread barnesjd
Thanks!  I'll add that and see if it helps me answer some of my other
questions.

Joe


--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-silently-fails-when-I-screw-up-tp3839290p3840381.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Data comparing in CONDITION column decision table

2012-03-19 Thread Vincent LEGENDRE
Hi

Instead of using a workaround, did you have a look to rule templates ?
  - under guvnor : 
http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1143
  - drl : 
http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e7501

You should be able to do exactly what you are trying to do, but properly, like 
that :

template header
field
accno

package range;

template Discount
  rule Discount @{row.rowNumber}
  when
Account( $v : @{field} != null )
$c : Customer( @{field} == $v , accno == @{accno} )
  then
$c.setDiscount(1);
  end
end template


- Mail original -
De: Sumeet Karawal sumeet.kara...@tcs.com
À: Rules Users List rules-users@lists.jboss.org
Envoyé: Jeudi 15 Mars 2012 14:20:01
Objet: Re: [rules-users] Data comparing in CONDITION column decision table

I inserted Account column with values that are always true.

Works fine. :)

Will try the same with 5.3 .

Thanks  Regards,
Sumeet




  
  From:   Wolfgang Laun wolfgang.l...@gmail.com   
  

  
  To: Rules Users List rules-users@lists.jboss.org
  

  
  Date:   03/15/2012 05:30 PM   
  

  
  Subject:Re: [rules-users] Data comparing in CONDITION column decision 
table 

  
  Sent by:rules-users-boun...@lists.jboss.org   
  

  





The documentation for 5.3.0 says
quote
To include a pattern without constraints, you can write the pattern in
front of the text for another pattern.
/quote
but it does not work with 5.2.0 and (likely) later versions.

As a workaround, re-insert the Account column and use a redundant
condition that is certainly true for all facts.

I'll have to look into this.

-W


On 15/03/2012, Sumeet Karawal sumeet.kara...@tcs.com wrote:
 Hi Wolfgang

 any other way to achieve this. I have tried many times, but no success
till
 now :(

 Thanks,
 Sumeet




   From:   Sumeet Karawal sumeet.kara...@tcs.com


   To: Rules Users List rules-users@lists.jboss.org


   Date:   03/15/2012 04:24 PM


   Subject:Re: [rules-users] Data comparing in CONDITION column
decision
 table

   Sent by:rules-users-boun...@lists.jboss.org









 After doing the changes, its taking the rules as:

 rule Discount_10
 when
 
 $a:Account(type ==
$a.getType(), accno == 1001)
 $c:Customer
 then
 
 $c.setDiscount(1);
 end


 and if I put it as $a: Account() $c: Customer(), it takes the rules as:

 rule Discount_10
 when
 
 $a:Account(type ==
$a.getType(), accno == 1001)
 $c:Customer()
 then
 
 $c.setDiscount(1);
 end

 Both these throw error..



 neither putting the $c:Customer before $a:Account is getting executed.


 Thanks  Regards,
 Sumeet
 Mailto: sumeet.kara...@tcs.com



   From:   Wolfgang Laun wolfgang.l...@gmail.com


   To: Rules Users List rules-users@lists.jboss.org


   Date:   03/15/2012 04:06 PM


   Subject:Re: [rules-users] Data comparing in CONDITION column
decision
 table

   Sent by:rules-users-boun...@lists.jboss.org







 On 15/03/2012, Sumeet Karawal sumeet.kara...@tcs.com wrote:

 How to make changes to the decision table entries to get a drl of this
 kind:


 Put
$a: Account() $c: Customer
 into the cell where you now have $c : Customer and delete the Account
 column.
 -W


 rule Discount_10
 when

   $a : Account()

   $c : Customer(type ==
 $a.getType(), accno == 1001)
  

Re: [rules-users] Persistence in fireUntilHalt() loop

2012-03-19 Thread Marco Rietveld

  
  
Alberto, 

Sorry to hear that the bug isn't fixed. 

Could you clarify what you mean by these points? 
 - Drools and JBPM have different persistence managers.
 - Drools uses JTA for persistence and JBPM does not.

I was pretty sure you could specify a JTA data source in the
persistence.xml that jBPM uses. 

As for the persistence managers, what do you mean exactly? 

Also, if you could maybe give me a github link referring to the code
you're using, that would be great. 

(Just to make sure, you are referring to jbpm 5, right?)

Thanks,
Marco


03/19/2012 06:23 PM, Alberto R. Galdo:
I'm afraid this bug is not resolved and doesn't have
  nothing to do with lazy evaluation.
  
  We've been able to get to the source of the problem and this are
  the facts:
  
   - Drools and JBPM have different persistence managers.
   - Drools uses JTA for persistence and JBPM does not.
   - When any JPA enabled object is persisted in Drools, a
  transaction begins, it's EntityManager ( Hibernate ) joins the
  transaction and the entity gets persisted. 
   - When any JPA enabled object ( in this case a
  ProcessInstanceInfo ) is persisted in JBPM, there are no
  transactions involved, and so the EntityManager ( Hibernate )
  decides to delay the insert ( queuing it as there's no transaction
  in progress ). Then the processId never gets updated and the NPE
  arises.
  
  The problem here seems to be that both Drools and JBPM manage
  persistence in different and incompatible ways. We've been able to
  modify jbpm-persistence-jpa to open a JTA transaction before
  persisting ProcessInstanceInfo, getting the EntityManager joining
  that transaction and using the current Bitronix implementation
  already running in Drools ( to assist persistence for their
  objects ) .. like so:
  
   public void setKnowledgeRuntime(InternalKnowledgeRuntime
  kruntime) {
   this.kruntime = kruntime;
   Environment env = kruntime.getEnvironment();
   Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER
  );
   if (!(tm instanceof javax.transaction.TransactionManager))
  {
try {
//  get Bitronix instance inside ...
 java.lang.reflect.Field field =
  tm.getClass().getDeclaredField("tm");
   // who says private in Java is really private ...
  xD
 field.setAccessible(true);
 tm = field.get(tm);
} catch (Exception e){
 e.printStackTrace();
}
   }
   this.txm = new JtaTransactionManager( env.get(
  EnvironmentName.TRANSACTION ), env.get(
  EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ), tm );
   }
  
   public void addProcessInstance(ProcessInstance
  processInstance) {
   ProcessInstanceInfo processInstanceInfo = new
  ProcessInstanceInfo( processInstance,
  this.kruntime.getEnvironment() );
   ProcessPersistenceContext context =
  ((ProcessPersistenceContextManager)
  this.kruntime.getEnvironment().get(
  EnvironmentName.PERSISTENCE_CONTEXT_MANAGER
  )).getProcessPersistenceContext();
   this.txm.begin();
   context.persist( processInstanceInfo );
   this.txm.commit();
  
  
  
  I think we can agree that the previous lines of code are not the
  most elegant solution ( at least not for me ).
  
  So, Is there any timeline for merging DROOLS and JBPM 5
  persistence managers? 
  
  If someone gives me advice and architectural hints ( and if it is
  doable in a reasonable ammount of time ) I would be eager to
  submit a patch for this 
  
  
  Alberto R. Galdo
  arga...@gmail.com
  
  
  On Wed, Mar 14, 2012 at 13:56, Alberto R.
Galdo arga...@gmail.com
wrote:
Great news!
  
  We were in the process of debugging JBPM trying to find the
  source of the bug ... and maybe days away from the solution
  ...
  
  Is there any bug report in Jira and/or a patch we can apply
  without having to wait for the next release so we can
  quick-patch our systems?
  
  
  Alberto R. Galdo
  arga...@gmail.com
  

  
  
  On Wed, Mar 14, 2012 at 13:09,
Marco Rietveld mriet...@redhat.com
wrote:

   
Hi Alberto, 

This is a bug that has been fixed in jBPM. It had to
do with lazy initialization of a JPAProcessInstanceManager
field. 

We'll be releasing a new jBPM version sometime soon

Re: [rules-users] Persistence in fireUntilHalt() loop

2012-03-19 Thread Marco Rietveld

  
  
Sorry, to be clear: a github link to the code you quoted is what I
was after. 

03/19/2012 10:33 PM, Marco Rietveld:

  
  Alberto, 
  
  Sorry to hear that the bug isn't fixed. 
  
  Could you clarify what you mean by these points? 
   - Drools and JBPM have different persistence managers.
   - Drools uses JTA for persistence and JBPM does not.
  
  I was pretty sure you could specify a JTA data source in the
  persistence.xml that jBPM uses. 
  
  As for the persistence managers, what do you mean exactly? 
  
  Also, if you could maybe give me a github link referring to the
  code you're using, that would be great. 
  
  (Just to make sure, you are referring to jbpm 5, right?)
  
  Thanks,
  Marco
  
  
  03/19/2012 06:23 PM, Alberto R. Galdo:
  I'm afraid this bug is not resolved and doesn't have
nothing to do with lazy evaluation.

We've been able to get to the source of the problem and this are
the facts:

 - Drools and JBPM have different persistence managers.
 - Drools uses JTA for persistence and JBPM does not.
 - When any JPA enabled object is persisted in Drools, a
transaction begins, it's EntityManager ( Hibernate ) joins the
transaction and the entity gets persisted. 
 - When any JPA enabled object ( in this case a
ProcessInstanceInfo ) is persisted in JBPM, there are no
transactions involved, and so the EntityManager ( Hibernate )
decides to delay the insert ( queuing it as there's no
transaction in progress ). Then the processId never gets updated
and the NPE arises.

The problem here seems to be that both Drools and JBPM manage
persistence in different and incompatible ways. We've been able
to modify jbpm-persistence-jpa to open a JTA transaction before
persisting ProcessInstanceInfo, getting the EntityManager
joining that transaction and using the current Bitronix
implementation already running in Drools ( to assist persistence
for their objects ) .. like so:

 public void setKnowledgeRuntime(InternalKnowledgeRuntime
kruntime) {
 this.kruntime = kruntime;
 Environment env = kruntime.getEnvironment();
 Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER
);
 if (!(tm instanceof
javax.transaction.TransactionManager)) {
  try {
  //  get Bitronix instance inside ...
   java.lang.reflect.Field field =
tm.getClass().getDeclaredField("tm");
 // who says private in Java is really private
... xD
   field.setAccessible(true);
   tm = field.get(tm);
  } catch (Exception e){
   e.printStackTrace();
  }
 }
 this.txm = new JtaTransactionManager( env.get(
EnvironmentName.TRANSACTION ), env.get(
EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ), tm );
 }

 public void addProcessInstance(ProcessInstance
processInstance) {
 ProcessInstanceInfo processInstanceInfo = new
ProcessInstanceInfo( processInstance,
this.kruntime.getEnvironment() );
 ProcessPersistenceContext context =
((ProcessPersistenceContextManager)
this.kruntime.getEnvironment().get(
EnvironmentName.PERSISTENCE_CONTEXT_MANAGER
)).getProcessPersistenceContext();
 this.txm.begin();
 context.persist( processInstanceInfo );
 this.txm.commit();



I think we can agree that the previous lines of code are not the
most elegant solution ( at least not for me ).

So, Is there any timeline for merging DROOLS and JBPM 5
persistence managers? 

If someone gives me advice and architectural hints ( and if it
is doable in a reasonable ammount of time ) I would be eager to
submit a patch for this 


Alberto R. Galdo
arga...@gmail.com


On Wed, Mar 14, 2012 at 13:56, Alberto
  R. Galdo arga...@gmail.com
  wrote:
  Great
news!

We were in the process of debugging JBPM trying to find the
source of the bug ... and maybe days away from the solution
...

Is there any bug report in Jira and/or a patch we can apply
without having to wait for the next release so we can
quick-patch our systems?


Alberto R. Galdo
arga...@gmail.com

  


On Wed, Mar 14, 2012 at 13:09,
  Marco Rietveld mriet...@redhat.com

Re: [rules-users] Data comparing in CONDITION column decision table

2012-03-19 Thread Michael Anstis
This is true, but be aware that if a cell value in the Template data is
empty the whole Fact Pattern is omitted.

For example:-

rule Discount @{row.rowNumber}
  when
Account( $v : @{field} != null )
$c : Customer( @{field} == $v , accno == @{accno} )
  then
$c.setDiscount(1);
end

If field is empty neither Account or Customer will be included in the
generated DRL.

If accno is empty Customer will not be included in the generated DRL.

This may have an impact on what you want to achieve.

With kind regards,

Mike

On 19 March 2012 21:29, Vincent LEGENDRE
vincent.legen...@eurodecision.comwrote:

 Hi

 Instead of using a workaround, did you have a look to rule templates ?
  - under guvnor :
 http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1143
  - drl :
 http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e7501

 You should be able to do exactly what you are trying to do, but properly,
 like that :

 template header
 field
 accno

 package range;

 template Discount
  rule Discount @{row.rowNumber}
  when
Account( $v : @{field} != null )
$c : Customer( @{field} == $v , accno == @{accno} )
  then
$c.setDiscount(1);
  end
 end template


 - Mail original -
 De: Sumeet Karawal sumeet.kara...@tcs.com
 À: Rules Users List rules-users@lists.jboss.org
 Envoyé: Jeudi 15 Mars 2012 14:20:01
 Objet: Re: [rules-users] Data comparing in CONDITION column decision table

 I inserted Account column with values that are always true.

 Works fine. :)

 Will try the same with 5.3 .

 Thanks  Regards,
 Sumeet




  From:   Wolfgang Laun wolfgang.l...@gmail.com

  To: Rules Users List rules-users@lists.jboss.org

  Date:   03/15/2012 05:30 PM

  Subject:Re: [rules-users] Data comparing in CONDITION column decision
 table

  Sent by:rules-users-boun...@lists.jboss.org






 The documentation for 5.3.0 says
 quote
 To include a pattern without constraints, you can write the pattern in
 front of the text for another pattern.
 /quote
 but it does not work with 5.2.0 and (likely) later versions.

 As a workaround, re-insert the Account column and use a redundant
 condition that is certainly true for all facts.

 I'll have to look into this.

 -W


 On 15/03/2012, Sumeet Karawal sumeet.kara...@tcs.com wrote:
  Hi Wolfgang
 
  any other way to achieve this. I have tried many times, but no success
 till
  now :(
 
  Thanks,
  Sumeet
 
 
 
 
From:   Sumeet Karawal sumeet.kara...@tcs.com
 
 
To: Rules Users List rules-users@lists.jboss.org
 
 
Date:   03/15/2012 04:24 PM
 
 
Subject:Re: [rules-users] Data comparing in CONDITION column
 decision
  table
 
Sent by:rules-users-boun...@lists.jboss.org
 
 
 
 
 
 
 
 
 
  After doing the changes, its taking the rules as:
 
  rule Discount_10
  when
 
 $a:Account(type ==
 $a.getType(), accno == 1001)
  $c:Customer
  then
 
 $c.setDiscount(1);
  end
 
 
  and if I put it as $a: Account() $c: Customer(), it takes the rules as:
 
  rule Discount_10
  when
 
 $a:Account(type ==
 $a.getType(), accno == 1001)
  $c:Customer()
  then
 
 $c.setDiscount(1);
  end
 
  Both these throw error..
 
 
 
  neither putting the $c:Customer before $a:Account is getting executed.
 
 
  Thanks  Regards,
  Sumeet
  Mailto: sumeet.kara...@tcs.com
 
 
 
From:   Wolfgang Laun wolfgang.l...@gmail.com
 
 
To: Rules Users List rules-users@lists.jboss.org
 
 
Date:   03/15/2012 04:06 PM
 
 
Subject:Re: [rules-users] Data comparing in CONDITION column
 decision
  table
 
Sent by:rules-users-boun...@lists.jboss.org
 
 
 
 
 
 
 
  On 15/03/2012, Sumeet Karawal sumeet.kara...@tcs.com wrote:
 
  How to make changes to the decision table entries to get a drl of this
  kind:
 
 
  Put
 $a: Account() $c: Customer
  into the cell where you now have $c : Customer and delete the Account
  column.
  -W
 
 
  rule Discount_10
  when
 
   $a : Account()
 
   $c : Customer(type ==
  $a.getType(), accno == 1001)
  then
 
   $c.setDiscount(1);
  end
 
 
  Thanks,
  Sumeet
  Mailto: sumeet.kara...@tcs.com
 
 
 
From:   Wolfgang Laun wolfgang.l...@gmail.com
 
 
To: Rules Users List rules-users@lists.jboss.org
 
 
Date:   03/15/2012 02:47 PM
 
 
Subject:Re: [rules-users] Data comparing in CONDITION column
  decision
  table
 
Sent by:rules-users-boun...@lists.jboss.org
 
 
 
 
 
 
 
  Line breaks were lost in transit, but I think that you should remove
  the quotes from
 
 type == $param
 
  if you insert an expression $a.getType().
 
  -W
 

Re: [rules-users] Metadata in Guvnor-created rules

2012-03-19 Thread Michael Anstis
The Metadata under the Attributes tab is stored in the JCR repository
and does not form part of the KnowledgeBase.

You can add metadata that is part of the KnowledgeBase using using the
Show options at the bottom of the Guided Rule Editor and adding metadata.

This metadata appears in rules as (for example) @mymetadata and AFAIK is
part of the rule metadata accessible from the droolsjbpm-knowledge API.

Unfortunately there is no way to link the two; however it is a reasonably
simple requirement and I'll happily mentor you to help with a Pull Request.

With kind regards,

Mike

On 19 March 2012 17:30, Stephen Masters stephen.mast...@me.com wrote:

 Hi folks,

 I'm curious about what metadata should be on a rule when created in
 Guvnor. I was assuming that any of the metadata fields shown under the
 Attributes tab should be available as metadata items when the rule gets
 activated. i.e. Title, categories, Created date, etc...

 However, when I call event.getActivation().getRule().getMetaData() on an
 AfterActivationFiredEvent, the map returned is completely empty.

 Or is the metadata for a rule in Guvnor not the same thing? I was rather
 hoping to be able to take note of the categories of each rule that fires.

 fyi ... I'm using 5.3.0.Final.

 Thanks for any assistance you can provide.

 Steve

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Exception in thread main java.lang.ClassCastException:

2012-03-19 Thread srinivasasanda
Thank you Esteban
Thank you very much

--
View this message in context: 
http://drools.46999.n3.nabble.com/Exception-in-thread-main-java-lang-ClassCastException-tp3838503p3841031.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Planner - scoring with Java (not DRL)

2012-03-19 Thread David Erickson
Hi I saw the JIRA issue on this topic here: 
https://issues.jboss.org/browse/JBRULES-3367

I'm wondering if any work has been done to enable this yet, or if not if 
this is something that could trivially be done?  I have some very 
complicated domain logic to determine a score and shudder to consider 
porting this to a language I know nothing about (DRL).  I'm also under 
significant time pressure, but would love to use Planner for some SA and 
TS runs.  Any help or pointers here would be greatly appreciated.  For a 
first run I'd be happy with completely recomputing the score at each 
step, but as an optimization would obviously want to do incremental 
where possible.

Thanks!
David
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Persistence in fireUntilHalt() loop

2012-03-19 Thread Alberto R. Galdo
Sure!


Drools does JPA persistence using this set of managers:

https://github.com/droolsjbpm/drools/blob/master/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/JpaPersistenceContextManager.java

https://github.com/droolsjbpm/drools/blob/master/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/JpaPersistenceContext.java

and JTA transaction management using:

https://github.com/droolsjbpm/drools/blob/master/drools-persistence-jpa/src/main/java/org/drools/persistence/jta/JtaTransactionManager.java


As you can see in JpaPersistenceContext, Drools only has support for
persisting this set of entities:  SessionInfo  WorkItemInfo


JBPM has its own persistence management implemented in this classes:

https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/JpaProcessPersistenceContext.java

https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/JPAProcessInstanceManager.java

So JBPM can persist ProcessInstanceInfo entities but there's no support for
JTA transactions, the code doesn't join a current JTA transaction, it even
doesn't use transactions at all.

The problem arises when using Hibernate as EntityManager for persistence
and running in a fireUntilHalt loop, given the lack of transactions support
in JBPM, when a processinstance gets created and JBPM tries to persist it
Hibernate delays the insertion as there is no transaction involved, then
the primary key stays null and so the NPE.




Alberto R. Galdo
arga...@gmail.com


On Mon, Mar 19, 2012 at 22:34, Marco Rietveld mriet...@redhat.com wrote:

  Sorry, to be clear: a github link to the code you quoted is what I was
 after.

 03/19/2012 10:33 PM, Marco Rietveld:

 Alberto,

 Sorry to hear that the bug isn't fixed.

 Could you clarify what you mean by these points?
- Drools and JBPM have different persistence managers.
- Drools uses JTA for persistence and JBPM does not.

 I was pretty sure you could specify a JTA data source in the
 persistence.xml that jBPM uses.

 As for the persistence managers, what do you mean exactly?

 Also, if you could maybe give me a github link referring to the code
 you're using, that would be great.

 (Just to make sure, you are referring to jbpm *5*, right?)

 Thanks,
 Marco


 03/19/2012 06:23 PM, Alberto R. Galdo:

 I'm afraid this bug is not resolved and doesn't have nothing to do with
 lazy evaluation.

 We've been able to get to the source of the problem and this are the facts:

- Drools and JBPM have different persistence managers.
- Drools uses JTA for persistence and JBPM does not.
- When any JPA enabled object is persisted in Drools, a transaction
 begins, it's EntityManager ( Hibernate ) joins the transaction and the
 entity gets persisted.
- When any JPA enabled object ( in this case a ProcessInstanceInfo ) is
 persisted in JBPM, there are no transactions involved, and so the
 EntityManager ( Hibernate ) decides to delay the insert ( queuing it as
 there's no transaction in progress ). Then the processId never gets updated
 and the NPE arises.

 The problem here seems to be that both Drools and JBPM manage persistence
 in different and incompatible ways. We've been able to modify
 jbpm-persistence-jpa to open a JTA transaction before persisting
 ProcessInstanceInfo, getting the EntityManager joining that transaction and
 using the current Bitronix implementation already running in Drools ( to
 assist persistence for their objects ) .. like so:

 public void setKnowledgeRuntime(​InternalKnowledgeRuntime kruntime) {
 this.kruntime = kruntime;
 Environment env = kruntime.getEnvironment();
 Object tm = env.get( EnvironmentName.TRANSACTION_​MANAGER );
 if (!(tm instanceof javax.transaction.​TransactionManager)) {
 try {
 // get Bitronix instance inside ...
 java.lang.reflect.Field field =
 tm.getClass().​getDeclaredField(tm);
 // who says private in Java is really private ... xD
 field.setAccessible(true);
 tm = field.get(tm);
 } catch (Exception e){
 e.printStackTrace();
 }
 }
 this.txm = new JtaTransactionManager( env.get(
 EnvironmentName.TRANSACTION ), env.get(
 EnvironmentName.TRANSACTION_​SYNCHRONIZATION_REGISTRY ), tm );
 }

 public void addProcessInstance(​ProcessInstance processInstance) {
 ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(
 processInstance, this.kruntime.getEnvironment() );
 ProcessPersistenceContext context =
 ((​ProcessPersistenceContextManag​er) this.kruntime.getEnvironment()​.get(
 EnvironmentName.PERSISTENCE_​CONTEXT_MANAGER
 )).​getProcessPersistenceContext()​;
 this.txm.begin();
 context.persist( processInstanceInfo );
 this.txm.commit();



 I think we can agree that the