UTF8 characters corrupted when embedded in DRL files
by crafferty
Drools, version, 5.0.1 running on Java 1.6.0_12
Our application creates rules in DRL files, the rules contain non-Latin
characters, here is an example rule:
//****************************************************************************
//
// TRIGGER_ RULE: Detect Dual Receiver Failure
//
//****************************************************************************
rule TRIGGER_Detect_Dual_Receiver_Failure_43296731577724
no-loop true
salience 0
when
// When a Child Group exists with:
child0:ChildGroup(
// base class is "com.sidonis.vp.dtvexample.BroadcastEquipment"
baseClass == "com.sidonis.vp.dtvexample.BroadcastEquipment",
// parent base class is "com.sidonis.vp.dtvexample.BroadcastEquipment"
parentBaseClass == "com.sidonis.vp.dtvexample.BroadcastEquipment",
// parent sub class starts with "DualReceiver"
child0_parentSubClass:parentSubClass ->
(child0_parentSubClass.startsWith( "DualReceiver" )),
// failed count is 2
failed == 2
)
then
StatisticsSystemRuleFunctions.incrementTrigRuleCount();
StatePropagationFunctions.trigForceParentFailedViaChild(
"TRIGGER_Detect_Dual_Receiver_Failure_43296731577724",
"あえいおう",
child0,
true );
end
When the static method trigForceParentFailedViaChild is invoke as a
consequence of fullfilling the rule conditions, the non-latin text in the
second argument is corrupted when output to a file.
The DRL is loaded as a resource by our application and passed to Drools
thus:
try {
final FileInputStream fis = new FileInputStream(drlFile);
fr = new InputStreamReader(fis, textEncoding);
} catch (FileNotFoundException e1) {
log.error("Cannot open DRL file: " + drlFile.getName());
return null;
} catch (UnsupportedEncodingException e) {
log.error("Text encoding configuration problem " + textEncoding);
return null;
}
// Load DRL file into PackageBuilder and create Package
Resource resource = ResourceFactory.newReaderResource(fr, textEncoding);
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBuilderConfiguration);
knowledgeBuilder.add(resource, ResourceType.DRL);
Note, 'textEncoding' is loaded from a properties file by the application and
is set to "UTF8". The system property "file.encoding" for the
application's JVM is also set to "UTF8".
We have also tried using the ResourceFactory's newFileResource passing it
the drlFile Object, but to no avail, the result is the same.
So we have debugged the Drools 5.0.1 source and discovered that when the
stream representing the DRL is wrapped by the ANTLRInputStream, line 320,
org.drools.compiler.DrlParser (drools-compiler project) the encoding of the
input stream is not passed on to the ANTLRInputStream that is used to wrap
it. If we modify the Drools code to use the overloaded ANTLRInputStream
constructor that accepts the stream encoding then the non-Latin text is
passed correctly to our method. We've also checked the code on the head
of the repository and it is same. Although this seems like a bug, I want to
make sure we're not doing something wrong first.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/UTF8-characters-corru...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
Re: [rules-users] How to work with org.drools.repository
by wilsonywx
Because I only needed a small subset of the Drools functionality (i.e. just
plain rules without salience) I just made up a simple xml schema to store
the rule. I've posted some other related questions about the .brl format
(which is the xml format Guvnor uses to store rules) but haven't gotten many
useful replies. I think if you project is not overly complex it's probably
better off just making up your own storage scheme than trying to reverse
engineer the classes in Drools (fyi they use XStream to serialize and
deserialize their classes into xml). Hope that helps.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-work-with-org-...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
API of Rule: no access to interesting attributes
by Wolfgang Laun
Whereas org.drools.rule.Rule contains a wealth of interesting fields,
the stable API org.drools.definition.rule.Rule restricts us to
getName() and getPackageName() (and some MetaData - whatever that
might be).
I'd opt for an extension of this interface, providing access to
agendaGroup, activationGroup and ruleFlowGroup. I see no obvious
reason why these user defined attributes should remain hidden.
These rule attributes would provide a good opportunity for writing
more sophisticated event loggers, letting you specify rule filters by
natural rule groupings.
Cheers
-W
14 years, 3 months
DATE-EXPIRES in rule table ?
by Arun Kumar
Hi,
Am using a spreadsheet based rules. Is it possible to set the attribute
like "date-expires", "enabled"
in the spread sheet ?
*
*
*Regards,*
*Arun*
*
*
14 years, 3 months
IllegalStateException : DroolsJPAManager while calling session.dispose() method.
by drooRam
Hi
I have got the following exception when i tried to call ksession.dispose()
method : Does anyone have faced this problem before??
java.lang.IllegalStateException: No value for key
[org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@173898a]
bound to thread [http-8080-1]
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.IllegalStateException: No value for key
[org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@173898a]
bound to thread [http-8080-1]
org.springframework.transaction.support.TransactionSynchronizationManager.unbindResource(TransactionSynchronizationManager.java:199)
org.drools.container.spring.beans.persistence.DroolsSpringJpaManager.dispose(DroolsSpringJpaManager.java:75)
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:296)
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.dispose(CommandBasedStatefulKnowledgeSession.java:181)
edu.rascalflow.service.impl.LoanApprovalServiceImpl.requestLoan(LoanApprovalServiceImpl.java:59)
edu.rascalflow.service.impl.BankingServiceImpl.requestLoan(BankingServiceImpl.java:62)
edu.rascalflow.controller.LoanRequestFormController.onSubmit(LoanRequestFormController.java:31)
org.springframework.web.servlet.mvc.SimpleFormController.onSubmit(SimpleFormController.java:387)
org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:272)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:268)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/IllegalStateException...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
MinaTaskClientHandler Reference Object
by drooRam
How can I obtain reference to MinaTaskClientHandler through drools config
tags? I mean .. we have <drools:kbase> tag for KnowledgeBase...similarly, do
we have anything for MinaTaskClientHandler...
I basically need to call the methods, TaskClient.claim, TaskClient.complete
etc thro MinaTaskClientHandler.getClient().
Please let me know how can i obtain MinaTaskClientHandler thro config or
snippet ?
-drooRam
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/MinaTaskClientHandler...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
creating .pkg from .drl
by Amit Kumar
Hi Folks,
I am trying to create a .pkg file (for probably faster loading) from a .drl
file
Does anybody has a code snippet which I can use. Am unable to find it in
javadocs.
Thanks
Amit
14 years, 3 months
Bug: ActivationCreatedEvent - Activation: InitialFactImpl in Object set
by Wolfgang Laun
Given this rule
rule "show no gaps"
when
not Gap()
then
System.out.println( "No gaps!" );
end
the ActivationCreatedEvent references an Activation, where the list of
fact handles (getFactHandles) contains one element, but its Object is null:
Fact null @0:0:27032609:1306428912:0:DEFAULT
But the list of objects (getObjects) returns a list where there *is* an
object:
Object (org.drools.reteoo.InitialFactImpl):
org.drools.reteoo.InitialFactImpl@4dde85f0
I think that this should be changed; neither a fact handle nor an object
should
be returned if there are no user objects participating in the activation.
Cheers
Wolfgang
14 years, 3 months
Drools Flow - Dependency Injection
by jawa
Hi,
I am writing a custom workItem handler in drools flow and want to access my
Stateless session bean from there. I will deploy my drools project to JBoss
so can I use @EJB annotation to get my stateless bean injected by jboss with
in WorkItemHandler?
Secondly I'll call my flow from with in a Stateless session bean. Is it ok?
Or does drools use multi threading? As multi threading is not recommended to
be used in EJBs?
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Dependenc...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months