[rules-users] (no subject)

Sandhya Sree sandhyachinnaraj at gmail.com
Mon Mar 10 09:51:15 EDT 2014


Thanks :)
i got it :-)


On Mon, Mar 10, 2014 at 7:18 PM, Mauricio Salatino <salaboy at gmail.com>wrote:

> If the list inside  Event has never being initialised it will throw a
> null point exception.. so you need to make sure that the list
> is initialised properly.
>
> Regards
>
>
> On Mon, Mar 10, 2014 at 1:43 PM, Sandhya Sree <sandhyachinnaraj at gmail.com>wrote:
>
>> Exception in thread "pool-2-thread-1" Exception executing consequence for
>> rule "size" in com.net: java.lang.NullPointerException
>>  at
>> org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
>>  at
>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
>> at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
>>  at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
>> at
>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
>>  at
>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
>> at
>> org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
>>  at com.net.RuleExecutor.execute(RuleExecutor.java:18)
>> at com.net.DirectoryMonitor.run(DirectoryMonitor.java:39)
>>  at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>  at java.lang.Thread.run(Thread.java:744)
>> Caused by: java.lang.NullPointerException
>> at
>> com.net.Rule_size_dc2a47e2812648e69eb9581eda931496.defaultConsequence(Rule_size_dc2a47e2812648e69eb9581eda931496.java:9)
>>  at
>> com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvokerGenerated.evaluate(Unknown
>> Source)
>> at
>> com.net.Rule_size_dc2a47e2812648e69eb9581eda931496DefaultConsequenceInvoker.evaluate(Unknown
>> Source)
>>  at
>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
>>
>>
>> On Mon, Mar 10, 2014 at 7:08 PM, Mauricio Salatino <salaboy at gmail.com>wrote:
>>
>>> Please copy the entire stack trace.. what you have copied doesn't mean
>>> anything besides that there is something wrong.
>>>
>>>
>>> On Mon, Mar 10, 2014 at 1:29 PM, Sandhya Sree <
>>> sandhyachinnaraj at gmail.com> wrote:
>>>
>>>> im getting the following error on doing that
>>>>
>>>> Exception in thread "pool-2-thread-1" Exception executing consequence
>>>> for rule "size" in com.net: java.lang.NullPointerException
>>>>
>>>> what might be the problem?
>>>>
>>>>
>>>>
>>>> On Mon, Mar 10, 2014 at 4:16 PM, Wolfgang Laun <wolfgang.laun at gmail.com
>>>> > wrote:
>>>>
>>>>> Seeing that the list is static you can use the usual way for accessing
>>>>> a static class member:
>>>>>
>>>>>     Event.listOfEvent.add( ... );
>>>>>
>>>>> @Mauricio: It's not unusual to maintain a static collection (even
>>>>> though there may be better ways, esp. with Drools).
>>>>>
>>>>>
>>>>>
>>>>> On 10/03/2014, Mauricio Salatino <salaboy at gmail.com> wrote:
>>>>> > Can you please elaborate about why do you want to do that? what's
>>>>> the point
>>>>> > of having a list inside of the Event class that will contain the same
>>>>> > event?
>>>>> >
>>>>> > The "Then" side of the rule is pure java.. so you just do
>>>>> > event.getEvents().add(event);
>>>>> >
>>>>> > but I don't see the point of doing that.
>>>>> >
>>>>> > Regards
>>>>> >
>>>>> >
>>>>> > On Mon, Mar 10, 2014 at 10:31 AM, Sandhya Sree
>>>>> > <sandhyachinnaraj at gmail.com>wrote:
>>>>> >
>>>>> >> hi ,
>>>>> >>
>>>>> >> i have a class called Event which is as follows:
>>>>> >>
>>>>> >> public class Event {
>>>>> >>  private  String name;
>>>>> >>  private  File source;
>>>>> >>  private  Date timeStamp;
>>>>> >> public static List<Event> listOfEvents;
>>>>> >>
>>>>> >> public Event(String name, File source, Date timeStamp) {
>>>>> >>  this.name = name;
>>>>> >> this.source = source;
>>>>> >> this.timeStamp = timeStamp;
>>>>> >>  }
>>>>> >>  public String getName() {
>>>>> >>  return name;
>>>>> >> }
>>>>> >> public void setName(String name) {
>>>>> >>  this.name = name;
>>>>> >> }
>>>>> >> public File getSource() {
>>>>> >>  return source;
>>>>> >> }
>>>>> >> public void setSource(File source) {
>>>>> >>  this.source = source;
>>>>> >> }
>>>>> >> public Date getTimeStamp() {
>>>>> >>  return timeStamp;
>>>>> >> }
>>>>> >> public void setTimeStamp(Date timeStamp) {
>>>>> >>  this.timeStamp = timeStamp;
>>>>> >> }
>>>>> >>
>>>>> >>
>>>>> >>  public void display()
>>>>> >>  {
>>>>> >>  System.out.println(name +" " + "in folder: " + source + " on " +
>>>>> >> timeStamp );
>>>>> >>   }
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> there are also some other classes associated with my project.. i
>>>>> have a
>>>>> >> rules file which computes the size of a folder and creates an
>>>>> object of
>>>>> >> Event class. every time this object of Event class is created i
>>>>> wwant to
>>>>> >> put it in a List<Event>.. how can i do this..
>>>>> >>
>>>>> >> my rules is as follows:
>>>>> >>
>>>>> >> rule "size"
>>>>> >> when
>>>>> >>   $p:  RuleContext($size:
>>>>> getOldContext().getParent().getUsableSpace() >
>>>>> >> (30*1024*1024))
>>>>> >>
>>>>> >> then
>>>>> >>    Event event = new Event("folder almost full",
>>>>> >> $p.getOldContext().getParent(), new Date());
>>>>> >>    event.display();
>>>>> >>    ......here i want to put this event into the List<Event>
>>>>> declared in
>>>>> >> Event Class.....
>>>>> >>
>>>>> >>   end
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> thanks,
>>>>> >> Sandhya
>>>>> >>
>>>>> >> _______________________________________________
>>>>> >> rules-users mailing list
>>>>> >> rules-users at lists.jboss.org
>>>>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>> >>
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> >  - MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
>>>>> >  - Co-Founder @ http://www.jugargentina.org
>>>>> >  - Co-Founder @ http://www.jbug.com.ar
>>>>> >
>>>>> >  - Salatino "Salaboy" Mauricio -
>>>>> >
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>
>>>
>>>
>>> --
>>>  - MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
>>>  - Co-Founder @ http://www.jugargentina.org
>>>  - Co-Founder @ http://www.jbug.com.ar
>>>
>>>  - Salatino "Salaboy" Mauricio -
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
>  - MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
>  - Co-Founder @ http://www.jugargentina.org
>  - Co-Founder @ http://www.jbug.com.ar
>
>  - Salatino "Salaboy" Mauricio -
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140310/1a7d761c/attachment-0001.html 


More information about the rules-users mailing list