Creating objects in WHEN clause
by David Boaz
In my application, we often compare the fact's field values against a known
object. For example:
WHEN person(height> new Quantity(2, "m")) // the height is greater than 2
meters.
will DROOLS create a "singleton" Quantity object, or will it create one
object for each fact evaluation?
We consider using anoter approach, using GLOBALS. Then, the Quantity object
will be created applicatively, and passed by the API to the engine.
something like:
GLOBAL Quantity 2meters
WHEN person(height > 2meters)
But this approach is combersom, because the rule author has to define part
of the information in the calling application, and part in the rule.
Do you have a good practice how to handle these situations?
Thanks, David
--
View this message in context: http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 9 months
Drools-Smooks Data Loader
by Dave Macpherson
I'm trying to use Smooks to populate my Drools internal data model as per the blog posting at http://blog.athico.com/2008/07/drools-smooks-data-loader.html, but it's not quite working out for me.
In that posting, there is the following line of code:
DroolsSmooks loader = new DroolsSmooks( session, smooks, conf );
I believe this line is a typo (there is no class that I can find called "DroolsSmooks", but I'm not sure what it should be. I've found a test case online that refers to a class called "DroolsSmooksStatelessSession", but that doesn't resolve the reference either.
Does anyone have a sample program that uses the Smooks data loader that I can follow and get working?
Regards,
Dave
15 years, 9 months
NPE in JavaDialectConfiguration
by cyclemenow
I am getting a NullPointerException while trying to call:
RuleAgent ruleAgent = RuleAgent.newRuleAgent(prop);
The exception looks like this:
13:15:08,754 ERROR [STDERR] org.drools.RuntimeDroolsException: Unable to
load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:160)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:146)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:121)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:98)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:124)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:86)
13:15:08,755 ERROR [STDERR] at
org.drools.compiler.SourcePackageProvider.loadPackage(SourcePackageProvider.java:22)
....
13:15:08,766 ERROR [STDERR] Caused by: java.lang.NullPointerException
13:15:08,766 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:89)
13:15:08,766 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:52)
13:15:08,766 ERROR [STDERR] at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:156)
I've made sure the eclipse compiler is definitely in the classpath. I am
able to load that class in my code that calls into drools.
I tracked this down to the line in the code excerpt below from
JavaDialectConfiguration.java that calls getClassLoader(). getClassLoader()
is returning a null.
I was then able to pull some info from the documentation for the Java1.5
getClassLoader() method:
"
Returns the class loader for the class. Some implementations may use null to
represent the bootstrap class loader. This method will return null in such
implementations if this class was loaded by the bootstrap class loader.
If a security manager is present, and the caller's class loader is not null
and the caller's class loader is not the same as or an ancestor of the class
loader for the class whose class loader is requested, then this method calls
the security manager's checkPermission method with a
RuntimePermission("getClassLoader") permission to ensure it's ok to access
the class loader for the class.
If this object represents a primitive type or void, null is returned.
"
It isn't a permissions problem, since that exception isn't thrown. The
error is clearly a null pointer, and stepping through the code after
attaching source also shows that getClassLoader() is returning a null.
Okay, so sometimes it can return null, but how do I get my code to work? Is
there a work around?
I'm running inside of Eclipse Ganymede, using JBoss 4.2.2.GA, Drools 4.0.7
and Java 1.5 running on MacOSX 10.5.
Thank you in advance for your help,
Matthew
-------code excerpt
/**
* Set the compiler to be used when building the rules semantic code
blocks.
* This overrides the default, and even what was set as a system
property.
*/
public void setCompiler(final int compiler) {
// check that the jar for the specified compiler are present
if ( compiler == ECLIPSE ) {
try {
problem line here: getClass().getClassLoader().loadClass(
"org.eclipse.jdt.internal.compiler.Compiler" );
} catch ( ClassNotFoundException e ) {
throw new RuntimeException( "The Eclipse JDT Core jar is not
in the classpath" );
}
} else if ( compiler == JANINO ){
try {
getClass().getClassLoader().loadClass(
"org.codehaus.janino.Parser" );
} catch ( ClassNotFoundException e ) {
throw new RuntimeException( "The Janino jar is not in the
classpath" );
}
}
--
View this message in context: http://www.nabble.com/NPE-in-JavaDialectConfiguration-tp22255233p22255233...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 9 months
Working with compiled packages
by Dan Seaver
Drools 5.0 - I'm planning on using compiled rule packages in our J2EE
production environment. I'm very interested in performance. I assume that
once a package is loaded, it doesn't matter if or how it was compiled, so
the primary concern is in the load time (unless there are other issues I'm
unaware of?)
Any difference between Janino builds versus Eclipse builds?
Which compiler does Guvnor use?
Is the high speed drools serialization being used for building / loading
binary packages?
Any faster technique for loading a binary package than using:
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(ResourceFactory.newInputStreamResource(inStream),
ResourceType.PKG);
if (builder.hasErrors()) {
logger.error(builder.getErrors());
return;
}
rulePackage.Base = KnowledgeBaseFactory.newKnowledgeBase(config);
rulePackage.Base.addKnowledgePackages(builder.getKnowledgePackages());
Thanks in advance for any illumination.
Dan
--
View this message in context: http://www.nabble.com/Working-with-compiled-packages-tp22256636p22256636....
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 9 months
How to set JANINO compiler with Drools5 M5
by Shigeaki Wakizaka
Hi.
I'm kind of new to Drools5.0.
Could I ask you guys how to set JANINO compiler with recent API?
I just run the sample drl with EclipseIDE, which is download from drools
site, and then
the error occured- The Eclipse JDT Core jar is not in the classpath.
So, I just want to know why this happens and how to set another compiler
to retry.
Thanks in advance.
waki
15 years, 9 months
Deploying BRMS on WAS 6.1
by Prachi Patil
Hi,
I am a newbier to Drools.
The BRMS war file is downloaded from
http://download.jboss.org/drools/release/4.0.7.19894.GA/drools-4.0.7-brms.zi
p
The deploy goes fine with no errors on WAS 6.1, but the when I hit the url
http://localhost:9081/drools-jbrms/index.jsp
I get an exception on the console as
[drools-jbrmsEAR#drools-jbrms.war] [/drools-jbrms] [Servlet.LOG]: Exception
while dispatching incoming RPC call: java.lang.NullPointerException
at
org.jboss.seam.remoting.gwt.GWTToSeamAdapter.callWebRemoteMethod(GWTToSeamAd
apter.java:67)
at
org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.processCall(GWTRemoteSer
viceServlet.java:290)
at
org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.doPost(GWTRemoteServiceS
ervlet.java:172)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:9
66)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:9
07)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.
java:145)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServle
tRequest.java:46)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstance
Wrapper.java:190)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.
java:130)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain
.java:87)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterMana
ger.java:701)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterMana
ger.java:646)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.
java:475)
at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrappe
r.java:463)
at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(Ht
tpInboundLink.java:465)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(Ht
tpInboundLink.java:394)
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLRea
dCallback.java:102)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioRea
dCompletionListener.java:152)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java
:213)
at
com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFutu
re.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741
)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
Can anybody please help?
Thanks !
15 years, 9 months
Need advice on asynchronicity
by Chuck Adams
I'm really pretty new to Drools, so bear with me here: I'm trying to
develop some rules for classifying domains as belonging to spammers or
not, based on various test scenarios. Whether to even start these
test scenarios is also controlled by various rules, like occurrences
within a timeframe, so a rule engine seems a natural fit.
So how I might write some rules, off the top of my head:
rule "Lookup A Records"
when
d : Domain( name : n, arecs == null )
not Verdict(domain == d)
then
# lookup_a_records is potentially quite slow
modify( d ) { arecs = lookup_a_records(n) }
end
rule "Spammy host"
when
# isAnyBlacklisted just looks up each record in a DNS zone, very quick
d : Domain( eval( isAnyBlacklisted( d.arecs ) )
not Verdict(domain == d)
then
insert( new Verdict(d, SPAM) )
end
First off, I wouldn't mind being able to refactor those "not
Verdict(domain == d)" conditions out somehow ... agenda groups,
perhaps?
My main problem however is: I want lookup_a_records() to be
asynchronous. It's potentially very slow, and I have hundreds of
other domains to check (I have other scenarios that are slower than
mere DNS lookups, this is just an example). Just to add to the fun,
there can only be so many queries outstanding at any one time, so I'm
looking at using a queue somewhere. I'm thinking I could lose the
modify in the first rule, and make lookup_a_records schedule some
asynchronous call through a ThreadPoolExecutor that modifies the fact
-- hopefully directly, but is a session threadsafe?
Are there any examples I can look at where the RHS modifies and
inserts facts asynchronously?
Chuck
15 years, 9 months
RE: [rules-users] Rules syntax question using hashmap
by Greg Barton
It looks like you want to use null safe bean navigation in mvel 2:
http://mvel.codehaus.org/MVEL+2.0+Property+Navigation
try this:
$f : Fact(details.?END_MATCH == true, details.?WINNER == "AWAY")
I have no idea if it will work, as the null safe ? example is for accessing bean properties, but it's worth a try. It's also MVEL 2.0, so will only work with drools 5.
--- On Thu, 2/26/09, Zevenbergen, Alex <azevenbergen(a)paddypower.com> wrote:
> From: Zevenbergen, Alex <azevenbergen(a)paddypower.com>
> Subject: RE: [rules-users] Rules syntax question using hashmap
> To: greg_barton(a)yahoo.com
> Date: Thursday, February 26, 2009, 11:30 AM
> So that doesn't solve the problem of null params in the
> hashmap?
>
> Do you know if it is possible?
>
> Also is there a good place for rules documentation and
> examples as all
> the examples I can find are fairly simply and
> one-dimensional
>
> -----Original Message-----
> From: Greg Barton [mailto:greg_barton@yahoo.com]
> Sent: 26 February 2009 17:26
> To: Zevenbergen, Alex
> Subject: RE: [rules-users] Rules syntax question using
> hashmap
>
> Ah. That's because drools is expecting
> "details" to be an object type.
> Rule conditions take the following form:
>
> ObjectType(property == value, anotherProperty >
> anotherValue, ...)
>
> So, for a condition like this...
>
> details(fact == $f, name == "END_MATCH", value ==
> true)
>
> ...you would need a class definition like this:
>
> class details {
> Fact fact;
> String name;
> boolean value;
> }
>
> And an object of type "details" would need to be
> inserted into working
> memory for the condition to possibly match.
>
> --- On Thu, 2/26/09, Zevenbergen, Alex
> <azevenbergen(a)paddypower.com>
> wrote:
>
> > From: Zevenbergen, Alex
> <azevenbergen(a)paddypower.com>
> > Subject: RE: [rules-users] Rules syntax question using
> hashmap
> > To: greg_barton(a)yahoo.com, "Rules Users
> List"
> <rules-users(a)lists.jboss.org>
> > Date: Thursday, February 26, 2009, 11:14 AM
> > Hi,
> > I get the following error: Unable to resolve
> ObjectType
> > 'details'
> >
> > I've tried different variations (getDetails etc)
> but
> > 'details is my
> > attribute name and doesn't seem to be picked up!
> >
> > alex
> > -----Original Message-----
> > From: rules-users-bounces(a)lists.jboss.org
> > [mailto:rules-users-bounces@lists.jboss.org] On Behalf
> Of
> > Greg Barton
> > Sent: 26 February 2009 17:04
> > To: Rules Users List
> > Subject: Re: [rules-users] Rules syntax question using
> > hashmap
> >
> > Can you provide any info on why the third option
> > doesn't work?
> >
> > --- On Thu, 2/26/09, Zevenbergen, Alex
> > <azevenbergen(a)paddypower.com>
> > wrote:
> >
> > > From: Zevenbergen, Alex
> > <azevenbergen(a)paddypower.com>
> > > Subject: [rules-users] Rules syntax question
> using
> > hashmap
> > > To: rules-users(a)lists.jboss.org
> > > Date: Thursday, February 26, 2009, 10:45 AM
> > > Hi all,
> > >
> > >
> > >
> > > Im using an object called 'Fact' this
> object
> > has
> > > one attribute that is a
> > > hashmap 'details'
> > >
> > >
> > >
> > > I know there are several ways to access the
> parameters
> > in
> > > the hashmap
> > >
> > >
> > >
> > > $f : Fact()
> > >
> > > eval
> > ($f.getDetails().get("END_MATCH").toString()
> > > == "true" &&
> > >
> $f.getDetails().get("WINNER").toString() ==
> > > "HOME")
> > >
> > >
> > >
> > > $f : Fact(details.END_MATCH ==
> true,details.WINNER ==
> > > "AWAY")
> > >
> > >
> > >
> > > $f : Fact()
> > >
> > > details(fact == $f, name ==
> "END_MATCH",
> > value ==
> > > true)
> > >
> > >
> > >
> > >
> > >
> > > I was told the third option works but it
> doesn't
> > for
> > > me!
> > >
> > >
> > >
> > > Anyway my question is: Is there anyway for these
> sort
> > of
> > > rules to not
> > > through an exception if any of the named
> parameters
> > > aren't on the
> > > hashmap 'details'?
> > >
> > >
> > >
> > > Ideally the rule would simply not fire if it
> looked
> > for a
> > > key that
> > > wasn't there!
> > >
> > >
> > >
> > > Any info much appreciated
> > >
> > >
> > >
> > > Alex
> > >
> > >
> > >
> > >
> > >
> >
> ________________________________________________________________________
> > > Privileged, confidential and/or copyright
> information
> > may
> > > be contained in this communication. This e-mail
> and
> > any
> > > files transmitted with it are confidential and
> > intended
> > > solely for the use of the individual or entity to
> whom
> > they
> > > are addressed. If you are not the intended
> addressee,
> > you
> > > may not copy, forward, disclose or otherwise use
> this
> > e-mail
> > > or any part of it in any way whatsoever. To do so
> is
> > > prohibited and may be unlawful. If you have
> received
> > this
> > > email in error
> > > please notify the sender immediately.
> > >
> > > Paddy Power PLC may monitor the content of e-mail
> sent
> > and
> > > received for the purpose of ensuring compliance
> with
> > its
> > > policies and procedures.
> > >
> > > Paddy Power plc, Airton House, Airton Road,
> Tallaght,
> > > Dublin 24 Registered in Ireland: 16956
> > >
> >
> ________________________________________________________________________
> > _______________________________________________
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > >
> https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> ________________________________________________________________________
> > Privileged, confidential and/or copyright information
> may
> > be contained in this communication. This e-mail and
> any
> > files transmitted with it are confidential and
> intended
> > solely for the use of the individual or entity to whom
> they
> > are addressed. If you are not the intended addressee,
> you
> > may not copy, forward, disclose or otherwise use this
> e-mail
> > or any part of it in any way whatsoever. To do so is
> > prohibited and may be unlawful. If you have received
> this
> > email in error
> > please notify the sender immediately.
> >
> > Paddy Power PLC may monitor the content of e-mail sent
> and
> > received for the purpose of ensuring compliance with
> its
> > policies and procedures.
> >
> > Paddy Power plc, Airton House, Airton Road, Tallaght,
> > Dublin 24 Registered in Ireland: 16956
> >
> ________________________________________________________________________
>
>
>
>
> ________________________________________________________________________
> Privileged, confidential and/or copyright information may
> be contained in this communication. This e-mail and any
> files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they
> are addressed. If you are not the intended addressee, you
> may not copy, forward, disclose or otherwise use this e-mail
> or any part of it in any way whatsoever. To do so is
> prohibited and may be unlawful. If you have received this
> email in error
> please notify the sender immediately.
>
> Paddy Power PLC may monitor the content of e-mail sent and
> received for the purpose of ensuring compliance with its
> policies and procedures.
>
> Paddy Power plc, Airton House, Airton Road, Tallaght,
> Dublin 24 Registered in Ireland: 16956
> ________________________________________________________________________
15 years, 9 months