Unable to run "Hello World" Drools example in Eclipse: runtime exception org.drools.RuntimeDroolsException: Unable to load dialect

user396377 picture user396377 · Jul 21, 2010 · Viewed 26.3k times · Source

I just installed the Drools plug-in in Eclipse (version 3.5.2), and I am trying to run the "Hello World" example that comes with the plug-in.

When I run the code, I am getting runtime error with the following stack trace:

org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
 at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
 at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259)
 at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
 at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
 at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
 at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:142)
 at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilder(KnowledgeBuilderProviderImpl.java:29)
 at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:29)
 at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:39)
 at com.sample.DroolsTest.main(DroolsTest.java:23)
Caused by: java.lang.RuntimeException: **The Eclipse JDT Core jar is not in the classpath**
 at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:94)
 at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
 at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270)
 ... 9 more

Here is some of the relevant Java code:

public static final void main(String[] args) {
    try {
        // load up the knowledge base
        KnowledgeBase kbase = readKnowledgeBase();
    }
}

private static KnowledgeBase readKnowledgeBase() throws Exception {
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
    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;
}

Answer

Kris Verlaenen picture Kris Verlaenen · Jul 21, 2010

You're missing the eclipse JDT core jar in your classpath. If you are not using the Drools classpath container or if you manually created your own runtime, make sure that jar is part of your classpath or runtime directory. If you are using the Drools classpath container and generated a default runtime, and the JDT core jar is not there, make sure to use a recent version of the plugin that supports Eclipse 3.5.2. You can of course also just add the JDT core jar manually and recreate your runtime.

More info on runtimes can be found at http://download.jboss.org/drools/release/5.1.1.34858.FINAL/drools-5.1.1-docs.zip and open up drools-5.1.1-docs.zip\drools-flow\html\ch.Drools_Eclipse_IDE_Features.html