Perhaps for the benefit of the community, u could share the knowledge and
list down the actions taken, eg which jar files u missed/misspelled etc.
Just that it's kinda weird that 'null pointer' exceptions is displayed if
jar files not found. Expecting more like 'class not found' exception

-----Original Message-----
From: Khairul Anwar [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 14, 2006 12:27 PM
To: user@drools.codehaus.org
Subject: Re: [drools-user] NullPointerException using
builder.addPackagerFromDrl(source)

Hi, just got it solved. Never thought that the exception caused by a missing
package name. Very frustrating mistake.

Thank you very much Michael and Ishafizan.

On 4/14/06, Ishafizan Ishak <[EMAIL PROTECTED]> wrote:
>
> Hi,
> Can u try a simple helloWorld rule call (or a rule that u worked on and
> works) ? Ie public final static String AUTH_RULE_FILE_LOGIN =
> "myHelloWorld.drl"...then do a readRule(), plus could use the eclipse
> debugger to see where it fails too.
>
>
>
> -----Original Message-----
> From: Khairul Anwar [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 14, 2006 11:20 AM
> To: user@drools.codehaus.org
> Subject: Re: [drools-user] NullPointerException using
> builder.addPackagerFromDrl(source)
>
> Here it is. Is it any possibilities the exception is caused by drl file?
> If
> any object used in drl file is null, the exception will be thrown at
> workingMemory.assertObject() right?
>
> Sorry, a total newbie here.
>
> #list any import classes here.
> import com.Session
> import com.SystemConfig
> import com.AuthorizationStateManager
>
> #declare any global variables here
>
>
> rule "If user is in session"
>     salience -1
>     #include attributes such as "salience" here...
>     when
>         #conditions
>         asm : AuthorizationStateManager()
>         Session(cntUserIdInSession>0)
>     then
>         #actions
>         asm.setUserIsInSession(true);
>         //drools.modifyObject(asm);
> end
>
>
> rule "Login: To allow access or not"
>     when
>         #conditions
>         asm : AuthorizationStateManager()
>         AuthorizationStateManager(userIsInSession==true)
>     then
>         #actions
>         asm.setAccessAllowedBool(false);
> end
>
>
> On 4/13/06, Michael Neale <[EMAIL PROTECTED]> wrote:
> >
> > Can you also post the rule(s) you are trying to run?
> >
> > On 4/13/06, Khairul Anwar <[EMAIL PROTECTED]> wrote:
> > >
> > > here is the code
> > >
> > >        private static RuleBase ruleBase;
> > >     public final static String AUTH_RULE_FILE_LOGIN = "
> > > ruleAuthorization.drl
> > > ";
> > >
> > > RuleAuthorization()
> > > {
> > >         WorkingMemory workingMemory = null;
> > >         if (ruleBase != null) {
> > >             System.out.println("rulebase not null : "+
> ruleBase.toString
> > > ());
> > >             workingMemory = ruleBase.newWorkingMemory();
> > >         } else {
> > >             ruleBase = readRule();
> > >             workingMemory = ruleBase.newWorkingMemory();
> > >         }
> > >
> > >
> > >         workingMemory.assertObject(asm);
> > >         workingMemory.assertObject(ss.getCntUserIdInSession());
> > >         workingMemory.assertObject(ss);
> > >         // fire rules
> > >         workingMemory.fireAllRules();
> > >
> > >     }
> > >
> > >
> > >
> > >     private static RuleBase readRule() throws Exception {
> > >         // read in the source
> > >         System.out.println("Enter readRule");
> > >
> > >         Reader source = new InputStreamReader(RuleAuthorization.class
> > >                 .getResourceAsStream(AUTH_RULE_FILE_LOGIN));
> > >
> > >         if (RuleAuthorization.class.getResourceAsStream
> > > (AUTH_RULE_FILE_LOGIN)
> > > != null) {
> > >             System.out.println("not null");
> > >         } else {
> > >             System.out.println("null");
> > >         }
> > >
> > >         PackageBuilder builder = new PackageBuilder();
> > >         try {
> > >             // builder.addPackage(pdscr);
> > >             builder.addPackageFromDrl(source);
> > >         } catch (Exception ex) {
> > >             // System.out.println("So the builder is : " +
> > >             // builder.getPackage());
> > >             ex.printStackTrace();
> > >         }
> > >
> > >
> > >         Package pkg = builder.getPackage();
> > >
> > >         // add the package to a rulebase (deploy the rule package).
> > >         ruleBase = RuleBaseFactory.newRuleBase();
> > >         ruleBase.addPackage(pkg);
> > >
> > >         return ruleBase;
> > >     }
> > >
> > >
> > > exception :
> > > 15:49:44,796 INFO  [STDOUT] [mTokens]: line 1:1
> > > 15:49:44,796 INFO  [STDOUT]  state 0 (decision=15) no viable alt line
> > 1:1;
> > > char='?'
> > > 15:49:44,796 INFO  [STDOUT] [mTokens]: line 1:19
> > > 15:49:44,796 INFO  [STDOUT]  state 0 (decision=15) no viable alt line
> > > 1:19;
> > > char='?'
> > > 15:49:44,796 INFO  [STDOUT] java.lang.NullPointerException
> > > 15:49:44,796 INFO  [STDOUT]     at
> > > org.drools.compiler.PackageBuilder.newPackage(PackageBuilder.java:130)
> > > 15:49:44,796 INFO  [STDOUT]     at
> > > org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:115)
> > > 15:49:44,796 INFO  [STDOUT]     at
> > > org.drools.compiler.PackageBuilder.addPackageFromDrl(
> PackageBuilder.java
> > > :90)
> > > 15:49:44,796 INFO  [STDOUT]     at RuleAuthorization.readRule(
> > > RuleAuthorization.java:93)
> > >
> > >
> > > On 4/13/06, Michael Neale <[EMAIL PROTECTED]> wrote:
> > > >
> > > > can you post some more details?
> > > >
> > > > On 4/13/06, Khairul Anwar <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > yes, it is RC1.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Khairul Anwar
> > >
> > >
> >
> >
>
>
> --
> Khairul Anwar
>
>
>


--
Khairul Anwar


Reply via email to