Question about drools server
by Xinhua Zhu
Hi
I am a new guy on drools server. I am trying to exposed drools rules in web
services.
I downloaded Drools Guvnor Standalone from website, it includes Jboss, then
I put drools server war file in deploy folder, and start the Jboss.
When I input "http://localhost:8080/drools-5.1.1-server/" in browser, it
works well. the result is "Execution server is running".
When I input "http://localhost:8080/drools-5.1.1-server/test.jsp", the
expected result should be "echo: Hello world", but the actual result is:
Sending Message: "Hello World"
Response: "org.apache.cxf.jaxrs.impl.ResponseImpl@6231ed"
What is wrong with it? How to solve it? Thanks very much!
BR
Xinhua
15 years, 5 months
ksession.dispose() and DroolsSpringJpaManager.dispose()
by drooRam
I have question on kession.dispose(), what is the best place to call this
method?
I have a code where in i call
ksession.startProcess("someprocess", mapParam);
ksession.fireAllRules();
....
finally{
ksession.dispose();
}
If i invoke the kession.dispose() like the above, I always ended up in "No
value bound to the key" - Transaction exception.
My understanding is that all the calls to drools should be enclosed in a
transactional unit. I have done that so.
My observation is that DroolsSpringJpaManager.dispose() method is being
invoked due to my call to ksession.dispose() after the transaction has begun
from my app code and right before the transaction.aftercompletioncommit()
call.
I can see a line of code in DroolsJpaManager.dispose() method,
TransactionSynchronizationManager.unbindResource(this.emf) //
entityManagerFactory reference borrowed from application code.
My question is that why the above line of code is necessary in dispose()
method since this.emf is the reference obtained from Application code jpa
manager, since this method unbinded this resource, transaction initiated
from the application code is also trying to unbind the same resource once
everything is completed results to "No value found for this key exception".
When i comment out ksession.dispose() call from my app code, it works fine.
At this point, i am not sure when to invoke ksession.dispose() call and why
the TransactionSynchronizationManager.unbindResource(this.emf) being made
in DroolsSpringJpaManager.dispose() on a reference obtained from
JpaTransactionManager ?
-drooRam
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/ksession-dispose-and-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
DRL Functions
by Swindells, Thomas
I've just been writing what should be a really simple function in my DRL.
What I wanted to do is to take an object in, construct another object from it and then insert both into working memory.
Eg.
function void insertBoth(Object1 object1) {
insert(new Object2(object1));
insert(object 1);
}
Rule XYZ
When
Then
insertBoth(new Object1());
End
This didn't work as expected however as it couldn't find the method insert.
I then thought, ah maybe I need to use the kcontext global to access them
function void insertBoth(Object1 object1) {
kcontext.insert(new Object2(object1));
kcontext.insert(object 1);
}
Rule XYZ
When
Then
insertBoth(new Object1());
End
This doesn't work either so what I've had to do is:
function void insertBoth(KnowledgeContext kcontext, Object1 object1) {
kcontext.getKnowledgeRuntime().insert(new Object2(object1));
kcontext.getKnowledgeRuntime().insert(object 1);
}
Rule XYZ
When
Then
insertBoth(kcontext, new Object1());
End
This is suddenly a lot more complicated than it needs to be. Why can't functions have the same access to the standard operations (insert, update, retract etc) and globals as rule actions currently do?
Should I raise an issue for this or am I missing something?
Thomas
________________________________
**************************************************************************************
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
**************************************************************************************
15 years, 5 months
Variable Notation in rule Condition
by sumatheja
Hi All,
I have this doubt regarding the notation used inside the rule's
condition. I have a fact HOST having the variables* HostName* and *
CPUSockets*. I have the following rule
rule "Test"
when
HOST(HostName!=null, CPUSockets>3)
then
# do something
Is throws an error saying cannot extract field *HostName*. It works fine
when i use *hostName*. Can anyone explain me the concept behind this.
Thanks in advance :)
--
cheers
Sumatheja Dasararaju
15 years, 5 months
Drools-Spring Config for Knowledge Agent
by KiranP
Hello Everybody,
I've used Drools5.1.0 and I have following Config In Spring :
<drools:resource id="profileChangeProcess" type="DRF"
source="classpath:/process/profilechangeprocess.rf"></drools:resource>
<drools:resource id="documentsRule" type="DRL"
source="classpath:/rules/documentsrule.drl" />
<drools:resource id="ChangeSet" type="CHANGE_SET"
source="classpath:/ChangeSet.xml"></drools:resource>
<drools:resource-change-scanner id="scanner" interval="10" />
<drools:kagent id="agent" kbase="knowledgeBase" new-instance="true">
<drools:resources>
<drools:resource ref="profileChangeProcess"></drools:resource>
<drools:resource ref="documentsRule"></drools:resource>
<drools:resource ref="ChangeSet"></drools:resource>
</drools:resources>
</drools:kagent>
<drools:kbase id="knowledgeBase"></drools:kbase>
now when i run the code i get following exception :
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'kSession': Error setting property values; nested exception
is org.springframework.beans.NotWritablePropertyException: Invalid property
'knowledgeAgent' of bean class
[org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory]:
Bean property 'knowledgeAgent' is not writable or has an invalid setter
method. Does the parameter type of the setter match the return type of the
getter?
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:820)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:762)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:475)
... 30 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid
property 'knowledgeAgent' of bean class
[org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory]:
Bean property 'knowledgeAgent' is not writable or has an invalid setter
method. Does the parameter type of the setter match the return type of the
getter?
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1012)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:857)
at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1338)
... 41 more
any help or pointers to examples may help.............
-----
Keep Working >>
KiranP
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Spring-Config-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Resuming a simple process involving human task
by Touma
Hi all,
For the past few weeks I've been trying to get a simple drools flow example
involving human tasks up and running. I've done quite a bit to the point
that my session, process, task and workitems are being persisted in the
database. Here is what my flow looks like:
Start -> Ruleflow -> Decision node -> Human Task -> Printing Node -> End
The work item handler for the Human task simply performs the task of
persisting the Task instance. After reaching the Human Task, the flow stops
and the state is persisted. But how would I go about restarting/resuming the
flow so that the 'Printing node' is reached? I've tried using the
loadStatefulKnowledgeSession(sessionId) to load the session but querying the
list of all the processes for the given session returns an empty list. Ditto
with the list of all the process events. I have all the ID's with me
(workitem, process, task, session) but am pretty confused as to how these
can be put to use to resume my suspended workflow.
Any pointers would be much appreciated. TIA.
Peace,
/T\
--
View this message in context: http://n3.nabble.com/Resuming-a-simple-process-involving-human-task-tp716...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Constants and BigDecimals
by Evert Penninckx
Hi
I've got the following rule:
when
$sale : Sale( amount > 300 )
then
modify($sale) { amount = 300; }
end
First problem: I don't like putting the constant value "300" two times in my
rule.
Second problem: amount is a BigDecimal. I read that mvel2 supports
BigDecimal literals like 300.00B, but drools won't compile this.
An ideal solution would look like something like this:
when
$maxAmount : 300.00B
$sale : Sale( amount > $maxAmount )
then
modify($sale) { amount = $maxAmount; }
end
1. Is it possible to attribute values to a variable?
2. If not, is it possible to use mvel's BigDecimal support? Because amount
> 300.00B says a lot more than eval(amount.compareTo(new
BigDecimal("300.00")) > 0).
Evert
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Constants-and-BigDeci...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Re: [rules-users] Is it possible to use CEP features in Guvnor?
by John Peterson
I've done some additional experimentation and verified that you can't
run Test Scenarios (at least, can't run them successfully). I did
discover that I could create a "Technical Rule" that has the declare to
establish our object as an event. I'm sure this isn't intended, but it
works....
For technical rules, adding the "from entry-point "X" " is easy.
For DSL rules, I can hide it in the translation for the literal values
the user can specify
For the Guided Rule Editor, it appears that adding "Free Form DRL" to
the LHS of the rule under the Fact block to enter the "from entry-point
"X" " part as well and it parses and runs okay.
jp
> Date: Tue, 12 Oct 2010 20:50:28 +0100
> From: Michael Anstis <michael.anstis(a)gmail.com>
> Subject: Re: [rules-users] Is it possible to use CEP features in
> Guvnor?
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID:
> <AANLkTingb2zOtR3WZsKkn6rEqfAGcLg60axGZuYLvnM1(a)mail.gmail.com>
> Content-Type: text/plain; charset="windows-1252"
>
> I assume you mean using ther guided editor rather than a vanilla "DRL
Rule"
> (free format text)?
>
> If the former then I don't believe it is possible (nor would testing
with Guvnor's QA facility).
>
> DRL rules could be defined but not tested.
>
> 2010/10/12 John Peterson <john.peterson.gv3k(a)statefarm.com>
>
> > I was wondering if it was possible to leverage the CEP features in
> > Guvnor. I am not sure how we?d set the ?@role(event)? in Guvnor or
> > putting the ?entry-point? in the rule unless you use DSL (embedding
it
> > in the translation) or doing technical rules.
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
15 years, 5 months