Getting java.lang.NoSuchMethodError: org.drools.util.CompositeClassLoader.clone()Lorg/drools/util/CompositeClassLoader in drools webservice
by pratibhapandey
Hello Team,
I am creating a web service in java using eclipse and axis2 which has some
drools functionality in it.
This is my drools class:
public class LeverageDrools {
public LeverageDrools(){
}
public List<List<String>> findCorpLeverageName(List<LeverageBSLAData>
lvgBsladataList) throws Exception{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
List<List<String>> corpLevList = new ArrayList<List<String>>();
for(int i=0; i<lvgBsladataList.size();i++){
LeverageBSLAData lvgBsladata = lvgBsladataList.get(i);
lvgBsladata.setCorpLeverageName("");
ksession.insert(lvgBsladata);
ksession.fireAllRules();
List<String> bslaList = new ArrayList<String>();
bslaList.add(lvgBsladata.getInvestmentNumber());
bslaList.add(lvgBsladata.getCorpLeverageName());
corpLevList.add(bslaList);
}
logger.close();
return corpLevList;
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration config =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
config.setInputType(DecisionTableInputType.XLS);
//kbuilder.add(ResourceFactory.newClassPathResource("com/ge/re/leverage/drools/resources/LeverageTagging.drl"),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("com/LeverageRuleSheet.xls"),
ResourceType.DTABLE, config);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
and this is my POM:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
<version>3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-jsr94</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.1.0.drools16</version>
</dependency>
<dependency>
<groupId>javax.rules</groupId>
<artifactId>jsr94</artifactId>
<version>1.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
</dependency>
The build is fine and service also deploys well. but when I try to access
the service from a client, I get the following error on:
20:30:33,105 INFO [STDOUT] [ERROR]
org.drools.util.CompositeClassLoader.clone()Lorg/drools/util/CompositeClassLoader;
java.lang.NoSuchMethodError:
org.drools.util.CompositeClassLoader.clone()Lorg/drools/util/CompositeClassLoader;
at
org.drools.compiler.PackageBuilderConfiguration.getClassLoader(PackageBuilderConfiguration.java:358)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:94)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:57)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:309)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:298)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:187)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:165)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:301)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:229)
at
org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:47)
the error is coming on KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(); this line..
Please help as this is an urgent issue.
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-java-lang-NoSuchMethodError-org...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Logging Rules Fired on a Fact -- Best Practices
by BenjaminWolfe
Is there a way to log what rules have interacted with a fact -- and keep the
logging with the fact? What are the best practices for that?
For example, facts are unmarshalled from an XML stream:
<important_fact>
<foo>bar</foo>
</important_fact>
Then my rules interact with it:
rule "my rule"
no-loop true
dialect "mvel"
when
i : important_fact()
then
i.setFoo("fee");
end
rule "my second rule"
no-loop true
dialect "mvel"
when
i : important_fact( foo = "fee" )
then
i.setFoo(i.getFoo + "foo");
end
Then I'm thinking I'd like the marshalled output to be something like this
(except maybe with unique rule IDs instead of just names):
<important_fact>
<foo>feefoo</foo>
<rule_history>
<rule>my rule</rule>
<rule>my second rule</rule>
</rule_history>
</important_fact>
But I'm pretty new at this. Is that ever done? If so, what are the best
practices? If not, maybe there's a good reason, so why not?
--
View this message in context: http://drools.46999.n3.nabble.com/Logging-Rules-Fired-on-a-Fact-Best-Prac...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Re: [rules-users] Error in Drools when clicking "Generate Task Form Template"
by Tihomir Surdilovic
The issue seems to be your assignment mapping of the task data outputs.
Please note the "To" and "From" columns in the data assignments editor:
** When you are mapping DATA INPUTS:
"From" columns should have the object you are mapping from, so like
process variables, globals, etc
"To" columns should have the object you are mapping to, so the data
input of your task
** When you are mapping DATA OUTPUTS:
"From" columns should have the object you are mapping from, so your data
output of your Task
"To" columns should have the object you are mapping to, so like your
process variables, globals, etc.
I think in your case you should just switch your assignments for your
task data outputs, so:
** Task 1:
from Object="Approve" is mapped to "ApprovedRequest"
should be
from Object="ApprovedRequest" is mapped to "Approve"
** Task 2:
from Object="Order" is mapped to "OrderItem"
should be
from Object="OrderItem" is mapped to "Order"
Hope this helps.
Tihomir
On 8/7/12 10:06 AM, Saadi Ajam wrote:
> Thanks a lot for reply,
> Actually I was searching the internet and I found your post in
> wordpress. And yes it was a variable or binding error. I removed all
> the variables and the forms generated with the no data.
>
> So, Could you please give me some hints about the variables in Drools.
> My whole process example is composed of 2 user tasks only:
>
> * In the process properties under "*Variable Definition*", I add
> "ItemID" = Integer and "ItemName" = String and "Approve"=Boolean
> and "Order"=Boolean
> * In the first task properties: under "*DataInputSet*", I add
> "AddItemID"=Integer and "AddItemName"=String | Under
> "*DataOutputSet"* I add "ApproveRequest"=Boolean
> o Under assignments, From Object= "ItemID" is mapped to
> "AddItemID", From Object="ItemName" is mapped to
> "AddItemName", from Object="Approve" is mapped to
> "ApprovedRequest"
> * In the second task properties: under*"DataInputSet"*, I add
> "OrderItemID"=Integet and "OrderItemName"=String | Inder
> *"DataOutputSet"* I add "OrderItem"=Boolean
> o Under assignments, From Object= "ItemID" is mapped to
> "OrderItemID", From Object="ItemName" is mapped to
> "OrderItemName", from Object="Order" is mapped to "OrderItem"
>
> Thanks,
>
>
>
> On Tue, Aug 7, 2012 at 4:44 PM, Tihomir Surdilovic
> <tsurdilo(a)redhat.com <mailto:tsurdilo@redhat.com>> wrote:
>
> Task Form generation parses your process BPMN2 and it looks as you
> have
> some issues with it - click on the "BPMN2" button in the Designer
> footer
> and then either provide the BPMN2 shown, or the server log error(s) it
> generates. If you get errors, provide those, and also click on the
> "JSON" button in the footer and provide the JSON representation of
> your
> process.
>
> You can click on the "info" button in the Designer header to
> provide the
> Designer version you are using...that will help as well
>
> Thanks.
> Tihomir
> On 8/7/12 9:02 AM, Sadiroveski wrote:
> > Dear helpers,
> >
> > I designed process in drools with human tasks included, add the
> variables,
> > inputsets and bindings.
> > When I clicked on the "Generate Task Form Templates", to add
> forms I got the
> > following:
> >
> >
> ----------------------------------------------------------------------------------------
> > type Exception report
> >
> > message
> >
> > description The server encountered an internal error () that
> prevented it
> > from fulfilling this request.
> >
> > exception
> >
> > java.lang.ArrayIndexOutOfBoundsException: 1
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.applyTaskProperties(Bpmn2JsonUnmarshaller.java:3482)
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.applyProperties(Bpmn2JsonUnmarshaller.java:1921)
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshallItem(Bpmn2JsonUnmarshaller.java:1645)
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshallItem(Bpmn2JsonUnmarshaller.java:1560)
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshall(Bpmn2JsonUnmarshaller.java:225)
> >
> >
> org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshall(Bpmn2JsonUnmarshaller.java:201)
> >
> >
> org.jbpm.designer.web.server.TaskFormsServlet.doPost(TaskFormsServlet.java:73)
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
> >
> >
> org.jbpm.designer.web.filter.impl.PluggableFilter.doFilter(PluggableFilter.java:70)
> >
> > note The full stack trace of the root cause is available in the
> JBoss
> > Web/7.0.1.Final logs.
> >
> -------------------------------------------------------------------------------------------
> >
> >
> > Any help please,
> >
> >
> >
> > --
> > View this message in context:
> http://drools.46999.n3.nabble.com/Error-in-Drools-when-clicking-Generate-...
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
12 years, 4 months
Can somebody help me with this rule engine execution
by Venkat
I want to do this.
rule
when
condition (when condition is successful then go to next rule, but when
it fails it should just log it)
then
end
I have done for successful scenario using activation-group, but don't know
what to specify in the consequence for that to tell to go to next rule.
How can I log it when the rule fails, it should not go to anymore rules, it
should just break from the rule engine.
Can somebody let me know how to do this.
Thanks,
--
View this message in context: http://drools.46999.n3.nabble.com/Can-somebody-help-me-with-this-rule-eng...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Bug in "enabled" rule attribute???
by bdolbeare
The following DRL produces a Null Pointer Exception when the "enabled"
attribute is set to false on "test rule 2". Any ideas why? Changing this
value to true or commenting out the rule causes things to succeed.
Environment: Java 7 and Drools 5.4
package tests
import org.apache.log4j.Logger;
import java.util.List;
global Logger log
declare Data
name : String
end
rule "insert Data"
when
then
insert(new Data("test"));
end
rule "test rule 2"
enabled false
when
d : List() from collect (Data( name == "test") )
then
log.info(String.format("%s hit on %s", kcontext.getRule().getName(), d));
end
Exception executing consequence for rule "insert Data" in tests:
java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:278)
at tests.DroolsTest.testStateless(DroolsTest.java:98)
at tests.DroolsTest.runTest(DroolsTest.java:60)
at tests.DroolsTest.main(DroolsTest.java:45)
Caused by: java.lang.NullPointerException
at org.drools.common.DefaultAgenda.createActivation(DefaultAgenda.java:569)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:297)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:259)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:676)
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:591)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:345)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:342)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:187)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:181)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218b.defaultConsequence(Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218b.java:7)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218bDefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
tests.Rule_insert_Data_2eb7a40b15e640d6bc777e1075d1218bDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
--
View this message in context: http://drools.46999.n3.nabble.com/Bug-in-enabled-rule-attribute-tp4019049...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Matching consecutive events
by jpullmann
Dear contributors,
this rule is expected to match a sequence of 2 consecutive events:
rule "test"
when
// a)
$ev1 : LocalizationEvent( type == TYPE.HINT, $target : target )
from entry-point "events/localization"
$ev2 : LocalizationEvent( type == TYPE.HINT, target == $target, this
after $ev1 ) from entry-point "events/localization"
// b)
// Ev1 directly followed by ev2: no other HINT in between
not( LocalizationEvent( type == TYPE.HINT, target == $target, this
after $ev1, this before $ev2 ) from entry-point "events/localization" )
then
do()
end
The second event is interpreted as a "confirmation" of the first event (a).
No other (deviating) event is allowed between them (b). With this
restriction
in place, the rule requires a sequence of 3 input events for activation,
otherwise
2 events are sufficient (as expected). The events are ordered correctly and
it is
not obvious, why a third event is needed since the interval between ev1 and
ev2 is
closed ? This leads to an unnecessary delay in rule activation.. How could
this be
avoided and are there other approaches to match a concrete event sequence
pattern ?
Many thanks
Jaro
--
View this message in context: http://drools.46999.n3.nabble.com/Matching-consecutive-events-tp4018980.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
ResourceChangeScanner and ResourceChangeNotifierImpl - hundereds of threads
by paulB
Hi all,
I've run into a memory issue when using Drools, and I was hoping someone
could help out.
I have a project that uses StatefulKnowledgeSession's, and every couple of
weeks I get OutOfMemory from the JVM. I've done heap dumps and analyzed the
dominator_tree, etc. No luck yet in identifying the culprit.
However, I did notice that I have hundreds of the following threads (shown
below) for .ResourceChangeNotifierImpl$ProcessChangeSet and
ResourceChangeScannerImpl$ProcessChangeSet. The thread count increases
every time a new session is created (and maybe every time a rule is
evaluated??). This seems kind of odd to me. I'm using drool-spring to
instantiate the kbase, kagent, and resource-change-scanner.
My spring configuration is as follows, using v1.5 of the xsd under Drools
5.4.0.Final and jBPM 5.3.0.Final:
Thank you for any ideas.
--
View this message in context: http://drools.46999.n3.nabble.com/ResourceChangeScanner-and-ResourceChang...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Error in Drools when clicking "Generate Task Form Template"
by Sadiroveski
Dear helpers,
I designed process in drools with human tasks included, add the variables,
inputsets and bindings.
When I clicked on the "Generate Task Form Templates", to add forms I got the
following:
----------------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception
java.lang.ArrayIndexOutOfBoundsException: 1
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.applyTaskProperties(Bpmn2JsonUnmarshaller.java:3482)
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.applyProperties(Bpmn2JsonUnmarshaller.java:1921)
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshallItem(Bpmn2JsonUnmarshaller.java:1645)
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshallItem(Bpmn2JsonUnmarshaller.java:1560)
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshall(Bpmn2JsonUnmarshaller.java:225)
org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.unmarshall(Bpmn2JsonUnmarshaller.java:201)
org.jbpm.designer.web.server.TaskFormsServlet.doPost(TaskFormsServlet.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jbpm.designer.web.filter.impl.PluggableFilter.doFilter(PluggableFilter.java:70)
note The full stack trace of the root cause is available in the JBoss
Web/7.0.1.Final logs.
-------------------------------------------------------------------------------------------
Any help please,
--
View this message in context: http://drools.46999.n3.nabble.com/Error-in-Drools-when-clicking-Generate-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months