Possible bug using from and or
by Evert Penninckx
Hi
This little rule won't compile:
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.addresses
(Address() or Address())
then
# do stuff
end
BuildError: Unable to build expression for 'from' : [Error: Failed to
compile: 1 compilation error(s):
- (1,7) unqualified type in strict mode for: $person]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0] '$person.addresses(Address() or Address())'
BuildError: Unable to determine the used declarations.
java.lang.Class cannot be cast to org.mvel2.util.MethodStub
This does work
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.addresses
Address() or Address()
then
# do stuff
end
And this also:
rule "Test from and or"
dialect "mvel"
when
$person : Person()
Address( ) from $person.getAddresses()
(Address() or Address())
then
# do stuff
end
Can anybody confirm this as a bug?
Tnx
Evert
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Possible-bug-using-fr...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Doubt in converting .brl to .drl format in java
by Kamal Thiyagarajan
Hello,
I had try to convert .brl file to .drl format using java code i got an error
in conversion. my java code is
String fileName = "c:/Sampleguide.brl";
File file = new File(fileName);
//System.out.println("hello");
String content = FileUtils.readFileToString(file);
System.out.println(content);
BRXMLPersistence read = (BRXMLPersistence)
BRXMLPersistence.getInstance();
BRDRLPersistence write = (BRDRLPersistence)
BRDRLPersistence.getInstance();
//BRDRLPersistence.getInstance();
String outputDRL = write.marshal(read.unmarshal(content));
System.out.println(outputDRL);
I got error like this
com.thoughtworks.xstream.converters.ConversionException: metadataList :
metadataList : metadataList : metadataList
---- Debugging information ----
message : metadataList : metadataList
cause-exception :
com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : metadataList : metadataList
class : org.drools.brms.client.modeldriven.brl.RuleModel
required-type : org.drools.brms.client.modeldriven.brl.RuleModel
path : /rule/metadataList
-------------------------------
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:89)
at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)
at
com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:845)
at
org.drools.brms.server.util.BRXMLPersistence.unmarshal(BRXMLPersistence.java:91)
at com.sample.DroolsTest.main(DroolsTest.java:30)
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException:
metadataList : metadataList
at
com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at
com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:52)
at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:347)
at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:208)
at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
... 11 more
Thanks&Regards,
*Kamal.t*
Associate Software Engineer
Sybrant Technologies Pvt. Ltd.
'Shriram The Gateway (SEZ)', Block A1,
3rd Floor, 16 GST Road, Perungalathur,
Chennai - 600 063, India
India | USA | Germany | China
Email :kamal.t@sybrant.com <swetha.p(a)sybrant.com>
Mobile : +91 9944011715
Phone : 044 4294 7511
Skype :kamalkamal5796
13 years, 10 months
looping over list
by odelyaholiday
I have a list of officers:
public static final Map<String, List<Officer>> officersPerGenre = new
HashMap<String, List<Officer>>();
Where the Officer with:
String name;
Integer mininumCost;
Integer maximumCost;
in officersPerGenre I fill for each genre list of officers.
In my drools:
rule "Select Officer"
ruleflow-group "select_officer"
no-loop true
salience 20
when
$processInstance: WorkflowProcessInstance()
$requestData: RequestData();
then
System.out.println("Hey!");
List officersWithGenre = (List)officers.get($requestData.getGenre());
end
Now I need to shrink the officersWithGenre only to officers that
$requestData.cost is between their mininumCost and maximum cost.
How do I write it in drools? In java i will simply iterate over the
collection.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/looping-over-list-tp2...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Large amount of rules deployment
by Benson Fung
Hi,
I have 9000 rules in a DRL file and would like to import to BRMS. Please
suggest a way to import it efficiently.
Thanks
Benson
13 years, 10 months
org.hibernate.StaleObjectStateException on aborting process
by Massudi
Running JBoss 6.0. Somewhere inside running JTA transaction:
@Override
public void stopProcess(PropertyObject object)
{
StatefulKnowledgeSession ksession =
ProcessHelper.loadSession(Registry.get().getMainProcessName(),
object.getKnowledgeSessionId());
ksession.abortProcessInstance(object.getProcessInstanceId());
}
aborting process leads to org.hibernate.StaleObjectStateException:
WARN [com.arjuna.ats.arjuna] ARJUNA-12125
TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple<
0:ffffc0a801e8:126a:4d3fd283:3d,
org.hibernate.transaction.synchronization.HibernateSynchronizationImpl@1fa8761
>: javax.persistence.OptimisticLockException:
org.hibernate.StaleObjectStateException: Row was updated or deleted by
another transaction (or unsaved-value mapping was incorrect):
[org.drools.persistence.session.SessionInfo#13]
at
org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1243)
[:3.6.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1166)
[:3.6.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
[:3.6.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
[:3.6.0.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1067)
[:3.6.0.Final]
at
org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122)
[:3.6.0.Final]
at
org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)
[:3.6.0.Final]
at
com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:97)
[:6.0.0.20101110-CR1]
at
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:274)
[:6.0.0.20101110-CR1]
at
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:94)
[:6.0.0.20101110-CR1]
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159)
[:6.0.0.20101110-CR1]
at
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1156)
[:6.0.0.20101110-CR1]
at
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119)
[:6.0.0.20101110-CR1]
at
com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
[:6.0.0.20101110-CR1]
at
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162)
[:6.0.0.20101110-CR1]
at
com.infotech.web.util.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:53)
[:]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
[:6.0.0.20101110-CR1]
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
[:6.0.0.20101110-CR1]
at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
[:1.1.0.Final]
at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
[:1.1.0.Final]
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
[:6.0.0.20101110-CR1]
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[:6.0.0.20101110-CR1]
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[:6.0.0.20101110-CR1]
at
org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
[:6.0.0.20101110-CR1]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
[:6.0.0.20101110-CR1]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[:6.0.0.20101110-CR1]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
[:6.0.0.20101110-CR1]
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
[:6.0.0.20101110-CR1]
at java.lang.Thread.run(Unknown Source) [:1.6.0_22]
Caused by: org.hibernate.StaleObjectStateException: Row was updated or
deleted by another transaction (or unsaved-value mapping was incorrect):
[org.drools.persistence.session.SessionInfo#13]
at
org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1932)
[:3.6.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2576)
[:3.6.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2476)
[:3.6.0.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2803)
[:3.6.0.Final]
at
org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113)
[:3.6.0.Final]
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
[:3.6.0.Final]
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
[:3.6.0.Final]
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
[:3.6.0.Final]
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
[:3.6.0.Final]
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
[:3.6.0.Final]
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
[:3.6.0.Final]
at
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
[:3.6.0.Final]
at
org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)
[:3.6.0.Final]
... 29 more
Problem arises only when trying to abort process. Other things are
working: process executes, workItems are created etc.
What is the other transaction that updates the SessionInfo object? Why
doesn't ksession.abortProcessInstance(...) run in my current transaction?
Following helper methods are used in the code above:
public static StatefulKnowledgeSession loadSession(String process, int
sessionId)
{
try
{
KnowledgeBuilder kbuilder = getKnowledgeBuilder(process);
Environment env = buildEnvironment();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession =
JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null,
env);
registerWorkItemHandlers(ksession);
return ksession;
}
catch (Exception ex) {...}
}
public static KnowledgeBuilder getKnowledgeBuilder(String process)
{
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(process,
ProcessHelper.class), ResourceType.DRF);
if (kbuilder.hasErrors())
{
for (KnowledgeBuilderError error : kbuilder.getErrors())
{
System.out.println(error);
}
throw new IllegalStateException("Error building kbase!");
}
return kbuilder;
}
public static Environment buildEnvironment() throws NamingException
{
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
return env;
}
13 years, 10 months
Not able to achieve combination of NOT & FROM keyword in a brl through Guvnor
by Harshit Bapna
Hello All,
>From the Expert documentation, I am trying to create the rule(below) in
Guvnor
Guvnor Version : 5.1.1
I am not able to achieve the combination of NOT & FROM in a business rule.
*Is it possible to create the below drl rule into a brl rule in Guvnor?*
------------------------------------------------------------------------------------
package org.drools;
rule "Avoid NPE on wrong syntax"
when
*not*( Cheese( ( type == "stilton" && price == 10 ) || ( type == "brie"
&& price == 15 ) ) *from* $cheeseList )
then
System.out.println("OK");
end
------------------------------------------------------------------------------------
13 years, 10 months
Implementing multiple 'and' 'or' conditions
by Ayush
Hi, I've to write a rule in which there are multiple and, or conditions. Like
(
MyEvent(prop = "1")
or
MyEvent(prop = "2")
or
MyEvent(prop = "3")
)
and
MyEvent(prop = "4")
and
MyEvent(prop = "5")
I tried to implement it like
$E: (
MyEvent(prop = "1")
or
MyEvent(prop = "2")
or
MyEvent(prop = "3")
)
MyEvent(prop = "4")
MyEvent(prop = "5")
but it's throwing error expecting ')'.
Can anyone please help me writting this rule?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-multiple...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Drools Flow - Python how?
by Jins Thomas
Hi all,
I recently joined this group. We are using Drools flow to create some
workflows to automate some of the tasks. Would like to have some advice on
how we can use python instead of Java or Mvel. Do we have some good
tutorials/articles on this. In Drools flow we have nodes like 'Script' ,
'Converge', 'Diverge' etc. Currently i could we can either use MVEL or Java,
but from the internet we are getting a feel like we can use even python for
this.
Would some body please advice
Br
Jins Thomas
13 years, 10 months
Real World Examples Wanted!!!!!!
by Mark Proctor
We often get complaints about not enough real world examples in Drools.
We have a large community now, so surely a few of you must be able to
write up examples based on your work? So please, please, please, please
take the time to help us here.
Thanks
Mark
13 years, 10 months