[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2030) NPE due to missing import for fact type

Mark Proctor (JIRA) jira-events at lists.jboss.org
Sat Mar 28 01:16:22 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-2030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12459460#action_12459460 ] 

Mark Proctor commented on JBRULES-2030:
---------------------------------------

I can't recreate this with trunk I made the following unit test, where Cheese exists and MissingClass doesn't:
    public void testMissingImport() throws Exception {
        String str = "";
        str += "package org.drools \n";
        str += "import org.drools.Person\n";
        str += "global java.util.List list \n";
        str += "rule rule1 \n";
        str += "when \n";
        str += "    $i : Cheese() \n";
        str += "         MissingClass( fieldName == $i ) \n";
        str += "then \n";
        str += "    list.add( $i ); \n";
        str += "end \n";

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        kbuilder.add( ResourceFactory.newByteArrayResource( str.getBytes() ),
                      ResourceType.DRL );

        if ( kbuilder.hasErrors() ) {
            System.err.println( kbuilder.getErrors() );
        }
        assertTrue( kbuilder.hasErrors() );
    }  

And i get a resulting printout, and no NPE.
Unable to resolve ObjectType 'MissingClass' : [Rule name='rule1']

Please provide more information on how to recreate this.

> NPE due to missing import for fact type
> ---------------------------------------
>
>                 Key: JBRULES-2030
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2030
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler (expert)
>    Affects Versions: 5.0.0.CR1
>            Reporter: Wolfgang Laun
>            Assignee: Mark Proctor
>             Fix For: 5.0.0.GA
>
>
> Missing import for IntersectionType causes NPE
> rule updateMg2
>     when
>         $m : MsgMg2( $x25No : x25No )
>         $s : IntersectionType( x25No == $x25No )
>     then
> end
> Exception in thread "main" java.lang.NullPointerException
> 	at org.drools.spi.DeclarationScopeResolver.getDeclarationClasses(DeclarationScopeResolver.java:203)
> 	at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:65)
> 	at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86)
> 	at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1191)
> 	at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:662)
> 	at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:296)
> 	at rss.bfz.engine.impl.DroolsEngine.loadSourceRules(DroolsEngine.java:37)
> 	at rss.bfz.init.Main.exec(Main.java:25)
> 	at rss.bfz.init.Main.main(Main.java:31)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list