I am facing a tough problem requiring some abnormal solutions: The requirements calls for million rules (they all think about that at the beginning), so we are thinking about packaging rules on the fly during execution instead caching all the rules in the rules engine.  All the rules will be pre-compiled and serialized to storage.  We would like to achieve to separate the Package and Rule's objects, and dynamically compose the Package object when needed.
 
I tried the following steps and was enable to move forward beyond step 5:
1.  Create the Package object by using PackageBuilder().addPackageFromDrl(drl_file).
2.  For each rule under the Package object, remove it from Package by calling Package().removeRule(rule), then serialize it to storage.
3.  Serialize the now empty Package object to storage.
<!-- when recompose the Package object, perform the following steps -->
4.  Deserialize the Package.
5.  Deserialize the Rule objects - this is where I encountered an ClassNotFoundException at the end of the message
6.  Using Package().addRule(rule) to add needed rules - not tried yet.
7.  Add the package to RuleBase..... as normally do.
 
java.lang.ClassNotFoundException: com.travelocity.rules.hotel.Rule_Match_Region_Rule_1_0ConsequenceInvoker
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:242)
 at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
 at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
 at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
 at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
 at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
 at com.travelocity.common.util.IOUtil.readObject(IOUtil.java:158)
 at com.travelocity.common.util.IOUtil.readObject(IOUtil.java:147)
 at com.travelocity.rules.hotel.HotelChargeRulesUnitTest.loadPackage(HotelChargeRulesUnitTest.java:64)
 at com.travelocity.rules.hotel.HotelChargeRulesUnitTest.testHotelChargeRequest(HotelChargeRulesUnitTest.java:41)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
 
In the application, the rule name is "Match Region Rule 1", and the package name is "com.travelocity.rules.hotel".  Please advise if it is possible to get around this problem, or if this approach would really work?
 
Your help is greatly appreciated.
-Ming