When Guvnor is down.
by san_hegde
Hi All,
We are facing a problem i.e. when Guvnor is down our application then fails to scan the resource in Guvnor, and after that even if Guvnor comes up, the scanner wont scan that resource. In the log I can see that number of resource scanning is 0.
That means if that happens then our application goes for toss forever till we next restart our application.
We are using spring integration for resource scanning. Below is the code used for that
<drools:resource id="resource"
source="ruleEngineURL"
type="CHANGE_SET" />
<drools:resource-change-scanner id="s1"
interval="3600" />
I also read that we can configure such a way that when Guvnor is down then local cached resource can be used, and when Guvnor comes up then it starts reading from Guvnor.
Do you know what configuration I have to use to achieve that.
We are using drools and Guvnor 5.2 version.
Thank you
Santhosh Hegde A
--
View this message in context: http://drools.46999.n3.nabble.com/When-Guvnor-is-down-tp4028983.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
6.0.1.F Need help in getting recanned rules into new session
by SrjTx
I've have been unable to figure out how to get drools to rescan and then use
the updated rules in a new session. I currently have to restart jboss to
pick up the changes. The scanning seems to happen, but I don't see the
changes that should be included.
I have looked at lots of example code on the web and also at the Switchyard
source. When I do this in tandem with SY, I can get it to work, but I
need/want to have it work on its own.
I have tried some different combinations with no luck.
In addition to the "why doesn't it work", I would like to clearly
understand:
Do I need a KieBase, or should I just be creating sessions off of the
container?
What do I need to have in Envinonment?.
What do I need to have in ksessionConfiguration?
Related, what is the proper mechanism to pass in the Session Name?
GAD is: com.xyz.policy, cep, 1.0
Drools session is stateful and named "DroolsSession", stream processing
mode, realtime
I initialized KIE with the following.
kieServices = KieServices.Factory.get();
releaseId = kieServices.newReleaseId("com.xyz.policy", "cep",
"LATEST");
kieFileSystem = kieServices.newKieFileSystem().generateAndWritePomXML(
releaseId);
kieBuilder = kieServices.newKieBuilder(kieFileSystem);
kieBuilder.buildAll();
Results results = kieBuilder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
StringBuilder sb = new StringBuilder();
for (Message message : results.getMessages(Message.Level.ERROR)) {
if (sb.length() != 0) {
sb.append(" -- ");
}
sb.append(message.toString().trim());
}
log("Unable to initialize KIE " + sb.toString());
} else {
env = kieServices.newEnvironment();
kieContainer = kieServices.newKieContainer(releaseId);
kieScanner = kieServices.newKieScanner(kieContainer);
kieBaseConfiguration = kieServices.newKieBaseConfiguration();
kieBase = kieContainer.newKieBase(kieBaseConfiguration);
kieSessionConfiguration = kieServices.newKieSessionConfiguration();
kieSessionConfiguration.setProperty("sessionName", "DroolsSession");
kieSessionConfiguration.setProperty("drools.clockType", "realtime");
kieSessionConfiguration.setProperty("drools.evenProcessingMode",
"stream");
Later when I determine it is time to rescan, I do the following:
kieScanner.scanNow();
System.err.println("Scanning...");
currentKieSessionThread = new KieSessionThread(
kieBase.newKieSession(kieSessionConfiguration, env));
executorBean.execute(currentKieSessionThread);
--
View this message in context: http://drools.46999.n3.nabble.com/6-0-1-F-Need-help-in-getting-recanned-r...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
inserted object now working
by Gopu Shrestha
I am struggling to identify why my another object (Claim) inserted into ksession is not working..
However, I tried the object Message() is working but not Claim(). I printed values of Claim Object its working but not in rule.
Where I missed??? Please help...
Here is the code.
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
// go !
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
TClaim claim = loadFile();
System.out.println("......CategoryOfService---------"+claim.getClaimIdentificationInfo().getCategoryOfService().getValue());//working
System.out.println("......ProviderclaimNumber--"+claim.getClaimIdentificationInfo().getProviderClaimNumber().getValue()); //working
ksession.insert(message);
ksession.insert(claim);
ksession.fireAllRules();
private static TClaim loadFile() throws JAXBException, FileNotFoundException {
JAXBContext jaxbContext = JAXBContext.newInstance("com.sample");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
JAXBElement<?> unmarshalledObject = (JAXBElement<?>) unmarshaller.unmarshal(new FileInputStream("Encounter.xml"));
TClaim claim = (TClaim) unmarshalledObject.getValue();
return claim;
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("setBaseECN.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
----Rule file setBaseECN.drl----
rule "testing claim rule"
when
Claim();
then
System.out.println("..........Executing.......claim...rule.");//not working
end
rule "testing message rule"
when
Message()
then
System.out.println("........Executing......message rule");//working
end
12 years
Problem Itegrating Spring 3.2 with Drools 6.0.0
by milen igrachev
Hello,
I experience a problem autowiring my KieSession object into my Controller field in Spring.
I read the Spring integration configuration part of Drools documentation and edited my Spring
configuration as adviced. However on deploying I receive one and the same well know exception:
"org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.kie.api.runtime.KieSession] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {(a)org.springframework.beans.factory.annotation.Autowired(required=true), @org.kie.api.cdi.KSession(name=, value=ksession-rules)}"
My application's web.xml defines my spring configuration entries as follows:
mvc-dispatcher
......
mvc-dispatcher
/
contextConfigLocation
/WEB-INF/beans.xml,
/WEB-INF/security.xml,
/WEB-INF/entityManager.xml
As guided by Drools documentation I entered the following Drools configuration in my spring configuration (I try to put the bean both in mvc-dispatcher-servlet.xml configuration and in beans.xml the result is the same).
I have this package
"com.my.sample.drools.rulespackage"
with
a simple and tested rule in it.
In my Controller class I am trying to autowire the KieSession bean to a field as follows:
@Controller
@RequestMapping(value = "/")
public class BaseController extends AbstractController {
private static final Logger log = Logger.getLogger(BaseController.class);
@Autowired
@KSession("ksession-rules")
KieSession mySession;
.............
}
I tryed with @Inject instead of spring's @Autowire, the result is the same.
I am using the following Drools dependencies with their versions:
drools-core - 6.0.0.FINAL; drools-compiler - 6.0.0.FINAL; kie-spring - 6.0.0.FINAL; (I am trying to keep it simple as my first integration try.)
The spring version that I am using is 3.2.4.RELEASE.
I debugged
KModuleBeanFactoryPostProcessor
and I can clearly see that an object tree with
KieModuleModelImpl,
KieBaseModelImpl,
KieSessionModelImpl,
with the corresponding details that I entered in the configuration above (packages, name, type, etc.) is created!. However it seems that a KieSession bean is not registered
spring's container.
What I do wrong? Can anyone please help?
Thanks in advance!
Best Regards,
Milen
12 years
Is OptaPlanner the right tool for the job?
by Andrzej Raczkowski
Hello all OptaPlanner geeks! :)
This is my first post on this list. I would be very grateful if somebody
could give me any advice in this matter (details below).
We need to plan the schedule for repair units consisting of few people with
some particular skills and equipment.
What we know / What the Client has:
1. tasks - different tasks have different attributes like:
a) priority
b) time needed to fix a problem
c) number of employees needed
d) employees' skills
i) destination coordinates of the task to perform (we can use GIS to get
road costs)
2. established number of employees working according to work schedule and
having particular skills
3. established number of vehicles and equipment
What we want - to be able to plan tasks with the assumption that a good
schedule:
1. will 'keep in mind' all limitations (number of employees and equipment)
2. will plan all tasks in the shortest possible amount of time.
We want to optimize time that it takes to perform all tasks, and time would
be the only flexible feature here.
Is OptaPlanner the right tool to this kind of problems?
Thank you and have a nice day
Andrzej
12 years
User Security with guvnor 5.4 and Tomcat 6.0.36
by thecaptn
Hi,
I have searched extensively for any answers, but have obviously not been
looking in the right places.
Tomcat is my app server: it should define the users. This is no problem:
since it is a small application we want to define our users in
tomcat-users.xml, using the UserDatabaseRealm (in preference to
MemoryRealm). JAAS or other options are overkill for us.
Now, what should I do on the guvnor side? I understand I should be looking
at the WEB-INF/beans.xml config file. I can't find much documentation on the
contents of this file in general, and nothing specific that seems to help
me. A lot of the advice out there seems JBoss AS specific or precedes the
move in 5.4 to beans.xml.
But, I understand that tomcat in this setting is not supplying a JAAS
context, which seemed to be the most likely option.
Do I need to implement a version of
org.drools.guvnor.server.security.DemoAuthenticator?
Is that our only option?
Hasn't someone done this before?
What would you do in this situation?
Any assistance would be greatly appreciated.
Thanks, Pete
--
View this message in context: http://drools.46999.n3.nabble.com/User-Security-with-guvnor-5-4-and-Tomca...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
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.
12 years
[MVEL BUG] MVEL Parsing error
by alexandrebhr
Hi,
I found a MVEL bug :
When I want to compile a specific expression with MVEL, a
NullPointerException is thrown.
Test Case (Java Language) :
String expression = "5 + 1/10 * (VAR - 5)";
MVEL.compileExpression(expression);
When I launch this test, I get an error :
java.lang.NullPointerException
at
org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:47)
at org.mvel2.MVEL.eval(MVEL.java:408)
at org.mvel2.ast.Substatement.getReducedValue(Substatement.java:48)
at
org.mvel2.compiler.AbstractParser.arithmeticFunctionReduction(AbstractParser.java:2479)
at
org.mvel2.compiler.ExpressionCompiler.compileReduce(ExpressionCompiler.java:318)
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:172)
at
org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at org.mvel2.MVEL.compileExpression(MVEL.java:820)
at org.mvel2.MVEL.compileExpression(MVEL.java:723)
...
I get this error in rare case with this syntax but with different one, it
works.
Expressions which work :
5 + 1+10 * (VAR - 5)
5 + 1-10 * (VAR - 5)
5 + (1/10) * (VAR - 5)
5 + (VAR - 5) * 1/10
Expressions which not work :
5 + 1/10 * (VAR - 5)
5 + 1*10 * (VAR - 5)
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-BUG-MVEL-Parsing-error-tp4028939.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years