[rules-dev] [rules-users] ClassNotFound on class defined in drl with 5.5.0.CR1

Mario Fusco mario.fusco at gmail.com
Mon Oct 29 07:34:31 EDT 2012


I just pushed the fix for the issue you found.

Regards and thank you again for having pointed it out,
Mario


> Hi All,
>
> As a first time GIT user... I think I have manager to "pull this off"
> and submitted a pull request for a test case in the drools-compiler
> project. This should add one file in src/test/ in the package
> org.drools.compiler.integration as I deemed that to be the most
> appropriate place.
>
> Regards,
> Willem
>
> On 10/26/2012 06:37 AM, Mark Proctor wrote:
> > Would it be possible to submit a small self contains test, as a pull
> request. Here a detailed "how to" to get you started.
> >
> http://docs.jboss.org/drools/release/5.4.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html
> >
> > Thanks
> >
> > Mark
> > On 25 Oct 2012, at 12:09, Willem van Asperen <willem at van.asperen.org>
> wrote:
> >
> >> Hi All,
> >>
> >> I have taken the liberty to log this in Jira at
> >> https://issues.jboss.org/browse/JBRULES-3670
> >>
> >> Regards,
> >> Willem
> >>
> >> On 10/25/2012 12:44 PM, Willem van Asperen wrote:
> >>> Hi All,
> >>>
> >>> The difference between failing or not stems from using insert() and
> >>> retract() versus insertLogical(). The first two make the package fail
> to
> >>> load, the latter seems to work fine.
> >>>
> >>> I can create a package that *does* load, by adding a cast to the full
> >>> class name in the rule:
> >>>
> >>> rule "clean up possible slot lock, when no longer to schedule"
> >>>       when
> >>>           $p : PossibleSlotLock( $ship; )
> >>>           not ToScheduleLock( mover == $ship )
> >>>       then
> >>>           retract( (vcm.planner.lock.standard.PossibleSlotLock)$p );
> >>> end
> >>>
> >>> and by stating the full class name in the inserts, like so:
> >>>
> >>> insert(new vcm.planner.lock.standard.PossibleSlotLock($ship, $chamber,
> >>> $side, $schedule, $eta, $schedule.getTick(), "existing"));
> >>>
> >>> This way the loading works fine.
> >>>
> >>> So this is less about loading compiled files and more about class
> >>> loading for insert() and retract().
> >>>
> >>> Hope this helps!
> >>>
> >>> I have also managed to reproduce this in a simple case. jar attached.
> >>> Notice that when I change rule "now use it B" to have RHS "insert( new
> >>> Person( $christianName, null ) );" the loading works. I can imagine the
> >>> compiler / loader just assumes that a class with constructor Person(
> >>> String, ExternalClass ) may become available at run time?
> >>>
> >>> Regards,
> >>> Willem
> >>>
> >>> On 10/25/2012 11:32 AM, Willem van Asperen wrote:
> >>>> Hi All,
> >>>>
> >>>> To add to this, I've done some further testing.
> >>>>
> >>>> It seems that the particular order in which each of the compiled
> >>>> packages is loaded does not matter.
> >>>> Not all packages that declare local classes fail... I have now found
> the
> >>>> two that do. I cannot see any striking differences between the ones
> that
> >>>> do and do not fail...
> >>>>
> >>>> What I did find is that removing all the rules from the failing
> packages
> >>>> (so only leaving the imports and declare) seems to remove this issue!
> >>>>
> >>>> I'll dig 'round some more.
> >>>>
> >>>> Regards,
> >>>> Willem
> >>>>
> >>>> On 10/25/2012 01:45 AM, Wolfgang Laun wrote:
> >>>>> Folks,
> >>>>> it seems that something new in 5.5.0.CR1 sabotages the ingestion of
> >>>>> compiled packages.
> >>>>> -W
> >>>>>
> >>>>> ---------- Forwarded message ----------
> >>>>> From: Willem van Asperen <willem at van.asperen.org>
> >>>>> Date: Thu, 25 Oct 2012 00:04:32 +0200
> >>>>> Subject: Re: [rules-users] ClassNotFound on class defined in drl
> with 5.5.0.CR1
> >>>>> To: Wolfgang Laun <wolfgang.laun at gmail.com>, Rules Users List
> >>>>> <rules-users at lists.jboss.org>
> >>>>>
> >>>>> 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 at 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 at 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 at lists.jboss.org
> >>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
> >>>>>>>>>
> >>>>>>>> _______________________________________________
> >>>>>>>> rules-users mailing list
> >>>>>>>> rules-users at lists.jboss.org
> >>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
> >>>> _______________________________________________
> >>>> rules-dev mailing list
> >>>> rules-dev at lists.jboss.org
> >>>> https://lists.jboss.org/mailman/listinfo/rules-dev
> >> _______________________________________________
> >> rules-dev mailing list
> >> rules-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-dev
> >
> > _______________________________________________
> > rules-dev mailing list
> > rules-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-dev
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20121029/ad08b433/attachment-0001.html 


More information about the rules-dev mailing list