[rules-users] NPE in JavaDialectConfiguration

cyclemenow cyclemenow at yahoo.com
Sat Feb 28 01:35:39 EST 2009


I am getting a NullPointerException while trying to call: 

			RuleAgent ruleAgent = RuleAgent.newRuleAgent(prop);

The exception looks like this: 

13:15:08,754 ERROR [STDERR] org.drools.RuntimeDroolsException: Unable to
load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:160)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:146)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:121)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:98)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:124)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:86)
13:15:08,755 ERROR [STDERR] 	at
org.drools.compiler.SourcePackageProvider.loadPackage(SourcePackageProvider.java:22)
....
13:15:08,766 ERROR [STDERR] Caused by: java.lang.NullPointerException
13:15:08,766 ERROR [STDERR] 	at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:89)
13:15:08,766 ERROR [STDERR] 	at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:52)
13:15:08,766 ERROR [STDERR] 	at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:156)

I've made sure the eclipse compiler is definitely in the classpath.  I am
able to load that class in my code that calls into drools.  

I tracked this down to the line in the code excerpt below from
JavaDialectConfiguration.java that calls getClassLoader().  getClassLoader()
is returning a null.

I was then able to pull some info from the documentation for the Java1.5
getClassLoader() method: 

"
Returns the class loader for the class. Some implementations may use null to
represent the bootstrap class loader. This method will return null in such
implementations if this class was loaded by the bootstrap class loader.
If a security manager is present, and the caller's class loader is not null
and the caller's class loader is not the same as or an ancestor of the class
loader for the class whose class loader is requested, then this method calls
the security manager's checkPermission method with a
RuntimePermission("getClassLoader") permission to ensure it's ok to access
the class loader for the class.

If this object represents a primitive type or void, null is returned.
"

It isn't a permissions problem, since that exception isn't thrown.  The
error is clearly a null pointer, and stepping through the code after
attaching source also shows that getClassLoader() is returning a null. 
Okay, so sometimes it can return null, but how do I get my code to work?  Is
there a work around?

I'm running inside of Eclipse Ganymede, using JBoss 4.2.2.GA, Drools 4.0.7
and Java 1.5 running on MacOSX 10.5.

Thank you in advance for your help,

Matthew


-------code excerpt 
   /** 
     * Set the compiler to be used when building the rules semantic code
blocks.
     * This overrides the default, and even what was set as a system
property. 
     */
    public void setCompiler(final int compiler) {
        // check that the jar for the specified compiler are present
        if ( compiler == ECLIPSE ) {
            try {
problem line here:  getClass().getClassLoader().loadClass(
"org.eclipse.jdt.internal.compiler.Compiler" );
            } catch ( ClassNotFoundException e ) {
                throw new RuntimeException( "The Eclipse JDT Core jar is not
in the classpath" );
            }
        } else if ( compiler == JANINO ){
            try {
                getClass().getClassLoader().loadClass(
"org.codehaus.janino.Parser" );
            } catch ( ClassNotFoundException e ) {
                throw new RuntimeException( "The Janino jar is not in the
classpath" );
            }
        }



-- 
View this message in context: http://www.nabble.com/NPE-in-JavaDialectConfiguration-tp22255233p22255233.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list