Re: [rules-users] KnowledgeAgent not reloading KnowledgeBase
by Pritam
It's working now. The key was to provide a change-set location to
KnowledgeAgent and make the agent itself singleton in the app.
public static KnowledgeBase getKnowledgeBase()
throws DroolsParserException, IOException {
// hold a static reference in class
if(agent != null) {
return agent.getKnowledgeBase();
}
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
agent = KnowledgeAgentFactory.newKnowledgeAgent("myagent");
agent.applyChangeSet(ResourceFactory.newFileResource("<path>\\change-set.xml"));
return agent.getKnowledgeBase();
}
<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.xsd' >
<add>
<resource source='file:<path>/rules/' type='DRL' />
</add>
</change-set>
faruk wrote:
>
> Hi all,
>
> i have same problem with my code. And i implement both cases: with path to
> chage-set file and with xml string as You suggests.
>
> I both cases, i have same situation: logs says me that rules are
> rebuilded, but when i fire rules, i have next situation:
>
> with statefull session, no rules are fired after update
> with stateless session, same rules are fired.
>
> I make rules without conditions.
>
--
View this message in context: http://n3.nabble.com/KnowledgeAgent-not-reloading-KnowledgeBase-tp121401p...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
KnowledgeAgent not reloading KnowledgeBase
by Pritam
Before I ask the problem, here's the design I currently have:
Our "site" (webapp) has 100 pages. While rendering each page, the rule
engine is called for filtering the page contents. We have 100 drl files
(corresponding to each page). Since creating of a KnowledgeBase is
expensive, I'm using a KnowledgeAgent.getKnowledeBase() since the javadocs
mentions it as "it loads, caches, reloads knowledgeBase."
However after using the sample code given, a change in the rule file is not
reloading the knowledgeBase automatically. Note that I cache the
knowledgeAgent since I need one agent per knowledge base (is there a better
way to manage multiple drl files in one knowledge base and agent?)
Is something wrong with the below code?
// ruleFile is a complete file path on server
public static KnowledgeBase createKnowledgeBaseFromAgent(String ruleFile)
throws DroolsParserException, IOException {
ResourceChangeScannerConfiguration sconf = ResourceFactory
.getResourceChangeScannerService()
.newResourceChangeScannerConfiguration();
// static map of knowledgeAgents
if (knowledgeAgents.containsKey(ruleFile)) {
return
((KnowledgeAgent)knowledgeAgents.get(ruleFile)).getKnowledgeBase();
}
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
KnowledgeBase knowledgeBase = createKnowledgeBase(ruleFile);
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
KnowledgeAgentConfiguration conf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
conf.setProperty("drools.agent.scanDirectories", "true");
final KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent(
"my agent", knowledgeBase, conf);
// agent.applyChangeSet(ResourceFactory.newFileResource(ruleFile));
setKnowledgeAgent(ruleFile, agent);
return agent.getKnowledgeBase();
}
public static KnowledgeBase createKnowledgeBase(
KnowledgeBaseConfiguration config,
KnowledgeBuilderConfiguration knowledgeBuilderConfig,
String ruleFile) throws DroolsParserException, IOException {
// else, create a knowledgeBase
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(knowledgeBuilderConfig);
knowledgeBuilder.add(ResourceFactory.newFileResource(ruleFile),
ResourceType.DRL);
if (knowledgeBuilder.hasErrors()) {
throw new RuntimeException(knowledgeBuilder.getErrors().toString());
}
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(config);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
return knowledgeBase;
}
I commented out
agent.applyChangeSet(ResourceFactory.newFileResource(ruleFile));
since I get a NPE
java.lang.NullPointerException
at
org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgentImpl.java:135)
Pl suggest
--
View this message in context: http://n3.nabble.com/KnowledgeAgent-not-reloading-KnowledgeBase-tp121401p...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
Guvnor Error
by HonorGod
Hi,
I have uploaded decision tables into drools guvnor and the corresponding
model jar. I have the following in the decision table import section
Import com.barcap.efg.fine.util.LogUtil, java.util.Date
And in one of the actions I have
LogUtil.caRecommendationLogger.warn("Lift Rule Fired = "+11);
When I try to validate the decision table using Guvnor I get the following
error -
[Corporate_Actions_Update_Lift_dates] Rule Compilation error Only a type
can be imported. com.barcap.efg.fine.util.LogUtil resolves to a package
LogUtil.caRecommendationLogger cannot be resolved to a type
[Corporate_Actions_Update_Lift_dates] Rule Compilation error Only a type
can be imported. com.barcap.efg.fine.util.LogUtil resolves to a package
LogUtil.caRecommendationLogger cannot be resolved to a type
[Corporate_Actions_Update_Lift_dates] Rule Compilation error Only a type
can be imported. com.barcap.efg.fine.util.LogUtil resolves to a package
LogUtil.caRecommendationLogger cannot be resolved to a type
But the same works with no errors when I run my project through eclipse.
Please guide.
Thanks
--
View this message in context: http://n3.nabble.com/Guvnor-Error-tp120766p120766.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
how set breakpoints in 5.x process flows
by Chuck Irvine
Sorry if I'm missing the obvious. In the eclipse IDE, I can't figure out how
to set breakpoints in (5.x) flows. The documentation indicates that this is
supported, but I can't see any description of how to do it. Can anyone
help? Thanks -Chuck
16 years, 2 months
Can we have two or more Changeset.xml file in an Application
by Pardeep Ruhil
Hi,
My doubt is, Can we have two or more changeset.xml file having different workflow, and any change in the workflow or rule will read the corresponding changeset.xml file and rebuild the knowledge base in an application.
Thanks & Regards
Pradeep Ruhil
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
16 years, 2 months
Understanding "no viable alternative ..." errors
by Pritam
While executing the following rule,
rule "home dummy"
when
pointId: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
I get the following error:
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule "home
dummy" in pattern PointId[18,16]: [ERR 102] Line 18:16 mismatched input
'"type"' expecting ']' in rule "home dummy" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "drools 5) for writing the
following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the Content
id is "adslot" with a property, type as "ad" then filter the Content (using
a global map and passing a boolean flag)
Thanks
--
View this message in context: http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months
Re: [rules-users] How to specify relative URL in chagenset.xml file
by Pardeep Ruhil
Hi Mark,
Thanks for answering my query.
It is picking the relative path now, provided there is no space(' ') in a folder name.
Is there a way, that it wil pick the folder having space in name ?
Thanks & Regards
Pradeep Ruhil
>
> Hi,
>
> I am getting File Not Found Exception when I try to give relative path
> of the file.
>
> <resource source='file:../HelloWorld.drl' type='DRL' />
>
If I told you that the above would do nothing more than:
new File ("../HelloWorld.drl");
Would that help?
Mark
>
> But when I give the complete path, It picks the changeset.xml file.
>
> <resource source='file:C:/Tomcat/webapps/DroolsCheck/HelloWorld.drl'
> type='DRL' />
>
> Please tell me the syntax for using the relative path for my workflow
> or rule files.
>
> Thanks & Regards
>
> Pradeep Ruhil
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
16 years, 2 months
drools 5.0.1 enum serialization/deserialization problem
by Garner, Shawn
We are pre-compiling the rules and then reading them in and running them later.
I'm getting this error when reading in the compiled (serialized rules) rules:
"Error deserializing enum value"...
This line (pretty similar to this) is causing the issue when it's deserializing the Java 5 Enum.
MyClass( myEnumType == MyEnum.MY_ENUM_VALUE)
I saw some bug reports that this is fixed in 5.0.2 but I can't find it and it's been a while since 5.0.1 was released.
When is this going to be fixed or is there a way to get a snapshot 5.0.2 with this fixed?
Can somebody help me?
Thanks,
SDG
-----Message Disclaimer-----
This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect(a)principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.
Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.
While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.
16 years, 2 months
Backing up Guvnor repository
by RichardA
Today we are using Drools 4 and the gui for the rules.
The backend of the gui repository is in Oracle, and we backup the oracle db
each day.
But we also perform an export from the gui using the import/export function
to gather a known good repository.
In drools 4 we can use:
wget -O repository_export.zip
http://localhost:4980/drools-gui/drools.../backup
and this does the same as the export...
but in guvnor we have enabled authentication, and when we run:
wget -O repository_export.zip
http://localhost:4980/guvnor/org.drools.guvnor.Guvnor/backup
we get Internal server error, exception shown below.
Is there a way to authenticate via a url call?
wget -O repository_export.zip
http://admin:passwd@localhost:4980/guvnor/org.drools.guvnor.Guvnor/backup
doesn't work.
Thanks
Ric
StandardWrapperValve[RepositoryBackupServlet]: PWC1406: Servlet.service()
for servlet RepositoryBackupServlet threw exception
org.jboss.seam.InstantiationException: Could not instantiate Seam component:
roleBasedPermissionManager
at org.jboss.seam.Component.newInstance(Component.java:2066)
at org.jboss.seam.Component.getInstance(Component.java:1948)
at org.jboss.seam.Component.getInstance(Component.java:1910)
at org.jboss.seam.Component.getInstance(Component.java:1904)
at org.jboss.seam.Component.getInstance(Component.java:1899)
at
org.jboss.seam.security.permission.RoleBasedPermissionResolver.hasPermission(RoleBasedPermissionResolver.java:94)
at
org.jboss.seam.security.permission.PermissionMapper.resolvePermission(PermissionMapper.java:77)
at org.jboss.seam.security.Identity.hasPermission(Identity.java:623)
at
org.jboss.seam.security.Identity.checkPermission(Identity.java:571)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.doGet(RepositoryBackupServlet.java:90)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at
com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at
com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.lang.NullPointerException
at
org.drools.repository.security.PermissionManager.isValideUserName(PermissionManager.java:188)
at
org.drools.repository.security.PermissionManager.retrieveUserPermissions(PermissionManager.java:79)
at
org.drools.guvnor.server.security.RoleBasedPermissionStore.getRoleBasedPermissionsByUserName(RoleBasedPermissionStore.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
--
View this message in context: http://n3.nabble.com/Backing-up-Guvnor-repository-tp119403p119403.html
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 2 months