ksession persistence (from docs) - not getting it to work
by amarok
I try to persist a knowledge session using the example code from Drools
5.5.0-Final Documentation. And I am stuck with following exception:
javax.persistence.PersistenceException: [PersistenceUnit:
org.drools.persistence.jpa] Unable to build EntityManagerFactory
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
[...]
Caused by: org.hibernate.service.jndi.JndiException: Error parsing JNDI name
[jdbc/BitronixJTADataSource]
at
org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:92)
at
org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:63)
[...]
Caused by: javax.naming.OperationNotSupportedException
at bitronix.tm.jndi.BitronixContext.getNameParser(BitronixContext.java:147)
at javax.naming.InitialContext.getNameParser(InitialContext.java:480)
at
org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:86)
... 42 more
Probably I did some configuration mistake. This is my setup:
1) I added following dependencies (via maven)
drools-persistence-jpa, btm (bitronix), h2 (database),
hibernate-entitymanager
2) I created a hibernate.cfg.xml, persistence.xml and jndi.properties file
(I put the jndi.properties file in resources/META-INF ( is this correct/
related to the error ?))
3) I made all my fact classes serializable
4) I added this code:
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName( "jdbc/BitronixJTADataSource" );
ds.setClassName( "org.h2.jdbcx.JdbcDataSource" );
ds.setMaxPoolSize( 3 );
ds.setAllowLocalTransactions( true );
ds.getDriverProperties().put( "user", "sa" );
ds.getDriverProperties().put( "password", "sasa" );
ds.getDriverProperties().put( "URL", "jdbc:h2:mem:mydb" );
ds.init();
org.drools.runtime.Environment env =
KnowledgeBaseFactory.newEnvironment();
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager());
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
This is my Hibernate config:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>
<property name="connection.url">jdbc:h2:file:db/drools</property>
</session-factory>
</hibernate-configuration>
This is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
<persistence-unit name="org.drools.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/BitronixJTADataSource</jta-data-source>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
jndi.properties:
java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
--
View this message in context: http://drools.46999.n3.nabble.com/ksession-persistence-from-docs-not-gett...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Not able to fetch values from a list in Guvnor web based decision table
by ashish6276
Hi All,
I have a request with /market/ which is a list of /market info/ something
like this :
*<complexType name="RuleRequest">
<sequence>
<element name="Market" type="tns:MarketInfo" maxOccurs="unbounded" />
</sequence>
</complexType>
<complexType name="MarketInfo">
<sequence>
<element name="region" type="String">
</element>
<element name="country" type="String">
</element>
</sequence>
</complexType>*
While writing DRL like this I am able to fire the rules:
*when
hotelReq : HotelRequest ($market : market != null )
MarketInfo( region == "NA") from $market
then
System.out.println("Done");
end*
But am not able to achieve the same thing in web guided editor in
Guvnor(Decision table).
I came close enough to write the below in web based editor but could not
succeed in firing the rules.
*when
hotelRequest : HotelRequest( $market : market != null )
marketInfo : MarketInfo( region == "NA" ) from entry-point
"$market"
then*
Any help will be appreciated.
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Not-able-to-fetch-values-from-a-list-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
error while firing rules from drools guvnor web guided editor.
by ashish6276
Hi
I am using drools guvnor 5.2.1. I am exploring drools decision table
option on this. When i am trying to fire the rules from my java code It
gives me following error.
[9/27/13 11:47:29:499 IST] 00000028 SystemOut O Before firing
[9/27/13 11:47:32:226 IST] 00000028 FireRuleTask E
com.aexp.travel.rules.service.FireRuleTask fireRule Error in executing rules
:
com.aexp.travel.rules.RuleEngineException:
Error executing rules:
at
com.aexp.travel.rules.drools.DroolsRuleExecutor.executeRules(DroolsRuleExecutor.java:45)
at
com.aexp.travel.rules.service.FireRuleTask.fireRule(FireRuleTask.java:55)
at
com.aexp.travel.rules.service.RuleEngineService.fireOffGDSInclusionRule(RuleEngineService.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at
com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:150)
at
com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:261)
at
com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:314)
at
com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:608)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:259)
at
com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:207)
at
com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at
com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at
com.sun.xml.ws.transport.http.servlet.WSSpringServlet.doPost(WSSpringServlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
Caused by: org.drools.runtime.rule.ConsequenceException: rule: Row 1
RegionBasedRules
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:737)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:701)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at
com.aexp.travel.rules.drools.DroolsRuleExecutor.executeRules(DroolsRuleExecutor.java:42)
... 44 more
Caused by: [Error: null pointer or function not found: setErrorRemark]
[Near : {... HotelREs.setErrorRemark( "welc ....}]
^
[Line: 1, Column: 1]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:996)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:368)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
at org.mvel2.ast.ASTNode.optimize(ASTNode.java:154)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:110)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:122)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:115)
at org.mvel2.MVEL.executeExpression(MVEL.java:928)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:105)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 50 more
[9/27/13 11:47:32:320 IST] 00000028 SystemOut O After Firing
I am not geting reason for this error.
--
View this message in context: http://drools.46999.n3.nabble.com/error-while-firing-rules-from-drools-gu...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Manners Benchmark broken!?
by ru
Hello drools-community,
I tried to run Manners Benchmark test and got this error message:
assign first seat : [Seating id=1 , pid=1 , pathDone=true , leftSeat=1,
leftGuestName=128, rightSeat=1, rightGuestName=128] : [Path id=1, seat=1,
guest=128]
find seating : [Seating id=2 , pid=1 , pathDone=false , leftSeat=1,
leftGuestName=128, rightSeat=2, rightGuestName=123] : [Path id=2, seat=2,
guest=123] : {Chosen id=1, name=123, hobbies=h2}
find seating : [Seating id=3 , pid=1 , pathDone=false , leftSeat=1,
leftGuestName=128, rightSeat=2, rightGuestName=122] : [Path id=3, seat=2,
guest=122] : {Chosen id=1, name=122, hobbies=h2}
Exception in thread "AWT-EventQueue-0" Exception executing consequence for
rule "pathDone" in org.drools.benchmark.manners:
java.lang.ClassCastException: org.drools.benchmark.manners.Seating cannot be
cast to org.drools.benchmark.manners.Context
at
org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1026)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:128)
at
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:68)
at
org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:936)
at
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1183)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:936)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:910)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:233)
at
org.drools.benchmark.manners.MannersBenchmark.main(MannersBenchmark.java:94)
at
org.drools.benchmark.DroolsBenchmarkExamplesApp$1.actionPerformed(DroolsBenchmarkExamplesApp.java:59)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassCastException:
org.drools.benchmark.manners.Seating cannot be cast to
org.drools.benchmark.manners.Context
at
org.drools.benchmark.manners.Rule_pathDone929756542DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
org.drools.benchmark.manners.Rule_pathDone929756542DefaultConsequenceInvoker.evaluate(Unknown
Source)
at
org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1016)
... 45 more
--
View this message in context: http://drools.46999.n3.nabble.com/Manners-Benchmark-broken-tp4026131.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Fusion 5.5 - Deterministically identifying event insert order?
by dunnlow
I am testing with fusion (5.5) and running into an /intermittent /issue. I
am trying to track transitions between two big events (BEvent) using a
smaller event (SEvents) with the properties I care about. The idea is that
I will maintain many SEvents in memory for the different kinds of BEvents.
My basic steps (partly driven by salience) are:
1) rule a: (salience=100): when a new BEvent is inserted, insert a new
related SEvent
2) rule b: (salience=50): If there are two SEvents for this type of BEvent,
compare them (old vs new) and act accordingly
3) rule c: (salience=0) remove the *old* SEvent (keeping the latest one)
4) rule d: (salience=-50) retract the BEvent
My rule c (above) is:
when $se1 : SEvent(name matches "auto")
$se2 : SEvent(this after $se1, style matches ($se1.style))
then
retract($se1);
end;
I am of course running in stream mode and this USUALLY works, but sometimes
rule c does not get activated - based on the audit log. Also, I have a
DebugWorkingMemoryEventListener configured and I can see that two SEvents DO
exist in working memory which should activate it.
In my test, I have a loop in which I am inserting events. When I add a
brief delay, I have not seen a failure. My guess is that the timestamps on
the two events are the same, thus the "after" is causing the issue.
However, I am unable to test this as the timestamp on the event is not
accessible (from what I have found on this forum).
I saw a suggestion here about using a variable on my SEvent to tell the
difference between a new and old version. I also considered using some sort
of counter bean to order the SEvents (although I believe it would need to be
serialized).
My questions:
1) Do you agree with my assessment? Is it possible in stream mode to have
two events with the same timestamp?
2) what is the BEST way to identify which event was inserted first?
Thanks for any insight!
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Fusion-5-5-Deterministically-identifyin...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Reg : Drools 5.5 Templates : CompoundValueRestrictions
by Barada (Native5)
Hi,
Am trying to model some rules using drools templates.
Currently the data inputs to rule templates are only strings, I need to be able to define a compound value restriction set for the rule i.e if fact attribute is present in a list. (see sample below).
e.g.
template header
dealers
template "my-template"
rule "my-rule"
when
$order : Order(dealer in (@{dealers}))
then
System.out.println("Order is present in dealer"
end
end template
I am trying to compile this template by passing it an Object which has a dealers attribute which is essentially a List<String>. Short of creating a function which sends back a comma separated representation of the list, does the drools compiler provide any option to send a list.
~ Barry
12 years, 5 months
NullPointer while deleting a rule since 6.0.0 upgrade
by Nicolas de Dreuille
Hey,
I recently upgraded drools from 5.5.0.Final to 6.0.0.CR3
A rule deletion that used to work now throws a NullPointerException.
A fact has to be inserted for the Exception to be thrown.
Here is the log :
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl -
> KieModule was added:MemoryKieModule[
> ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
> objectInserted org.test.ProximityTest$Track@2c6c5356
> [Rule name=ProxRule, agendaGroup=MAIN, salience=0, no-loop=false]
> Exception in thread "main" java.lang.NullPointerException
> at org.drools.core.phreak.AddRemoveRule.deletePeerLeftTuple(
> AddRemoveRule.java:687)
> at org.drools.core.phreak.AddRemoveRule.followPeer(AddRemoveRule.java:659)
> at org.drools.core.phreak.AddRemoveRule.processLeftTuples(
> AddRemoveRule.java:620)
> at org.drools.core.phreak.AddRemoveRule.flushStagedTuples(
> AddRemoveRule.java:243)
> at org.drools.core.phreak.AddRemoveRule.removeRule(AddRemoveRule.java:134)
> at org.drools.core.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:172)
> at org.drools.core.reteoo.ReteooRuleBase.removeRule(
> ReteooRuleBase.java:1402)
> at org.drools.core.reteoo.ReteooRuleBase.removeRule(
> ReteooRuleBase.java:1393)
> at org.drools.core.reteoo.ReteooRuleBase.removeRule(
> ReteooRuleBase.java:1371)
> at org.drools.core.impl.KnowledgeBaseImpl.removeRule(
> KnowledgeBaseImpl.java:210)
> at org.test.ProximityTest.CreateKieRuleOnTheFly(ProximityTest.java:72)
> at org.test.ProximityTest.main(ProximityTest.java:102)
Here is a code sample that reproduces the issue :
package org.test;
> import java.util.ArrayList;
> import java.util.List;
> import org.kie.api.KieBase;
> import org.kie.api.KieServices;
> import org.kie.api.builder.KieBuilder;
> import org.kie.api.builder.KieFileSystem;
> import org.kie.api.builder.KieRepository;
> import org.kie.api.builder.Message.Level;
> import org.kie.api.definition.rule.Rule;
> import org.kie.api.event.rule.ObjectDeletedEvent;
> import org.kie.api.event.rule.ObjectInsertedEvent;
> import org.kie.api.event.rule.ObjectUpdatedEvent;
> import org.kie.api.event.rule.WorkingMemoryEventListener;
> import org.kie.api.runtime.KieContainer;
> import org.kie.api.runtime.KieSession;
> public class ProximityTest {
> private void CreateKieRuleOnTheFly() {
> KieServices ks = KieServices.Factory.get();
> KieRepository kr = ks.getRepository();
> KieFileSystem kfs = ks.newKieFileSystem();
> // Can't understand why this does not work without the
> // src/main/resources part
> kfs.write("src/main/resources/org/test/rule.drl", getRule());
> KieBuilder kb = ks.newKieBuilder(kfs);
> kb.buildAll();
> if (kb.getResults().hasMessages(Level.ERROR)) {
> throw new RuntimeException("Build Errors:\n"
> + kb.getResults().toString());
> }
> KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
> KieSession kSession = kContainer.newKieSession();
> kSession.addEventListener(new WorkingMemoryEventListener() {
> @Override
> public void objectUpdated(ObjectUpdatedEvent oue) {
> System.out.println("objectUpdated " + oue.getObject());
> }
> @Override
> public void objectInserted(ObjectInsertedEvent oi) {
> System.out.println("objectInserted " + oi.getObject());
> }
> @Override
> public void objectDeleted(ObjectDeletedEvent ore) {
> System.out.println("objectRetracted " + ore.getOldObject());
> }
> });
> // CloseTrack closeTrack = new CloseTrack(100,200);
> Track track = new Track(100);
> // track.getCloseTracks().add(closeTrack);
> // kSession.insert(track);
> // track = new Track(200);
> kSession.insert(track);
> kSession.fireAllRules();
> KieBase kieBase = kSession.getKieBase();
> Rule rule = kieBase.getRule("org.test", "ProxRule");
> System.out.println(rule);
> kieBase.removeRule("org.test", "ProxRule");
> System.out.println("done");
> }
> private static String getRule() {
> String s = ""
> + "package org.test"
> + "\nimport org.test.ProximityTest.*"
> + "\nrule \"ProxRule\""
> + "\nwhen "
> + "\n $track:Track("
> + "\n )"
> + "\n $track1:Track("
> + "\n )"
> + "\n exists (CloseTrack(closeTrackId==$track1.trackId) from
> $track.closeTracks)"
> + "\nthen " + "\nSystem.out.println(\"proximity asserted\"); "
> + "\nend";
> return s;
> }
> /** test main */
> public static void main(String[] args) {
> (new ProximityTest()).CreateKieRuleOnTheFly();
> }
> public class CloseTrack {
> private int trackId;
> private int closeTrackId;
> public CloseTrack(int i, int j) {
> this.trackId = i;
> this.closeTrackId = j;
> }
> public int getTrackId() {
> return trackId;
> }
> public void setTrackId(int trackId) {
> this.trackId = trackId;
> }
> public int getCloseTrackId() {
> return closeTrackId;
> }
> public void setCloseTrackId(int closeTrackId) {
> this.closeTrackId = closeTrackId;
> }
> }
> public class Track {
> private int trackId;
> private List<CloseTrack> closeTracks = new ArrayList<CloseTrack>();
> public Track(int i) {
> this.trackId = i;
> }
> public List<CloseTrack> getCloseTracks() {
> return closeTracks;
> }
> public int getTrackId() {
> return trackId;
> }
> public void setTrackId(int id) {
> this.trackId = id;
> }
> public void setCloseTracks(List<CloseTrack> closeTracks) {
> this.closeTracks = closeTracks;
> }
> }
> }
>
>
Hope this helps.
Thanks.
--
N.
12 years, 5 months
Does Guvnor limits the number of unsuccessful Login Attempts ?
by Zahid Ahmed
Hi,
I want to know that is there any configuration in Guvnor to limit the number of unsuccessful login attempts. This is required as I want to prevent Brute Force attack on my production Guvnor server.
Environment:
1. Drools-Guvnor 5.5.0-Final
2. Jboss EAP 6.1.0
Thanks and Best Regards,
Zahid Ahmed
12 years, 5 months
JBPM 6 Loop back.
by Naman Shah
I got a work flow, which has a loop back.
?node : yes--> do x /?node:no -->repeat previous
yes works and n o dont
and also i cant find entires into process instance data ,using which i can
see the process status.
I am using jbpm beta 6.05
Please find the attached BPMN for the same.
Node name where loop back dont work : inclusiveGateway id="_49"
and others too.
-----------------------------------------------------------------------------
12 years, 5 months