Drools Planner: what if possible values of a PlanningVariable are dependent of another one?
by Willem van Asperen
Hi All,
I have a PlanningEntity that has several planning variables, say A and
B. Now, if A is O then B can be X or Y and when A is P then B can be Y or Z.
I see two routes:
* create a solution property that generates X, Y and Z as alternatives
for B and rely on the score rules to dismiss improper values,
depending on the value of A
* create an entity property that only generates the possible values
for B (i.e. X,Y for A=O and Y,Z for A=P)
What is the best route?
(Alternatively I do not use the constructionHeuristic and just start of
my solution with a randomly (but correct) generated solution)
Regards,
Willem
10 years, 6 months
Spring, KnowledgeAgent, and Guvnor
by paulB
I'm having a problem connecting my KnowledgeAgent to a package in Guvnor.
I'm using Spring to instantiate the KnowledgeAgent. The agent initializes
perfectly well when I point to a local change-set that in-turn points to a
local rule. However, even though I have the same rule in a package in
Guvnor, the KnowledgeAgent fails with the following exception when I point
to the package's change-set in Guvnor:
The code at KnowledgeBaseImpl.java:148 is (using 5.3.0.Final):
Here is the simple rule in the Guvnor as returned by the URL for the package
source URL:
Here is the local change-set definition. The line that is commented is the
failing resource, whereas the local file resource works fine:
Guvnor is residing on a Tomcat server.
I could not find anything related to this on the forum. Thank you for any
hints.
-Paul
--
View this message in context: http://drools.46999.n3.nabble.com/Spring-KnowledgeAgent-and-Guvnor-tp3500...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 6 months
java.lang.NullPointerException in simple example
by ahgiovanini
Hi guys!
I'm new in the world of jboss and drools and I'm making some simple examples
that existing on
https://github.com/droolsjbpm/drools/tree/master/drools-examples-api
Now, I'm studing the CashFlow example and in my project when I run it, I
receive a error message saying:
Exception in thread "main" java.lang.NullPointerException
at com.sample.CashFlowMain.main(CashFlowMain.java:30)"
I don't know the why this message, because I set the acp at lines 20 and 21.
Someone would help me please?
Thanks
package com.sample;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CashFlowMain {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
KieContainer kc =
KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.newKieSession("CashFlowKS");
AccountPeriod acp = new AccountPeriod();
acp.setStart(date("2013-01-01")); // set acp - line 20
acp.setEnd(date("2013-03-31")); // set acp - line 21
Account ac = new Account(1, 0);
CashFlow cf1 = new CashFlow(date( "2013-01-12"), 100,
CashFlowType.CREDIT, 1 );
CashFlow cf2 = new CashFlow(date( "2013-02-2"), 200,
CashFlowType.DEBIT, 1 );
CashFlow cf3 = new CashFlow(date( "2013-05-18"), 50,
CashFlowType.CREDIT, 1 );
CashFlow cf4 = new CashFlow(date( "2013-03-07"), 75,
CashFlowType.CREDIT, 1 );
FactHandle fh = ksession.insert(acp);
ksession.insert( ac );
ksession.insert( cf1 );
ksession.insert( cf2 );
ksession.insert( cf3 );
ksession.insert( cf4 );
ksession.fireAllRules();
acp.setStart(date( "2013-04-01"));
acp.setEnd(date( "2013-06-31"));
ksession.update(fh, acp);
ksession.fireAllRules();
}
public static Date date(String str) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse( str );
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NullPointerException-in-simpl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT
by waynemetcalfe
I've seen this problem a few places while searching for a solution. Is it
possible to overcome this issue?
Drools version:6.0.0.Final
Java version: 1.7.0_45
Code snippet:
...
final KieServices ks = KieServices.Factory.get();
final KieRepository kr = ks.getRepository();
final KieFileSystem kfs = ks.newKieFileSystem();
//ruleScript is simply a string containing the rules
kfs.write("src/main/resources/com/company/test/rules/rules.drl",
ruleScript);
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR)){
configuration.getLog().error("\nSomething wrong here!\n\n");
}
final KieContainer kContainer =
ks.newKieContainer(kr.getDefaultReleaseId());
session = kContainer.newKieSession();
Exception:
java.lang.RuntimeException: Cannot find KieModule:
org.default:artifact:1.0.0-SNAPSHOT
at
org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:86)
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Cannot-find-KieModule-org-default-artif...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
How to feed camel-server with kmodules using kie-ci?
by wogo
Hi,
I am trying to integrate drools-camel-server-example and kie-ci (6.0.1)
plugin.
My goal is to load modules from maven (built/deployed from kie-wb).
Maven configuration looks fine, as MavenSettings are initialized while
debugging (I see my repos).
I do everything locally to make things simpler.
Standalone code (from Eclipse) works fine with kie-cie - I execute
"Underage" rule from mortgages example.
I have built server with all kie-cie dependencies, however none of kmodules
deployed in Maven is loaded.
What am I missing? Is there anything special required in
knowledge-services.xml (I have used a default one provided originally in
.war)?
Do you have an example of mortgages obtained via camel-server?
Regards,
Wojciech
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-feed-camel-server-with-kmodules-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
named query TasksAssignedAsPotentialOwner doesn't work with MySql db
by Frank Knoll
Hi,
When I add a task (having two potential owners) by calling the method
addTask followed by calling the method getTasksAssignedAsPotentialOwner of
org.jbpm.task.service.TaskClient I expect to receive a list of TaskSummaries
containing at least the previously added task. But I actually get an empty
list!
Here is my setup and possible solution:
I am using the trunk version of
./jbpm-human-task/src/main/resources/META-INF/orm.xml and a MYSQL database.
When calling addTask the Task table will be populated with a NULL
actualOwner_id.
The named query TasksAssignedAsPotentialOwner
"select new org.jbpm.task.query.TaskSummary(...t.taskData.actualOwner...)
from ... left join t.taskData.actualOwner ..." of orm.xml generates SQL
consisting of an inner join "inner join OrganizationalEntity user7_ on
task0_.actualOwner_id=user7_.id" which doesn't take the NULL actualOwner_id
correctly into account.
When I replace the named query TasksAssignedAsPotentialOwner with
"select new org.jbpm.task.query.TaskSummary(...actualOwner...) from ...left
join t.taskData.actualOwner as actualOwner ...", then the generated SQL
consists of an "left outer join OrganizationalEntity user2_ on
task0_.actualOwner_id=user2_.id" which takes the NULL actualOwner_id
correctly into account. So I get a List of TaskSummaries containing the
added task.
Is this a correct fix?
Cheers, Frank
--
View this message in context: http://drools.46999.n3.nabble.com/named-query-TasksAssignedAsPotentialOwn...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 8 months
Spring 4.0 & Drools 6.0.1 Integration issue
by kmansoor
Hi All- I'm trying to use Drools in a Spring 4 applications. Trying to inject
a StatelessSession in a Spring bean:
@Service
public class RulesServiceImpl implements RulesService {
@Inject()
private StatelessKieSession kStatelessSession;
...
}
This results in:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [org.kie.api.runtime.StatelessKieSession] found
for dependency: expected at least 1 bean which qualifies as autowire
candidate for this dependency. Dependency annotations:
{(a)javax.inject.Inject()}
pom.xml is as follows:
<kie.version>6.0.1.Final</kie.version>
<drools.version>6.0.1.Final</drools.version>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>${kie.version}</version>
</dependency>
and applicationContext.xml:
<kie:kmodule id="kmodule1">
<kie:kbase name="kbase1" packages="rules">
<kie:ksession name="ksession1" type="stateless" />
</kie:kbase>
</kie:kmodule>
<bean id="kiePostProcessor"
class="org.kie.spring.KModuleBeanFactoryPostProcessor" />
I also tried the other route:
@PostConstruct
public void setUp() {
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
kStatelessSession = kContainer.newStatelessKieSession("ksession1");
}
This results in NullPointerException:
Caused by: java.lang.NullPointerException
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:444)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newStatelessKieSession(KieContainerImpl.java:435)
at
ca.utoronto.med.dc.webcv.service.RulesServiceImpl.setUp(RulesServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 23 more
I do see the following in the console:
2014-02-10 20:05:06,263 DEBUG
org.drools.compiler.kie.builder.impl.ClasspathKieProject.getPomProperties(210):
- Found and used pom.properties
\work\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\dcwebcv\META-INF\maven\ca.utoronto.med.dc\dcwebcv\pom.properties
releaseId == ca.utoronto.med.dc:dcwebcv:1.0-SNAPSHOT
2014-02-10 20:05:06,407 INFO
org.drools.compiler.kie.builder.impl.KieRepositoryImpl.addKieModule(72): -
KieModule was added:FileKieModule[
ReleaseId=ca.utoronto.med.dc:dcwebcv:1.0-SNAPSHOTfile=\work\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\dcwebcv\WEB-INF\classes]
Any pointer will be highly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Spring-4-0-Drools-6-0-1-Integration-iss...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 8 months
NullPointerException with kie-spring 6.0.1 and Spring 4.0
by Andrew Berman
Hello,
I'm trying to play around with Drool 6.0.1 integration with Spring (I'm
using spring-boot which includes spring 4.0). I've looked at the unit
tests written and have copied them pretty much exactly. When I start the
app, I consistently receive:
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [org.kie.spring.KModuleBeanFactoryPostProcessor]:
Constructor threw exception; nested exception is
java.lang.NullPointerException
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069)
... 22 more
Caused by: java.lang.NullPointerException
at
org.kie.spring.KModuleBeanFactoryPostProcessor.initConfigFilePath(KModuleBeanFactoryPostProcessor.java:79)
at
org.kie.spring.KModuleBeanFactoryPostProcessor.<init>(KModuleBeanFactoryPostProcessor.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
When debugging the NPE comes from line 79,
getClass().getResource("/").getPath(), because getResource yields null.
Here is my spring context file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:kie="http://drools.org/schema/kie-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://drools.org/schema/kie-spring http://drools.org/schema/kie-spring.xsd
">
<kie:kmodule id="kmodule">
<kie:kbase name="kbase1" packages="rules.drools">
<kie:ksession name="ksession">
<kie:consoleLogger/>
</kie:ksession>
</kie:kbase>
</kie:kmodule>
<bean id="kiePostProcessor"
class="org.kie.spring.KModuleBeanFactoryPostProcessor"/>
</beans>
Can someone help out?
Thanks!!
10 years, 8 months