OSGI, classloading, and imports in KnowledgeBuilder
by msully
So I'm playing with Drools in Equinox OSGi, and so far it's behaving quite
nicely - one bit of weirdness though.
What I'm trying to do:
I have a bundle with a 'flow manager' that listens for instances of
WorkItemHandler in the service broker (well, really my own subinterface that
has a getName method). It also listens for new bundles with a
META-INF/drools directory with *.rf files in them, and parses the .rf files
it finds there.
The Flow Manager is itself published as an OSGI Service with a 'perform'
method. It encapsulates all of its Drools calls within the perform method
though - they aren't exposed to clients.
My test involves a simple start->work item->end workflow.
I pass in an instance of a class "Tablex" that can be saved to hibernate. I
also pass in a String that has the table name, and an empty List to get the
results.
My .rf file tries to import Tablex. It declares the three values I mention
above, and maps them to the work item in the work item definition.
<p>
<imports>
<import name="my.pkg.Tablex" />
</imports>
...
<variable name="my.pkg.newrecord" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="my.pkg.Tablex"/>
</variable>
...
<workItem id="2" name="DBWorkItem" x="165" y="374" width="80"
height="40" >
<work name="DBWorkItem" >
</work>
<mapping type="in" from="my.pkg.tablename" to="my.pkg.tablename" />
<mapping type="in" from="my.pkg.newrecord" to="my.pkg.newrecord"/>
<mapping type="in" from="my.pkg.outlist" to="my.pkg.outlist"/>
</workItem>
</p>
In my manifest for my .rf file and for the flow manager (where the parsing
occurs) I Import-Package Tablex's package.
When my flow manager tries parsing the rule, it gives an error saying the
the import failed. BUT, everything still works, and my WorkItemHandler works
correctly (the WorkItemHandler imports Tablex itself, since it needs to
manipulate it).
If I declare my Tablex variable as a java.util.Object in the ruleflow then I
don't get the error and things also still work.
If I declare my Tablex as Tablex in the rule flow AND import it in the class
that does the parsing (it's already 'OSGI' imported to the parsing bundle,
but now I'm doing a plain old Java import on it) then everything works fine
with no error message.
Kind of a hybrid question but I figured I'd start with the Drools folks.
Any ideas would be appreciated.
Thanks,
Mike
--
View this message in context: http://www.nabble.com/OSGI%2C-classloading%2C-and-imports-in-KnowledgeBui...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
Re: [rules-users] not able to debug drools flow
by Jakob Marovt
Hi,
I`m experiencing the same problems as Vishal. I am using Eclipse 3.5
and newest Drools. I am only able to debug project as Java
application, but when I want to debug it as Drools application all I
get is this problem. I also tried disabling firewall and changing its
settings but as it seems it does not help.
So if anyone has figured out a solution to this problem, I would
really appreciate an answer.
Thanks,
Jakob
probably related to your personal firewall:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303969
http://www.techienuggets.com/Comments?tx=3786
I don't think this is a Drools specific issue.
Mark
Vishal Anand wrote:
>
**>* Hi,*
>
**>* *
>
**>* I am using Drools 5.0 and have create a simple application using *
>* drools flow, it runs perfectly but when trying to debug it as n drools *
>* application I get the following error:*
>
**>* *
>
**>* FATAL ERROR in native method: JDWP No transports initialized, *
>* jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)*
>
**>* ERROR: transport error 202: connect failed: Connection refused*
>
**>* ERROR: JDWP Transport dt_socket failed to initialize,
TRANSPORT_INIT(510)*
>
**>* JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports *
>* initialized [../../../src/share/back/debugInit.c:690]*
>
**>* *
>
**>* *
>
**>* While stack trace shows the following:*
>
**>* *
>
**>* *
>
**>* java.lang.IncompatibleClassChangeError: Expected static method *
>*org.drools.eclipse.launching.DroolsVMDebugger.renderCommandLine([Ljava/lang/String;)Ljava/lang/String;
*
>
**>* at org.drools.eclipse.launching.DroolsVMDebugger.run(Unknown Source)*
>
**>* at *
>*org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:101)
*
>
**>* at *
>*org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate.launch(Unknown
*
>* Source)*
>
**>* at *
>*org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
*
>
**>* at *
>*org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
*
>
**>* at *
>*org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:866)
*
>
**>* at *
>*org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1069)
*
>
**>* at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)*
>
**>* *
>
**>* *
>
**>* I am using eclipse 3.4*
>
**>* *
>
**>* What could be the issue ?*
>
**>* *
>
**>* Thanks*
>
**>* Vishal*
>
**>*------------------------------------------------------------------------
*
>
**>* _______________________________________________*
>* rules-users mailing list*
>* rules-users at lists.jboss.org<http://lists.jboss.org/mailman/listinfo/rules-users>
*
**>* https://lists.jboss.org/mailman/listinfo/rules-users*
**>* *
15 years, 3 months
Guvnor fails to vaildate rule, though same rule compiles and run successfully when compiled command line with ANT.
by Codedrop
Recently upgraded from Drools 4.0.7 to 5.1.0 and have imported our rules into
Guvnor. Unable to determine why the same rules will not correctly validate
in Guvnor which prevents building a package for deployment.
Sample Rule:
salience 50
agenda-group "idia"
when
Root(identityRequest != null)
then
logger.debug("Main - Main Data Evaluation");
System.out.println("Main - Main Data
Evaluation");
drools.getWorkingMemory().setFocus("mainAnalysis");
Throws the following validation error when you select ‘Validate’:
[Main - Data Evaluation] Unable to create Field Extractor for
'identityRequest' of '[ClassObjectType
class=com.netid.idia.model.natal.rootIdentityRequest.Root]' in rule 'Main -
Data Evaluation'
Unsure why identityRequest is failing. There is a valid getter in the java
file and guvnor displays identityRequest in the list of attributes for
‘Root’. Oddly, if I change the when clause to be
Root(this.identityRequest != null) it validates fine. Did something change
between 4.0.7 and 5.1.0 that I’m missing or do I have error somewhere that
goes undetected outside the guvnor?
--
View this message in context: http://www.nabble.com/Guvnor-fails-to-vaildate-rule%2C-though-same-rule-c...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
sliding time in lhs
by Francesco Chiarelli
Hi!
i'm new to use a drools-fusion, i've a next lhs condition in rule:
$o: Order(status!="EU_C_R1_INIT")
SystemConfig(value:value) from hbnSession.createQuery("from
SystemConfig where name=:name").setString("name","nRicMax").uniqueResult()
$nRic : Number(intValue < value) from accumulate($n:
Order(this==$o) over window:time(1d),count($n))
Data:
1) Order 1 date 28 aug 2009 EU_C_INIT
2) Order 1 date 31 aug 2009 EU_A_INIT
3) Order 1 date 31 aug 2009 EU_B_INIT
4) Order 1 date 30 aug 2009 EU_B_INIT
5) Order 1 date 28 aug 2009 EU_A_INIT
6) Order 1 date 01 aug 2009 EU_A_INIT
7) Order 1 date 28 aug 2009 EU_C_INIT
8) Order 1 date 28 aug 2009 EU_C_INIT
Only the first condition is verified [ Order(status!="EU_C_R1_INIT") ]
altough there are facts that verify Order(this==$o) over window:time(24h) ]
There are n-k facts that don't verify a previous condition but them come
count also:
I espect that drools count a 2-3-4 but it count also 5-6-7: i'm confused
P.S. i did set a stream mode, i' had set a timestamp attribute in event fact
@timestamp(myTimestampLong), i tried with pseudo clock (making it advance
for new Date().getTime() or at origin, therefore 01 jan 1970 [without event
@timestamp attribute] )
Regards
Francesco
15 years, 3 months
Why so many ACTIVATION/DEACTIVATION events?
by Tom.E.Murphy@wellsfargo.com
We have a fairly complex object model, but we're still puzzled - I thought that the definition of "Activation" was that the data matched on all conditions of a rule, and therefore the rule was entered into the agenda (activated).
If that is true, I cannot figure out why we're experiencing this.
As our number of rules increases, we're seeing exponential increases in repetitive activation/deactivation pairs, even on rules where we know the data does not match the conditions.
Example:
The following rule (abbreviated here) creates an object of type PolicySet if there are none that match the conditions.
I would expect this rule to activate once, then fire, wherein the matching PolicySet is created, and then never activate again since the absence of a matching PolicySet object is never again true.
However, in a rule base of ~4,000 rules, we see this rule activating 975 times and deactivating 975 times. This is just one example - nearly all our rules do this, and it is seriously impacting decisioning performance.
Have I misunderstood the meaning of "activation"? Can anyone help me understand this?
rule "RS6090.1.12_RF7007_50001012"
when
LendingProduct ( $exitStrategyType1 : exitStrategyType )
Features ( $lienPriority1 : lienPriority )
DecisionResultsInfo ( $dealRiskCategory1 : dealRiskCategory )
TransactionDetail ( $parentTransactionDetail1Id : myId )
not
(
PolicySet ( $parentPolicySet_1_Id : myId, parentId == $parentTransactionDetail1Id )
and
PolicySetIdentifier ( parentId == $parentPolicySet_1_Id
, lienPriority == $lienPriority1
, exitStrategyType == $exitStrategyType1
, dealRiskCategory == $dealRiskCategory1)
)
then
// Content removed... rule creates the policy set and the policy set identifier, and initializes all appropriate elements
// After doing so, why does it activate/deactivate 1800+ times in a rule base of 4000 rules?
System.out.println("6090 fired.");
End
Thanks.
Tom Murphy
Business Process Consultant
Wells Fargo HCFG - CORE Deal Decisioning Platform
800 S. Jordan Creek Parkway | West Des Moines, IA 50266
MAC: X2301-01B
Office: 515 324 4853 | Mobile: 941 320 8014
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
15 years, 3 months
Calculating minimal value for a group of facts
by kothvandir kothvandir
Hi,
I need to calculate the min time for a set of "jobs" inserted in working
mermory to know wich job is going to be finished first.
Is there any way to obtain within a rule the current facts of some type to
pass then to a function/method?
somethin like this:
Another idea to acomplish this?
gobal MyService myservice
rule "cmdCheckTime" ruleflow-group "comprobarExistencias"
when
Job(time = eval(myService.getMinTime( <jobs in working memory >))
then
go, go, go...
end
Thank you
15 years, 3 months
Drools-flowlification of an application
by Ista Pouss
Hi,
I have an application swing / JCR mecanism.
I should want put some Drool / Flow functions for existant datas. I'm
a total newbee. Flow is good for my ends users and for my code,I hope.
How can I transform some POJO object, and some JCR datas, to enabled
drools flow ?
Thanks.
15 years, 3 months
Not conditional 'not' for event streams?
by Barry Kaplan
I'm trying to formulate a condition like:
$se : StartEvent()
from entry-point "stream"
$fe : FinishedEvent(exchangeId == $se.exchangeId, this after[0s,30s] $se)
from entry-point "stream"
not AbortedEvent(exchangeId == $se.exchangeId, this after[0s,30s] $se)
from entry-point "stream"
A compile error is issued due to the use of 'not' on the last clause. Is
this not supported? Is there another way to obtain this behavior.
Even this simple clause is not value:
not AbortedEvent() from entry-point "stream"
----
The corresponding esper for this would be something like:
select * from pattern [every s=StartEvent ->
(f=FinishedEvent(exchangeId = s.echangeId) where timer:within(30
sec)
and not AbortedEvent(exchangeId = s.echangeId) where
timer:within(30 sec)]
--
View this message in context: http://www.nabble.com/Not-conditional-%27not%27-for-event-streams--tp2521...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months
Why this rule did't work?
by zgbigman
I'm trying to formulate a condition like:
package com.sample
import org.hibernate.Session;
import com.sample.entity.TempEntity;
global java.util.List myGlobalList;
rule "Hello World"
when
$hibernateSession : Session();
$tmp1 :TempEntity($bin1 :bin) from $hibernateSession.createQuery("from
TempEntity").list()
$tmp2 : TempEntity($bin2 : bin) from myGlobalList
//eval($bin == ((TempEntity)(myGlobalList.get(0))).getBin())
eval($bin1 == $bin2)
then
System.out.println("success");
end
I'm trying to find an Entity by bin from DB.
there is only one entity in the "myGlobalList". NO complie error but it
shows the following:
log4j:WARN No appenders could be found for logger
(org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate:
select
tempentity0_.bin as bin0_,
tempentity0_.bank_name as bank2_0_,
tempentity0_.bank_id as bank3_0_,
tempentity0_.card_name as card4_0_,
tempentity0_.card_length as card5_0_,
tempentity0_.card_type as card6_0_
from
bin tempentity0_
what should I do if i want this rule works?
--
View this message in context: http://www.nabble.com/Why-this-rule-did%27t-work--tp25218669p25218669.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 3 months