no its just because we didn't cater for the fact, at build time, that a
package name may not exist. I added a defensive check. We could have made a
default, however, that may cause problems down the track when people forget
to use the package namespace at all.

Should be cool in RC2.

The package name doesn't have to be anything specific. You only need to be
consistent if you are adding rules from multiple files, or perhaps in future
adding rules to a package that was created elsewhere, however in your case,
it really shouldn't matter what it is.

And 3.2 is the IDE that works best (due to internal eclipse API deps - or
stuff that *was* internal in 3.1).
3.2 final will be out shortly, which is brilliant timing.
FYI, I have been using 3.2 for sometime now, and it seems to me to be much
lighter then 3.1 in memory usage.

Michael.

On 4/14/06, Khairul Anwar <[EMAIL PROTECTED]> wrote:
>
> 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