Hi,
I hope someone can help me with this.
I are running Drools 5.0.0.CR1 using JANINO to compile a spreadsheet
into rules. I have lots of tests that prove the compilation is working
properly and the rules are correct.
Every now and then (twice in two months) we have had the following
exception start appearing and the rules stop working at all. The error
occurs after the system has been running for a while and at a point in
the application that has been visited many many times before the error
appears.
Caused by: java.lang.OutOfMemoryError
2010-02-16 02:28:38,143 ERROR [STDERR] at
java.util.zip.ZipFile.open(Native Method)
2010-02-16 02:28:38,143 ERROR [STDERR] at
java.util.zip.ZipFile.<init>(ZipFile.java:203)
2010-02-16 02:28:38,143 ERROR [STDERR] at
java.util.jar.JarFile.<init>(JarFile.java:132)
2010-02-16 02:28:38,143 ERROR [STDERR] at
java.util.jar.JarFile.<init>(JarFile.java:97)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org
.apache
.catalina.loader.WebappClassLoader.openJARs(WebappClassLoader.java:1724)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org
.apache
.catalina
.loader.WebappClassLoader.findResources(WebappClassLoader.java:991)
2010-02-16 02:28:38,143 ERROR [STDERR] at
java.lang.ClassLoader.getResources(ClassLoader.java:1015)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.util.ChainedProperties.getResources(ChainedProperties.java:
155)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:79)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:41)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:35)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.SessionConfiguration.init(SessionConfiguration.java:112)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org.drools.SessionConfiguration.<init>(SessionConfiguration.java:106)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org
.drools
.reteoo
.ReteooStatelessSession.newWorkingMemory(ReteooStatelessSession.java:86)
2010-02-16 02:28:38,143 ERROR [STDERR] at
org
.drools
.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:185)
2010-02-16 02:28:38,143 ERROR [STDERR] at
com
.base2
.ecm.just.service.product.LocalRulesEngine.apply(LocalRulesEngine.java:
49)
2010-02-16 02:28:38,143 ERROR [STDERR] at
com
.base2
.ecm
.just
.service
.product
.PublishingDetailsServiceImpl
.getPublishingDetails(PublishingDetailsServiceImpl.java:41)
Here is the code:
private static RuleBase ruleBase;
public void apply(PublishingDetails publishingDetails,
Advertisement advertisment)
{
StatelessSession statelessSession = getStatelessSession();
statelessSession.setGlobal("du",new DateUtils());
Object[] facts = {publishingDetails, advertisment};
statelessSession.execute(facts);
}
public void apply(Publication publication)
{
StatelessSession statelessSession = getStatelessSession();
statelessSession.setGlobal("du",new DateUtils());
statelessSession.execute(publication);
}
private StatelessSession getStatelessSession()
{
if (ruleBase == null)
{
initRuleBase();
}
StatelessSession statelessSession =
ruleBase.newStatelessSession();
return statelessSession;
}
private void initRuleBase()
{
Properties properties = new Properties();
properties.setProperty("drools.dialect.java.compiler",
"JANINO");
PackageBuilderConfiguration conf = new
PackageBuilderConfiguration(properties);
PackageBuilder builder = new PackageBuilder(conf);
try
{
SpreadsheetCompiler compiler = new SpreadsheetCompiler();
String drl = compiler.compile(getSpreadsheetStream(),
InputType.XLS);
builder.addPackageFromDrl(new StringReader(drl));
}
catch (DroolsParserException e)
{
throw new RuntimeException("DroolsParserException when
parsing the drools package", e);
}
catch (IOException e)
{
throw new RuntimeException("IOException when loading the
drools package", e);
}
PackageBuilderErrors errors = builder.getErrors();
if (errors != null && !errors.isEmpty())
{
for (KnowledgeBuilderError error : errors)
{
LOG.error(error.getMessage());
}
throw new RuntimeException("There were errors in the drl
file");
}
Package pkg = builder.getPackage();
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
}
As I said before the loading of the rules is OK. I'm wondering if
keeping a static reference to the RuleBase might be the issue?
The exception looks like Drools is trying to load a jar file at
runtime. Maybe there is a problem with the container (Jboss 4.2.2)?
If someone could confirm that I'm not doing anything wrong by keeping
a static reference to the RuleBase that would be appreciated. Note
that the system runs perfectly and then starts throwing this exception
with no apparent pattern to the failure.
Cheers
James