Probable bug when using two knowledge bases and one declarative model between
by Jackson Cunha
Hello conrads.
To explain what I need, the problem that I found and the solution that I
planning to use, I will firstly describe my cenario.
*Cenario*
In my cenario, I have a declarative model and rules of different groups. I
need put each rules group in a different knowledge base and all of it will
share the same declarative model.
In a time, I will create a fact using fact types defined in a knowledge
base that I will call as kbaseModel. This knowledge base will have only the
declarative model and no rules.
All facts created will be used in other knowledge base, called kbaseRules.
All kbaseRules have only rules and no declarative model, because model was
defined in kbaseModel.
I could have many kbaseRules but exists only one kbaseModel.
Using the Drools API, teoricaly, I could implement my cenario using the
following code:
//DRL for resourceModel
declare MyEntity
name : String
end
//DRL for resourceRules
rule "Simple Rule"
when
$entity: MyEntity()
then
System.out.println($entity)
end
Resource resourceModel = ... //Resource with only the declarative model and
no rules
Resource resourceRules = ... //Resource with only rules and no declarative
model
KnowledgeBuilder kbuilderModel =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilderModel add(resourceModel, ResourceType.DRL);
KnowledgeBase kbaseModel = kbuilderModel.newKnowledgeBase();
KnowledgeBuilder kbuilderRules =
KnowledgeBuilderFactory.newKnowledgeBuilder(kbaseModel);
kbuilderRules.add(resourceRules, ResourceType.DRL);
KnowledgeBase kbaseRules = KnowledgeBaseFactory.newKnowledgeBase();
kbaseRules.addKnowledgePackages(kbuilderRules.getKnowledgePackages());
FactType factType = kbaseModel.getFactType("mymodel", "MyEntity");
Object myEntity = factType.newInstance();
factType.set(myEntity, "name", "Jackson Cunha Cassimiro");
StatelessKnowledgeSession session =
kbaseRules.newStatelessKnowledgeSession();
session.execute(myEntity);
This code should work, but when I try to run I get this stacktrace:
java.lang.ClassNotFoundException: Unable to load class: mymodel.MyEntity
at
org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:92)
at
org.drools.common.AbstractRuleBase.registerAndLoadTypeDefinition(AbstractRuleBase.java:649)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:553)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
at app.UsingDeclares.main(UsingDeclares.java:79)
Exception in thread "main" org.drools.RuntimeDroolsException: unable to
resolve Type Declaration class 'mymodel.MyEntity'
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:582)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
at app.UsingDeclares.main(UsingDeclares.java:79)
It happens because Drools can't find any reference of mymodel.MyEntity in
kbaseRules, but this kbase was built from kbaseModel that already have this
class declared. *I think it can be a **bug*.
*Debuging*
During creation of kbaseModel, a method called mergePackage(pkgRegistry,
packageDescr) from PackageBuilder class is invoked. The pkgRegistry not
contains any reference to declarative model. The packageDescr contains a
list of type definitions from declarative model. Inside mergePackage is
invoked other method, called processTypeDeclarations(pkgRegistry,
packageDescr) that will iterate over all type definitions from
packageDescrand will fill a map called Map<String,byte[]>
classLookups from JavaDialectRuntimeData class.
During the creation of kbaseRules the method mergePackage(pkgRegistry,
packageDescr) from PackageBuilder is invoked again, but at this time
pkgRegistry contains all type definitions defined previously in kbaseModeland
packageDescr not contains any type definitions, only rules. When the
method processTypeDeclarations(pkgRegistry,
packageDescr) from PackageBuilder is called and try iterate over type
definitions of packageDescr, this is empty and nothing is done and the
map Map<String,byte[]>
classLookups from JavaDialectRuntimeData will be empty too.
*The classLookups empty is the cause of ClassNotFoundException*.
*Solution*
The solution that I found was apply reflection to fill Map<String,byte[]>
classLookups from JavaDialectRuntimeData correctly before add the packages
into kbaseRules:
Collection<KnowledgePackage> packages =
kbuilderRules.getKnowledgePackages();
Mirror mirror = new Mirror();//Reflection utilities
for (KnowledgePackage kPackage : packages) {
Package pkg = (Package) mirror.on(kPackage).get().field("pkg");
JavaDialectRuntimeData dialect = (JavaDialectRuntimeData)
pkg.getDialectRuntimeRegistry().getDialectData( "java" );
for (FactType factType : kPackage.getFactTypes()) {
Class<?> c = factType.getFactClass();
String className = c.getName();
String classAsPath = className.replace('.', '/') + ".class";
InputStream stream =
c.getClassLoader().getResourceAsStream(classAsPath);
byte[] bytes = IOUtils.toByteArray(stream);
dialect.putClassDefinition(classAsPath, bytes);
}
}
KnowledgeBase kbaseRules = KnowledgeBaseFactory.newKnowledgeBase();
kbaseRules.addKnowledgePackages(packages);
----------------------------------------------------------------------------------------------------------------
Jackson Cunha Cassimiro (CereB)
Bacharel em Ciencia da Computação - UFPI
MSN: jackson.cereb(a)gmail.com
Telefone Móvel +55 86 9928 1251
Analista de Sistemas - Infoway - http://www.infoway-pi.com.br
Missão Infoway - "Influenciar a Gestão de Sistemas de Saúde através de
e-health"
("A vida é um combate que os fracos abate, aos bravos, aos fortes só pode
exaltar" - Canção do Tamoio, Gonçalves Dias)
----------------------------------------------------------------------------------------------------------------
12 years, 1 month
refactoring "complex" conditon to use "in" operator
by Cotton, Ben
Hi,
The following rule is working well.
rule "foo"
when
Message(_initialStubRate == "1.0") ||
Message(_initialStubRate == "2.0") || (
Message(_initialStubRate >= "4.0") &&
Message(_initialStubRate <= "44.0")
) ||
Message(_initialStubRate == "52.0")
then
System.out.println("foo");
End
To make this logic more amenable to being generically rendered via .DRT template, I want to simplify this rule . Consider the following re-factoring.
rule "bar"
when
Message(_initialStubRate in (
'1.0',"2.0",
"4.0","5.0","6.0","7.0","8.0","9.0","10.0", "11.0", "12.0","13.0",
"14.0","15.0","16.0","17.0","18.0","19.0","20.0", "21.0", "22.0","23.0",
"24.0","25.0","26.0","27.0","28.0","29.0","30.0", "31.0", "32.0","33.0",
"34.0","35.0","36.0","37.0","38.0","39.0","40.0", "41.0", "42.0","43.0",
"44.0",
"52.0")
)
then
System.out.println("bar");
end
This re-facotred rule produces a syntax error in Eclipse's .DRL view.
BuildError: Unable to Analyse Expression _initialStubRate == "1.0" || _initialStubRate == "2.0" || _initialStubRate == "4.0" || _initialStubRate == "5.0" || _initialStubRate == "6.0" || _initialStubRate == "7.0" || _initialStubRate == "8.0" || _initialStubRate == "9.0" || _initialStubRate == "10.0" || _initialStubRate == "11.0" || _initialStubRate == "12.0" || _initialStubRate == "13.0" || _initialStubRate == "14.0" || _initialStubRate == "15.0" || _initialStubRate == "16.0" || _initialStubRate == "17.0" || _initialStubRate == "18.0" || _initialStubRate == "19.0" || _initialStubRate == "20.0" || _initialStubRate == "21.0" || _initialStubRate == "22.0" || _initialStubRate == "23.0" || _initialStubRate == "24.0" || _initialStubRate == "25.0" || _initialStubRate == "26.0" || _initialStubRate == "27.0" || _initialStubRate == "28.0" || _initialStubRate == "29.0" || _initialStubRate == "30.0" || _initialStubRate == "31.0" || _initialStubRate == "32.0" || _initialStubRate == "33.0" || _initialStubRate == "34.0" || _initialStubRate == "35.0" || _initialStubRate == "36.0" || _initialStubRate == "37.0" || _initialStubRate == "38.0" || _initialStubRate == "39.0" || _initialStubRate == "40.0" || _initialStubRate == "41.0" || _initialStubRate == "42.0" || _initialStubRate == "43.0" || _initialStubRate == "44.0" || _initialStubRate == "52.0":
[Error: no such identifier: _initialStubRate]
[Near : {... _initialStubRate == "1.0" || _ ....}]
^
[Line: 1, Column: 1]
What could be wrong?
Ben D Cotton III
Morgan Stanley & Co.
OTC Derivatives Clearing Technology
1221 AOTA Rockefeller Ctr - Flr 27
New York, NY 10020
(212)762.9094
ben.cotton(a)ms.com<mailto:ben.cotton@ms.com>
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
12 years, 1 month
physically view the .DRL file generated by .DRT?
by Cotton, Ben
Section 2.4.7 of the Drools Expert User's Guide shows how to generate a .DRL from an .XLS rules base via .drt template processing. Is this generated .DRL representation physically generated as a real .DRL file in the file system Or is it logically generated in the runtime and not physically written to the underlying file system?
Ben D Cotton III
Morgan Stanley & Co.
OTC Derivatives Clearing Technology
1221 AOTA Rockefeller Ctr - Flr 27
New York, NY 10020
(212)762.9094
ben.cotton(a)ms.com<mailto:ben.cotton@ms.com>
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
12 years, 1 month
regarding JBOSS Clustering
by Athul K
I was trying to cluster a jboss 5.1 server locally with the nodes under the
same instance
After the configuration changes one of the server is working fine
While starting the second server startup is getting stuck at this point
Kindly let me know if anywhere else do I have to make the changes.
---------------------------------------------------------
GMS: address is 127.0.0.1:55400 (cluster=DefaultPartition)
---------------------------------------------------------
17:22:02,255 INFO [PlatformMBeanServerRegistration] JBossCache MBeans were
successfully registered
to the platform mbean server.
17:22:02,318 INFO [STDOUT]
---------------------------------------------------------
GMS: address is 127.0.0.1:55400 (cluster=DefaultPartition-HAPartitionCache)
---------------------------------------------------------
--
Thanks and Regards
Athul
12 years, 1 month
Clustered Guvnor performance issue
by worldofprasanna
Hi,
We have set the clustered environment with 2 nodes for guvnor and we used
Oracle Database as journal. We are experiencing performance issues, like
even to navigate between the cells in decision table it takes avg of 5-7
secs.
We followed the guidelines given in jackrabbit site to set up the clustered
repository and the link is,
http://wiki.apache.org/jackrabbit/Clustering
We doubt whether this clustering is the cause for this performance issue coz
we didn t find any issues in the forum related to the performance of Guvnor
? Can anyone give recommended procedure for clustering guvnor. We found that
there is a task to create cluster repository, but didn t find much
information about drools-ant task. Can we get some example for configuring
drools-ant ?
Also can we know whether there will be any difference in performance if File
Journal is used instead of Database Journal? There ll not be concurrent
access to both the guvnor application.
Thanks,
Prasanna Venkataraman.
--
View this message in context: http://drools.46999.n3.nabble.com/Clustered-Guvnor-performance-issue-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Decision table loading : java.lang.VerifyError
by Mahadevappa, Shobha
Hi,
Can anybody please throw some light on this error. I am not sure why I am getting this?
java.lang.VerifyError: (class: com/keane/nREAP/util/generatedclasses/Rule_VerificationAShobha_13_0, method: defaultConsequence signature: (Lorg/drools/spi/KnowledgeHelper;Lcom/keane/nREAP/util/generatedclasses/LOG1;Lorg/drools/FactHandle;)V) Incompatible object argument for function call
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at org.codehaus.janino.ReflectionIClass.getDeclaredIMethods2(ReflectionIClass.java:65)
at org.codehaus.janino.IClass.getDeclaredIMethods(IClass.java:111)
at org.codehaus.janino.IClass.getDeclaredIMethods(IClass.java:130)
at org.codehaus.janino.UnitCompiler.getIMethods(UnitCompiler.java:5962)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5919)
at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:5862)
at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:3124)
at org.codehaus.janino.UnitCompiler.access$6300(UnitCompiler.java:108)
at org.codehaus.janino.UnitCompiler$10.visitMethodInvocation(UnitCompiler.java:2579)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2650)
at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:2599)
at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:3535)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2084)
at org.codehaus.janino.UnitCompiler.access$3800(UnitCompiler.java:108)
at org.codehaus.janino.UnitCompiler$7.visitMethodInvocation(UnitCompiler.java:2058)
at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:2650)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:2078)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1184)
at org.codehaus.janino.UnitCompiler.access$800(UnitCompiler.java:108)
at org.codehaus.janino.UnitCompiler$4.visitExpressionStatement(UnitCompiler.java:739)
at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:1339)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:758)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:777)
at org.codehaus.janino.UnitCompiler.access$700(UnitCompiler.java:108)
at org.codehaus.janino.UnitCompiler$4.visitBlock(UnitCompiler.java:738)
at org.codehaus.janino.Java$Block.accept(Java.java:1280)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:758)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1783)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:723)
at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:705)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:431)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:329)
at org.codehaus.janino.UnitCompiler$3.visitPackageMemberClassDeclaration(UnitCompiler.java:302)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:703)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:308)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:286)
at org.codehaus.janino.Compiler.compile(Compiler.java:496)
at org.drools.commons.jci.compilers.JaninoJavaCompiler.compile(JaninoJavaCompiler.java:171)
at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:368)
at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:53)
at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:70)
at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:790)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:749)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:338)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:567)
Regards,
Shobha M | Senior Program Manager, A&AD | NTT DATA Global Delivery Services Limited| w. +91-80-26659482 (Ext 3679) | v. 8814.3679 | m. +91.9972522743 | shobha.mahadevappa(a)nttdata.com<mailto:shobha.mahadevappa@nttdata.com>
______________________________________________________________________
Disclaimer:This email and any attachments are sent in strictest confidence for the sole use of the addressee and may contain legally privileged, confidential, and proprietary data. If you are not the intended recipient, please advise the sender by replying promptly to this email and then delete and destroy this email and any attachments without any further use, copying or forwarding
12 years, 1 month
transaction rollback makes the knowledge session multiplicate the timers when executing a processs that has timers bound to human tasks
by Alberto R. Galdo
Attached you can find a test case that has the following behaviour:
First, there is a process that has two script tasks and one human task that
has bounded an interrupting timer.
The test case, first configures a persistent environment using Bitronix and
H2 ( this has been tested also using JBoss and PostgreSQL ), then a
knowledgebase is configured using the previous BPMN process definition,
then human task service and persistence are configured along with the
defautl human task handler, and an StatefulKnowledgeSession is created.
Then there's a loop of 10 cycles of:
- Begin transaction
- Start the process ( then it executes until the timer waits for 30 days
)
- commit or rollback ( if cycle % 2 )
After that, the serialized KnowledgeSession is retrieved from the database
using just JDBC, and then is rehydrated using ProtobufMarshaller.
Well, what you will be able to see is that rolling back transactions that
involved executing a process that had timers inside, made the timers
multiplicate in the session. ( You can see this by placing a breakpoint
into "ProtobufInputMarshaller [line: 154] -
readSession(MarshallerReaderContext, int, ExecutorService, Environment,
SessionConfiguration) " and inspecting the contents of the variable
_session ).
>From the code it is expected to find just 5 timers persisted, but when
rehydrating the session one can see that were created 46 timers !!. This is
really weird, but it is weirder to find that there is some kind of pattern
).
If you take a look at what is inside the protocol buffers serialized
version of the knowledge session you can find that there's a direct
relation between the groups in the focus_stack, which in the example is:
focus_stack {
group_name: "MAIN"
group_name: "MAIN"
group_name: "MAIN"
group_name: "MAIN"
group_name: "MAIN"
}
and the number of repetitions of each timer ( associated with each process
instance ) are multiple of the number of group_names in the agenda. For
example if there are 5 items in the focus_stack there will be no more than
2^4 ( 16 ) repetitions of each timer. But all timers are congruent with
2^x-1 where x is the number of group_name in the agenda.
In fact, if you leave the timer behind ( just by changing the process ) you
will still be able to find that when executed there are 5 !! group_name
inside the focus_stack.
I've created a bug in Jira JBPM-3831 :
https://issues.jboss.org/browse/JBPM-3831
Any insight?
Alberto R. Galdo
argaldo(a)gmail.com
12 years, 1 month
taskName does not allow special characters
by eselis
Hello,
I have an application that use Guvnor 5.4.0 final as a process repository
running in a JBOSS-EAPv6, BPMN2 processes are designed with Orix (v2.3.0),
both are running in a JBOSS-EAPv6.
In addition I have another app which consumes processes from Guvnor (running
in another Jboos-EAPv6) which lists tasks.
When I created a BPMN2 process, I used different type of tasks, but for
/TaskType=User/ I have two names to define: the name (which is visualized in
the designer) and the TaskName.
I can't use the same name because TaskName (inside ORIX) does not allow
special characters (spaces and accents) for example "Llamada al médico". If
I use a TaskName with special characters, then when I want to validate the
process, it fails due to /User Task has no task form defined/ and if I
define the form, changes are not saved.
So, my "solution" is to use diferent names (one for visualization and
another one for the taskname used by jbpm). But when I have to listed the
tasks in my app I need the name displayed in the designer (the one that is
visualized in the designer, and is listed within the Common area inside the
Task properties). I here is my problem, because I can get the nodes to have
the name attribute, but neither Task nor TaskSummary has a link to the node.
Any ideas?
Thanks in advance,
--
View this message in context: http://drools.46999.n3.nabble.com/taskName-does-not-allow-special-charact...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 1 month
Re: [rules-users] ClassNotFound on class defined in drl with 5.5.0.CR1
by Willem van Asperen
Hi,
This was a good idea. Here is my test case:
public class TestCompilation {
private final static FileFilter RULES_FILES_FILTER = new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().endsWith(".drl");
}
};
private void testCompilation() throws FileNotFoundException,
IOException {
KnowledgeBuilderConfiguration configuration =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(configuration);
File folder = new File("src/main/rules/");
for (File file : folder.listFiles(RULES_FILES_FILTER)) {
System.out.println("compiling "+file.getAbsolutePath());
kbuilder.add(ResourceFactory.newFileResource(file.getAbsolutePath()),
ResourceType.DRL);
}
System.out.println("saving");
ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream("test.drl.compiled"));
out.writeObject( kbuilder.getKnowledgePackages());
out.close();
}
private KnowledgeBase testLoad() throws FileNotFoundException,
IOException, ClassNotFoundException {
Properties configProperties = new Properties();
KnowledgeBaseConfiguration knowledgeBaseConfiguration =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(configProperties);
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(knowledgeBaseConfiguration);
ObjectInputStream in = new ObjectInputStream(new
FileInputStream("test.drl.compiled"));
System.out.println("loading");
kbase.addKnowledgePackages((Collection<KnowledgePackage>) in.readObject());
return kbase;
}
public static void main(String[] args) throws
FileNotFoundException, IOException, ClassNotFoundException {
TestCompilation testCompilation = new TestCompilation();
testCompilation.testCompilation();
testCompilation.testLoad();
}
}
The folder src/main/rules consists of a number of .drl files.
Compiling works fine.
This is the output:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
further details.
compiling
/home/willem/development/workspace/VCM/src/main/rules/planner-lock.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/executable-action-selection.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/block-times-3.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/planner-bridge.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/routeplan.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/shift-management-brabant.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/plan-first-object-in-route.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/operator-lock.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/block-times-route-call.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/shift-management.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/planner-process-data.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/plan-last-moment.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/operator-bridge.drl
compiling
/home/willem/development/workspace/VCM/src/main/rules/operator-management.drl
saving
loading
Exception in thread "main" java.lang.ClassNotFoundException:
vcm.planner.lock.standard.PossibleSlotLock
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at
org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:85)
at
org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:97)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1480)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1330)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at
org.drools.rule.ConsequenceMetaData$Statement.readExternal(ConsequenceMetaData.java:61)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.util.ArrayList.readObject(ArrayList.java:733)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at
org.drools.rule.ConsequenceMetaData.readExternal(ConsequenceMetaData.java:19)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at org.drools.rule.Rule.readExternal(Rule.java:207)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at
org.drools.rule.JavaDialectRuntimeData.readExternal(JavaDialectRuntimeData.java:195)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.util.HashMap.readObject(HashMap.java:1155)
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:601)
at
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at
org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:58)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at org.drools.rule.Package.readExternal(Package.java:208)
at
org.drools.definitions.impl.KnowledgePackageImp.readExternal(KnowledgePackageImp.java:157)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.util.ArrayList.readObject(ArrayList.java:733)
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:601)
at
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at
com.paconsulting.pase.test.TestCompilation.testLoad(TestCompilation.java:57)
at
com.paconsulting.pase.test.TestCompilation.main(TestCompilation.java:64)
The class PossibleSlotLock is just a locally declared fact class. It is
only being used in that particular .drl file. Every .drl file has it's
own package name.
The head of the .drl file:
package vcm.planner.lock.standard;
import java.util.Set;
import com.paconsulting.pase.core.schedule.CurrentTime;
import com.paconsulting.pase.core.duration.FixedDuration;
import com.paconsulting.pase.transport.agents.ScheduleManagingContainer;
import com.paconsulting.pase.transport.agents.movers.Ship;
import com.paconsulting.pase.transport.agents.water.Lock;
import com.paconsulting.pase.transport.agents.water.LockChamber;
import com.paconsulting.pase.transport.agents.base.WaterLevel;
import com.paconsulting.pase.transport.components.action.ActionFactory;
import com.paconsulting.pase.transport.actions.IAction;
import com.paconsulting.pase.transport.components.action.IActionable;
import com.paconsulting.pase.transport.actions.NonTransactionAction;
import com.paconsulting.pase.transport.actions.ExecutableAction;
import com.paconsulting.pase.transport.components.containing.IContainer;
import
com.paconsulting.pase.transport.components.containing.IContainer.UpDown;
import com.paconsulting.pase.transport.components.moving.IMover;
import com.paconsulting.pase.transport.components.moving.TransferSchedule;
import com.paconsulting.pase.transport.components.moving.ToScheduleLock;
declare PossibleSlotLock
ship : IMover
chamber : IContainer
side : IContainer.UpDown
schedule : TransferSchedule
eta : double
at : double
cause : String
end
....
Same issue like in my previous email, different class that cannot be found.
This works in 5.4.0.Final
Any clue?
This seems to me like a really basic thing so either I am missing the
plot somehow or no-one has yet used a locally declared fact classes -
which I think is just not true...
Regards,
Willem
On 10/24/2012 07:29 PM, Wolfgang Laun wrote:
> It would be interesting to know (and perhaps help to isolate the problem
> apparently introduced in 5.5.0) if you could try and compile and
> serialize into a single file, and load that in a single readObject.
>
> -W
>
> On 24/10/2012, Willem van Asperen <willem(a)van.asperen.org> wrote:
>> Hi Wolfgang,
>>
>> Thanks for picking this up. I am indeed compiling these separate .drl
>> files into separate .drl.compiled files and then creating a kbase using
>> addKnowledgePackages on the individual .drl.compiled files.
>>
>> But: the classes declared in some of by .drl files are only going to be
>> used in that particular .drl file - not anywhere else.
>> Also: this did work in 5.4.0.Final but now has given up on me.
>>
>> Point is that I need to be flexible in mixing different .drl.compiled
>> files into a kbase, based on user specifications.
>> Alternative is that I do not pre-compile these .drl files and only
>> compile them, in combination, in the mix that is required by the user...
>> If that would solve the problem... But it seems to be more cumbersome...
>>
>> Regards,
>> Willem
>>
>> On 10/24/2012 03:39 PM, Wolfgang Laun wrote:
>>> The code you use for loading where you load many .pkg files isn't
>>> quite the counterpart for compiling where you compile one DRL.
>>>
>>> Do you compile and output the .drl files one by one? Apparently you
>>> load them individually?
>>>
>>> Try compiling them all, and then take the Collection<KnowledgePackage>
>>> and writeObject it to a single .pkg from which you load them in one
>>> go.
>>>
>>> Could it be that the type declared in one .drl is used in another .drl
>>> in the same package? Reading this in the wrong order might cause the
>>> CNF.
>>>
>>> -W
>>>
>>> On 24/10/2012, Willem van Asperen <willem(a)van.asperen.org> wrote:
>>>> Dear All,
>>>>
>>>> I use the Drools compiler to compile a set of drl files:
>>>>
>>>>
>>>> KnowledgeBuilder kbuilder =
>>>> KnowledgeBuilderFactory.newKnowledgeBuilder(configuration);
>>>> kbuilder.add(ResourceFactory.newFileResource(fileName),
>>>> ResourceType.DRL);
>>>>
>>>> KnowledgeBuilderErrors errors = kbuilder.getErrors();
>>>> if (errors.size() > 0) {
>>>> for (KnowledgeBuilderError error: errors) {
>>>> logger.error(error);
>>>> }
>>>> throw new IllegalArgumentException("Could not parse
>>>> knowledge.");
>>>> }
>>>>
>>>> ObjectOutputStream out = new ObjectOutputStream(new
>>>> FileOutputStream(fileName+".compiled"));
>>>> out.writeObject( kbuilder.getKnowledgePackages());
>>>> out.close();
>>>>
>>>> I then load these *.compiled files into my application:
>>>>
>>>>
>>>> for (String packageName : packages) {
>>>> InputStream is =
>>>> getClass().getResourceAsStream("/"+packageName+".drl.compiled");
>>>> if (is != null) {
>>>> logger.debug("adding package '"+packageName+"'");
>>>> ObjectInputStream in = new ObjectInputStream(is);
>>>> kbase.addKnowledgePackages((Collection<KnowledgePackage>)
>>>> in.readObject());
>>>> in.close();
>>>> } else
>>>> throw new FileNotFoundException("could not find
>>>> resource for package "+packageName);
>>>> is.close();
>>>> }
>>>>
>>>> In some of these drl files I declare a class, for instance:
>>>>
>>>> package vcm.selection.standard;
>>>>
>>>> import com.paconsulting.pase.transport.agents.ShiftWorker;
>>>> import com.paconsulting.pase.transport.agents.VCMShiftWorker;
>>>> import com.paconsulting.pase.transport.actions.ExecutableAction;
>>>> import com.paconsulting.pase.transport.agents.ScheduleManagingContainer;
>>>> import com.paconsulting.pase.transport.agents.water.Bridge;
>>>> import com.paconsulting.pase.transport.agents.movers.AbstractMover;
>>>> import com.paconsulting.pase.transport.agents.movers.Ship;
>>>> import com.paconsulting.pase.transport.agents.movers.VCMShip;
>>>>
>>>> declare RelevantExecutableAction
>>>> agent : ShiftWorker
>>>> executableAction : ExecutableAction
>>>> end
>>>> ...
>>>>
>>>> When running the
>>>> kbase.addKnowledgePackages((Collection<KnowledgePackage>)
>>>> in.readObject()) I get the following ClassNotFound stack trace:
>>>>
>>>> java.lang.ClassNotFoundException:
>>>> vcm.selection.standard.RelevantExecutableAction
>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
>>>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>>>> at java.lang.Class.forName0(Native Method)
>>>> at java.lang.Class.forName(Class.java:264)
>>>> at
>>>> org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:85)
>>>> at
>>>> org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:97)
>>>> at
>>>> java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
>>>> at
>>>> java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
>>>> at
>>>> java.io.ObjectInputStream.readClass(ObjectInputStream.java:1480)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1330)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at
>>>> org.drools.rule.ConsequenceMetaData$Statement.readExternal(ConsequenceMetaData.java:61)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at java.util.ArrayList.readObject(ArrayList.java:733)
>>>> 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:601)
>>>> at
>>>> java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
>>>> at
>>>> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at
>>>> org.drools.rule.ConsequenceMetaData.readExternal(ConsequenceMetaData.java:19)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at org.drools.rule.Rule.readExternal(Rule.java:207)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at
>>>> org.drools.rule.JavaDialectRuntimeData.readExternal(JavaDialectRuntimeData.java:195)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at java.util.HashMap.readObject(HashMap.java:1155)
>>>> at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> at java.lang.reflect.Method.invoke(Method.java:601)
>>>> at
>>>> java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
>>>> at
>>>> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at
>>>> org.drools.rule.DialectRuntimeRegistry.readExternal(DialectRuntimeRegistry.java:58)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at org.drools.rule.Package.readExternal(Package.java:208)
>>>> at
>>>> org.drools.definitions.impl.KnowledgePackageImp.readExternal(KnowledgePackageImp.java:157)
>>>> at
>>>> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1810)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at java.util.ArrayList.readObject(ArrayList.java:733)
>>>> 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:601)
>>>> at
>>>> java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
>>>> at
>>>> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
>>>> at
>>>> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>>>> at
>>>> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>>>> at
>>>> java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.definition.KnowledgebaseDefinition.addPackages(KnowledgebaseDefinition.java:48)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.definition.KnowledgebaseDefinition.materialize(KnowledgebaseDefinition.java:59)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.definition.TeamDefinition.materialize(TeamDefinition.java:97)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.definition.OperatingModelDefinition.materialize(OperatingModelDefinition.java:36)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.Run.<init>(Run.java:31)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.definition.RunDefinition.materialize(RunDefinition.java:53)
>>>> at
>>>> com.paconsulting.pase.core.configuration.runconfig.RunConfigExecutor$ScheduleExecutorWrapper.run(RunConfigExecutor.java:69)
>>>> ...
>>>>
>>>> I'm sure I miss something as this is basic functionality. Maybe I must
>>>> tell the kbase where to load the classes...
>>>>
>>>> Can someone point me in the right direction?
>>>>
>>>> Thanks,
>>>> Willem
>>>>
>>>> _______________________________________________
>>>> 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
>>
12 years, 1 month