For loop inside a modify block problem
by Martin A
Hello, guys,
I have the following snippet of a right side rule:
modify ($gsc) {
doSomething($item.id);
for (int i = 0; i < $item.quantity; i++) {
doSomethingElse($item.id);
}
}
which looks like is invalid syntax in some way, but it comes out with
strange error report, such as '[Error: no such identifier: $item]'
Would you please assist me on how to put that loop inside that modify block?
Thank you and regards,
Martin
14 years, 3 months
How to add Packages to RuleBase
by srinivasasanda
Hi
I wrote code for creating RuleBase. But I got error at retrieving URL
resource by passing ruleFile to the getResource() method.It is returning
null. How to get the URL resource. I posted the sample code which i have
written for creating RuleBase.
public RuleBase createRuleBase() throws Exception
{
if(rules==null)
{
throw new Exception("No rules provided for Engine");
}
ruleBase = RuleBaseFactory.newRuleBase();
PackageBuilder builder = new PackageBuilder();
for(String ruleFile : rules)
{
System.out.println("Rule is "+ruleFile); //prints
the ruleFile
URL resource = this.getClass().getResource(ruleFile); //gets the URL
resource of the ruleFile
if(resource==null)
{
System.err.println("Could not find resource: "+ruleFile);
continue;
}
File file = new File(this.getClass().getResource(ruleFile).getPath());
if(!file.exists())
{
System.err.println("Could not find rule file: "+file.getPath());
continue;
}
builder.addPackageFromDrl(new FileReader(file.getPath()));
}
org.drools.rule.Package pkg = builder.getPackage();
ruleBase.addPackage(pkg);
return ruleBase;
}
My Packages are not adding to RuleBase.It is returning null.
How to add the packages to ruleBase.Please suggest me
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-add-Packages-to-RuleBase-tp36534...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Re: [rules-users] Problem with “after” operator
by Davide Sottara
Quoting the Drools fusion manual:
"The after evaluator correlates two events and matches when the temporal
distance from the current event to the event being correlated belongs to the
distance range declared for the operator.
The temporal distance interval for the after operator is optional:
If two values are defined (like in the example below), the interval starts
on the first value and finishes on the second.
If only one value is defined, the interval starts on the value and finishes
on the positive infinity.
*If no value is defined, it is assumed that the initial value is 1ms and the
final value is the positive infinity."*
try changing after --> after[0ms] and see if this solves your problem.
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-after-operator-tp3620746p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Fresh Guvnor Install throws ClassNotFoundException
by Mike Key
Hi all,
I have installed Guvnor 5.3.0-Final on a fresh Tomcat 7.0.12. I am able to
import existing rules I have, however when I try to upload my fact model I
get an error in the localhost log file:
SEVERE: Servlet.service() for servlet [AssetFileServlet] in context with
path [/guvnor-5.3.0.Final-tomcat-6.0] threw exception [Servlet execution
threw an exception] with root cause
java.lang.ClassNotFoundException: org.osgi.framework.BundleActivator
>...at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
>...at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
>...at java.lang.Class.forName0(Native Method)
>...at java.lang.Class.forName(Class.java:247)
>...at
org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:109)
>...at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>...at java.lang.ClassLoader.defineClass1(Native Method)
>...at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
>...at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
>...at
org.drools.rule.MapBackedClassLoader.fastFindClass(MapBackedClassLoader.java:86)
>...at
org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.java:104)
>...at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>...at
org.drools.guvnor.server.contenthandler.ModelContentHandler.isClassVisible(ModelContentHandler.java:183)
>...at
org.drools.guvnor.server.contenthandler.ModelContentHandler.getImportsFromJar(ModelContentHandler.java:148)
>...at
org.drools.guvnor.server.contenthandler.ModelContentHandler.onAttachmentAdded(ModelContentHandler.java:66)
>...at
org.drools.guvnor.server.files.FileManagerUtils.attachFileToAsset(FileManagerUtils.java:115)
>...at
org.drools.guvnor.server.files.FileManagerUtils.attachFile(FileManagerUtils.java:87)
>...at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>...at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>...at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>...at java.lang.reflect.Method.invoke(Method.java:597)
>...at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
>...at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
>...at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
>...at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
>...at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>...at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
>...at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>...at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
>...at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>...at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163)
>...at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>...at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
>...at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
>...at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
I am attempting to upload a jar with all dependencies it uses (which
includes JPA annotations and JAXB annotations). I have verified that the
jar contains all its proper dependencies. This message seems to indicate I
am missing some OSGi jar or something that I would have expected to be
delivered with Guvnor. Do I need some sort of global libraries for OSGi to
run Guvnor or to use my model when it has these external dependencies in
the jar?
Any help on this is greatly appreciated.
Cheers.
Mike Key
14 years, 3 months
Unable to apply ChangeSet to DRL file
by srinivasasanda
Hi,
I've a DRL file and Java Class, and ChangeSet.xml present in local drive D:
DRL file is rulemaster.drl having rule A,rule B.
My ChangeSet.xml is <change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource source='file:D:\rulemaster.drl' type='DRL' />
</add>
</change-set>
Now My Java class is
package com.sample;
public class RuleEngine
{
private RuleEngine()
{
}
public static final void main(String[] args)
{
int counter=0;
try
{
System.out.println("Before rule engine start ");
RuleEngine.start();
System.out.println("After rule engine start ");
do{
Collection<KnowledgePackage> kpackages =
_kbase.getKnowledgePackages();
System.out.println("no of packages"+kpackages.size());
for(KnowledgePackage kpackage : kpackages)
{
for(org.drools.definition.rule.Rule rule1
:kpackage.getRules())
{
String packname= rule1.getPackageName();
String rulename=rule1.getName();
System.out.println("This is : "+packname+" Packages and
RuleName is " +rulename);
}
}
counter++;
try{
Thread.sleep(10000);
}catch (InterruptedException e){
System.out.println("Sleep exception occured");
}
}while(counter < 10000);
}catch (Throwable t){
t.printStackTrace();
}
}
public static synchronized RuleEngine start()
{
try{
if ( _instance == null)
{
_instance = new RuleEngine();
//create knowledgeBuilder
String url="file:D:\\ChangeSet.xml";
_kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent" );
System.out.println("after creating kagent");
_kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
System.out.println("after apply change set");
//Create Knowledge Base
_kbase = _kagent.getKnowledgeBase();
ResourceChangeScannerConfiguration sconf=
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
System.out.println("After starting Notification service");
}
}catch(Exception e)
{
System.out.println(e.getMessage());
}
return _instance;
}
private static KnowledgeAgent _kagent;
private static RuleEngine _instance;
private static KnowledgeBase _kbase=null;
private static StatelessKnowledgeSession _ksession=null;
}
Now as I'm making changes to DRL file by adding Rule C,Rule D..I've written
applyChangeSet method in Java class.But it is not displaying new
RuleNames.Please suggest me what is the way to applyChangeSet to DRL
file.Does anythng went wrong in above code..
Please suggest me
THanks
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-apply-ChangeSet-to-DRL-file-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
CPU Spike creating a StatefulKnowledgeSession using OSGi
by David Conde
Good Morning,
I now have drools running on the Spring DM-Server but I am seeing a CPU
spike when creating a StatefulKnowledgeSession. I've tested this outside of
an OSGi environment and I don't see the spike. Does anyone know any settings
that I can change that might make this go away?
Thanks,
Dave
--
David Conde
CTO Calom Technologies
14 years, 3 months
No Such Field Error:DESCR in implementing ChangeSet
by srinivasasanda
Hi,
I'm trying to implement CHANGESET.xml functinlaity through some example.Here
is my code
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
//kbuilder.add(ResourceFactory.newUrlResource("file:d:\\rulestest\\changeset.xml"),
ResourceType.CHANGE_SET);
kbuilder.add(ResourceFactory.newUrlResource(
"file:d:\\rulestest\\changeset.xml"), ResourceType.CHANGE_SET
);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.
err.println(error);
But It is generating exception as
java.lang.NoSuchFieldError: DESCR
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:539)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:42)
at com.sample.DroolsTest.main(DroolsTest.java:24)
Im using guvnor 5.2..Could you please suggest me
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/No-Such-Field-Error-DESCR-in-implementi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 3 months
Unable to do Guvnor Authentiation with MySQL
by Sumeet Karawal
Hi,
Has anybody encountered the similar problem, could someone please help me
on this.
TIA,
Sumeet
Mailto: sumeet.karawal(a)tcs.com
----- Forwarded by Sumeet Karawal/MUM/TCS on 01/11/2012 05:16 PM -----
From: Sumeet Karawal <sumeet.karawal(a)tcs.com>
To: rules-users(a)lists.jboss.org
Date: 01/09/2012 08:18 PM
Subject: [rules-users] Unable to do Guvnor Authentiation with MySQL
Sent by: rules-users-bounces(a)lists.jboss.org
Hi All,
I am trying to enable authentication in Guvnor using MySQL. I am using
MySQL 5.1, Guvnor 5.2 and JBoss AS 5.0.4
I searched over a lot of docs and tried to do as mentioned below :
I have created a GuvnorDB in MySQL with two tables
create table Principals(principal_id VARCHAR(64),password
VARCHAR
(64));
create table roles(principal_id VARCHAR(64),user_role VARCHAR
(64),role_group VARCHAR(64));
and have entered some values accordingly (admin, admin123) and (admin,
admin, admin);
My components.xml in drools-guvnor.war is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:web="http://jboss.com/products/seam/web"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xsi:schemaLocation="http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-2.0.xsd
http://jboss.com/products/seam/security
http://jboss.com/products/seam/security-2.0.xsd
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.0.xsd
http://jboss.com/products/seam/web
http://jboss.com/products/seam/web-2.0.xsd
http://jboss.com/products/seam/transaction
http://jboss.com/products/seam/transaction-2.0.xsd">
<core:init transaction-management-enabled="false" />
<transaction:no-transaction />
<component name="repositoryConfiguration">
<!-- JackRabbit -->
<property name="properties">
<key>org.drools.repository.configurator</key><value>org.drools.repository.jackrabbit.JackrabbitRepositoryConfigurator</value>
</property>
</component>
<!-- SECURITY IDENTITY CONFIGURATION -->
<security:identity authenticate-method="#{authenticator.authenticate}"
jaas-config-name="mysql"/>
<!-- SECURITY AUTHORIZATION CONFIGURATION -->
<component name="org.jboss.seam.security.roleBasedPermissionResolver">
<property name="enableRoleBasedAuthorization">true</property>
</component>
</components>
I have also changed my login-config.xml accordingly and added a
application policy :
<application-policy name="mysql">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag="required">
<module-option name="dsJndiName">java:/MySqlDS</module-option>
<module-option name="principalsQuery">select password from principals
where principal_id=?</module-option>
<module-option name="principalsQuery">select user_role,'Roles' from roles
where principal_id=?</module-option>
</login-module>
</authentication>
</application-policy>
I have also created a mysql-ds.xml and saved it in the default/deploy
folder; its contents :
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/GuvnorDB</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>getting an exceptiogetting
</datasources>
After all these changes, when I run guvnor and try to login, I am
getting an exception thrown at the console:
01:36:41,212 INFO [STDOUT] INFO 10-01 01:36:41,211
(SecurityServiceImpl.java:login:57) Logging in user [admin]
01:36:41,360 INFO [STDOUT] ERROR 10-01 01:36:41,357
(SecurityServiceImpl.java:login:77) Unable to login.
javax.security.auth.login.FailedLoginException: Password Incorrect/Password
Required
at
org.jboss.security.auth.spi.UsernamePasswordLoginModule.login
(UsernamePasswordLoginModule.java:213)
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:616)
at javax.security.auth.login.LoginContext.invoke
(LoginContext.java:784)
at javax.security.auth.login.LoginContext.access$000
(LoginContext.java:203)
at javax.security.auth.login.LoginContext$4.run
(LoginContext.java:698)
at javax.security.auth.login.LoginContext$4.run
(LoginContext.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv
(LoginContext.java:695)
at javax.security.auth.login.LoginContext.login
(LoginContext.java:594)
at org.jboss.seam.security.Identity.authenticate
(Identity.java:335)
at org.jboss.seam.security.Identity.authenticate
(Identity.java:324)
at org.drools.guvnor.server.security.SecurityServiceImpl.login
(SecurityServiceImpl.java:75)
at org.drools.guvnor.server.SecurityServiceServlet.login
(SecurityServiceServlet.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:57)......
.................
I tried a lot but not getting through on how to do this.
It would really helpful if somebody could guide me on this.
Thanks & Regards,
Sumeet
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 3 months