spring-drools api exception: Invalid property 'knowledgeAgent'
by mmjose26
Hi,
Im runnung test cases in Spring Drools 5.2M1
and I have this exception:
Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ksession2': 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?
it happens with testAgents method
If you change the source code located in the drools-spring component in
class
org.drools.container.spring.namespace.KnowledgeSessionDefinitionParser.java:
// find any kagent's for the current kbase and assign
for ( String beanName :
parserContext.getRegistry().getBeanDefinitionNames() ) {
BeanDefinition def =
parserContext.getRegistry().getBeanDefinition( beanName );
if ( KnowledgeAgentBeanFactory.class.getName().equals(
def.getBeanClassName() ) ) {
PropertyValue pvalue =
def.getPropertyValues().getPropertyValue( "kbase" );
RuntimeBeanReference tbf = (RuntimeBeanReference)
pvalue.getValue();
if ( kbase.equals( tbf.getBeanName() ) ) {
factory.addPropertyValue( "knowledgeAgent",
new RuntimeBeanReference(
beanName ) );
}
}
}
modifying: if ( kbase.equals( tbf.getBeanName() ) && "stateless".equals(
sessionType ) )
it works, becasue only stateless sessions have knowledgeAgent property.
is It Correct?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/spring-drools-api-exc...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 8 months
KnowledgeAgent and Guvnor restart
by Gerret Hansper
Hello,
I have got an issue with the KnowledgeAgent that seems not to survive a Guvnor
restart. The scenario is as follows:
* We use Drools 5.0
* On our application server we create a KnowledgeAgent
applying a ChangeSet that points to a package binary on a separate Guvnor server
like so:
SystemEventListenerFactory.setSystemEventListener(new
SystemEventLogger());
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent(workflowName);
agent.applyChangeSet(changeSet);
* Creating the kbase, registering globals and running sessions works fine.
* We shut down Guvnor (or the connection goes down, this was how we spotted the
problem) and restart it after a minute
* We then try to run sessions from the
same agent as above via
kagent.getKnowledgeBase().newStatefulKnowledgeSession();
which returns a ksession, but then setting a global we get
java.lang.RuntimeException: Unexpected global [log]
at
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:5
50)
at
org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessio
nImpl.java:284)
>From the debugger I can see that indeed the ruleBase's globals map is empty. The
SystemEventLogger indicates that the KnowledgeAgent unsubscribes from its
resource when Guvnor is down and rebuilds its kbase. Also, it stops scanning the
resource and does not find it once Guvnor is up again. (See log snippet below).
Wouldn't it be better in these cases to keep the resource as is in memory and
try to rescan? I figure that as long as the resource is specified in the
changeSet it should be considered part of the kbase and not be removed if it
cannot be found.
For the time being, does anyone have a suggestion how to avoid these problems?
We could catch the RuntimeException and recreate the KnowledgeAgent, but perhaps
there is a better way?
Thanks, Gerret
-- SystemEventLog --
# Guvnor is up here
07:58:01,881 ResourceChangeScanner attempt to scan 1 resources
07:58:02,209 ResourceChangeScanner thread is waiting for 60
07:58:15,067 ResourceChangeScanner attempt to scan 1 resources
# Guvnor goes down here
07:58:16,738 ResourceChangeScanner removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification received ChangeSet notification
07:58:16,738 ResourceChangeScanner thread is waiting for 60
07:58:16,738 ResourceChangeNotification processing ChangeSet
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 ResourceChangeNotification thread is waiting for queue update
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17 to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738
KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:59:02,202 ResourceChangeScanner attempt to scan 0 resources
07:59:02,202 ResourceChangeScanner thread is waiting for 60
# Guvnor back up here
07:59:16,731 ResourceChangeScanner attempt to scan 0 resources
07:59:16,731 ResourceChangeScanner thread is waiting for 60
--
Nur noch bis 31.01.2010: DSL-Komplettpaket für 16,99 Euro/mtl.!*
http://portal.gmx.net/de/go/dsl02
13 years, 8 months
Can Drools Flow Persistence Work without JTA
by Rui Tang
Hi list,
According to the documents and some test cases, I found that Drools Flow
persistence examples have to work with JTA to enable transaction management.
Is there some way to not use JTA as my transaction manager?
--
唐睿
13 years, 8 months
mvn failed to install under drools-5.1.1-examples.zip
by Aman
When I tried to run mvn install, it gave me following error-
[INFO] Scanning for projects...
Downloading:
http://repo1.maven.org/maven2/org/drools/drools/5.1.1/drools-5.1.1.pom
[INFO] Unable to find resource 'org.drools:drools:pom:5.1.1' in repository
central (http://repo1.maven.org/maven2)
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:drools-examples:pom:null
Reason: Cannot find parent: org.drools:drools for project:
null:drools-examples:pom:null for project null:drools-examples:pom:null
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find parent:
org.drools:drools for project: null:drools-examples:pom:null for project
null:drools-examples:pom:null
at
org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at
org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find
parent: org.drools:drools for project: null:drools-examples:pom:null for
project null:drools-examples:pom:null
at
org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultM
avenProjectBuilder.java:1396)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMav
enProjectBuilder.java:823)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInter
nal(DefaultMavenProjectBuilder.java:508)
at
org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjec
tBuilder.java:200)
at
org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at
org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at
org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM
'org.drools:drools' not found in repository: Unable to download the artifact
from any repository
org.drools:drools:pom:5.1.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.drools:drools
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(
DefaultMavenProjectBuilder.java:605)
at
org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultM
avenProjectBuilder.java:1392)
... 18 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
Unable to download the artifact from any repository
org.drools:drools:pom:5.1.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:228)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:90)
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(
DefaultMavenProjectBuilder.java:558)
... 19 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to
download the artifact from any repository
at
org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWag
onManager.java:404)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultAr
tifactResolver.java:216)
... 21 more
[INFO]
------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Oct 02 16:37:04 EDT 2010
[INFO] Final Memory: 1M/4M
[INFO]
------------------------------------------------------------------------
13 years, 8 months
KnowledgeAgent Issue
by Steven Williams
Hi all,
I am trying to use a Knowledge Agent in 5.1.1 with a change set with a few
different packages and resource types in it, and I am running into a problem
where it is not adding all the packages. Looking at the code I can see that
KnowledegeAgentImpl.createPackageFromResource has the following code when it
loads a resource:
if (kbuilder.getKnowledgePackages().iterator().hasNext()) {
return (KnowledgePackageImp)
kbuilder.getKnowledgePackages().iterator().next();
}
and KnowledgeBuilderImpl.getKnowledgePackages does the following:
Package[] pkgs = pkgBuilder.getPackages();
List<KnowledgePackage> list = new ArrayList<KnowledgePackage>( pkgs.length
);
and PackageBuilder.getPackages does the following:
for ( PackageRegistry pkgRegistry : this.pkgRegistryMap.values() ) {
Package pkg = pkgRegistry.getPackage();
// add package to array
}
pkgRegistryMap is implemented as a HashMap however so the order the packages
are returned in is not guaranteed. I seem to be hitting this problem.
This is a hard one to create a unit test for so I wanted to check that my
analysis is correct before raising a bug. Perhaps using a LinkedHashMap or
similar would fix it?
thanks
Steve
13 years, 8 months
Speed up inserting of rules into knowledge base
by Piotr Jedrychowski
Hello.
I'm loading a big amount of rules during starting of JBoss (20000
rules). All rules (in string format) are available before JBoss startup
- they are stored into database. Rules are loaded one by one and it
takes about 90 minutes. I want to speed up this process. Is there
something like "bulk load" for inserting rules into knowledge base or
another smart way to fast loading a big amount of rules?
I'm using:
1) Drools 5.1
2) JBoss 4.2.3
My source code looks like this:
String rule = ...
Resource resource = ResourceFactory.newReaderResource(new
StringReader(rule));
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeBuilder.add(resource, ResourceType.DRL);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
Regards,
Piotr
13 years, 8 months
New in Drools, java.lang.NullPointerException at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
by Manuel Ortiz
Hello all!
I am new in Drools but day by day, test by test, I think I get a bit more
knowledge of how the rule engine works from user point of view. I've been
adding rules to an alarm system, increasing the complexity and functionality
in several steps. Unfortunately in the last step I found the following
NullPointerException inside the rule engine...
java.lang.NullPointerException
at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
at org.drools.reteoo.AccumulateNode.modifyLeftTuple(AccumulateNode.java:329)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:239)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:640)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
at org.drools.reteoo.BetaNode.modifyObject(BetaNode.java:312)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:460)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:428)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:160)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:460)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:428)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:263)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:172)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1442)
at
org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1349)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:183)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196)
at
es.simcasva.alarmas.rules.Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0.defaultConsequence(Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0.java:18)
at
es.simcasva.alarmas.rules.Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0DefaultConsequenceInvoker.evaluate(Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0DefaultConsequenceInvoker.java:44)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
I've been trying to find the problem, and found a strange interaction
between three rules that makes the null pointer to appear. The alarm system
has many rules now and it is difficult to simplify the scenario, so I just
would like to know what is the funcion of AccumulateNode object in order to
have an idea of the NullPointerException possible cause.
Can anyone help me?
Thank you in advance for your time.
Regards,
Manuel Ortiz.
13 years, 9 months
The update function inside a rule
by Marc Strabin
Hello,
I've 2 rules which should be similar but the result is different and I can't
understand why :
I insert an object Message() into drools with the following rule :
rule "rule_a"
timer (int:1s 1s)
when
SimpleClock ( d : dateInMillisec != 0 ) // SimpleClock give the current
time (set by a java timer and an update)
m : Message ( internalEndDate < d )
then
System.out.println( "rule a");
m.setInternalEndDate (d + 10000);
* retract (m);*
* insert (m);*
end
> the result is fine : a message every 10.
If I replace the rule_a by the rule_b : (because an update should be better
than an retract/insert I guess)
rule "rule_b"
timer (int:1s 1s)
when
SimpleClock ( d : dateInMillisec != 0 ) // Simple slock give the current
time (set by a java timer and an update)
m : Message ( internalEndDate < d )
then
System.out.println( "rule b");
m.setInternalEndDate (d + 10000);
* update (m);*
end
> the result is bad : a message every 1 second.
It act as if the attibute message.internalEndDate wasn't updated in the
drools engine. Could someone explain me if/why this behaviour is normal ?
Thanks in advance
Marc
13 years, 9 months
Using Drools to model and solve a production scheduling problem with changeovers
by Andrei Neboian
Dear All,
I am looking for a user-friendly platform which would allow me to model and
solve a
*production scheduling problem with changeover times*. Since it's an NP-Hard
problem, I am getting convinced that a CP formulation would be most
appropriate. Later on, a GUI should be designed to allow a user to interact
with the model.
Is "drools" a proper platform for this? Are there any examples of this type
of problem solved with Drools?
I need to tackle a problem with 4 parallel machines, over 100 jobs and 100
changeovertypes (sequence dependant setup times between each job).
I would appreciate any help on this! Thanks
Kind Regards,
Andrei
13 years, 9 months
Mythic Game Project Addition Artificial Intelligence and Quest System Components
by Mark Proctor
http://blog.athico.com/2011/01/mythic-game-project-addition-artificial.html
"In this project, we describe the design decisions and principles behind
the arti cial intelligence (AI) for a multiplayer online role playing
game, and our use of an expert system to implement it. We explain how we
organize AI rules into les, how those rules are assembled from a
database, how AI is assigned to entities, the di erent types of AI, the
di erent phases of AI, and how we manage facts used by AI. We also
review some of the history behind the Mythic project, where it is
headed, what an expert system is and why we chose to use one for our
project. The result of our project is a design that allows us to have
diverse AI behavior and exibility to reuse code to create new behaviors,
but may prove to be ineffcient if implemented on systems with many
players or many instances of AI running."
13 years, 9 months