Wow!!  That'll be great!! However the problem that I faced above is only
with eclipse3.1(The missing package name in drl file). As with elipse3.2M5,
using a wizard, I found that if a user declare an absolutely different
package name in drl, it'll still be running just fine. The
nullPointerException will only happen when there is no package declared in
drl file. Maybe it is because the rules folder(drl and dsl files) already
defined in configuration-file .classpath?

thanks

On 4/14/06, Michael Neale <[EMAIL PROTECTED]> wrote:
>
> I will add a check for a package name at the point at which it is being
> built. Thus a meaningful error message should result.
>
> Note that it is not checked by the parser, as it is possible to
> programmatically add package names etc.. (or spread rules across files
> etc).
> But at the point you build the package, sure, we can check for it there !
>
>
>
> On 4/14/06, Ishafizan Ishak <[EMAIL PROTECTED]> wrote:
> >
> > 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: [email protected]
> > 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: [email protected]
> > > 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
> >
> >
> >
>
>


--
Khairul Anwar

Reply via email to