0 Replies Latest reply on Nov 25, 2012 12:30 PM by pablog1108

    Drools fusión returns NullPointerException

    pablog1108

      Hi everyone.


      I'm trying to make a twitter app using mule+drools fusion, but I'm getting a null pointer exception in the rhs of one specific rule, "Tweet a caso sospechoso." I can't figure out.


      I think that the drools engine is retracting tweet events early. When I need to use a tweet event in the rhs, the event doesn't exist any more.


      import clases.*;


      declare Tweet

              @role ( event )

      end


      declare Gripe

              @role ( event )

      end


      declare Sospechoso

              @role ( event )

      end


      rule "Tweet a Gripe"

          when

              $t:Tweet($us:usuario, texto matches "\.*gripe.*") from entry-point "Flujo Tweets"

              not (Gripe(usuario==$us) from entry-point "Casos Confirmados")

          then

              Sospechoso s = new Sospechoso(TiposSintomas.GRIPE,$t);        

              Gripe g = new Gripe(s);        

              entryPoints["Casos Confirmados"].insert(g);

              mule.generateMessage("alerts",g, null, MessageExchangePattern.ONE_WAY);

      end


      rule "Tweet a caso sospechoso"

              when

                      $t:Tweet(texto not matches "\.*gripe.*",$us:usuario,$txt:texto) from entry-point "Flujo Tweets"

                      $s:SintomaGripe($t.texto matches regexp)

                      not (Sospechoso(usuario==$us) from entry-point "Casos Sospechosos")

                      not (Gripe(usuario==$us) from entry-point "Casos Confirmados")

              then

                      Sospechoso s = new Sospechoso($s.getTipo(),$t);

                      entryPoints["Casos Sospechosos"].insert(s);

                      mule.generateMessage("alerts",s, null, MessageExchangePattern.ONE_WAY);

      end


      rule "Sospechosos a Gripe"

              when

                      $s:Sospechoso($us:usuario) from entry-point "Casos Sospechosos"

                      not(Gripe(usuario==$us) from entry-point "Casos Confirmados")

                      $casos:ArrayList(size >= 3)

                                 from collect (Sospechoso(usuario==$us) from entry-point "Casos Sospechosos")

              then

                      Gripe g = new Gripe($casos);

                      entryPoints["Casos Confirmados"].insert(g);

                      mule.generateMessage("alerts",g, null, MessageExchangePattern.ONE_WAY);

      end


      Stacktrace


      ERROR 2012-11-25 13:28:29,655 [[ceptwitter].Flujo1.stage2.02] org.mule.exception.DefaultMessagingExceptionStrategy:

      ********************************************************************************

      Message               : Failed to invoke RulesComponent{Flujo1.commponent.22081703}. Component that caused exception is: RulesComponent{Flujo1.commponent.22081703}. Message payload is of type: Tweet

      Type                  : org.mule.component.ComponentException

      Code                  : MULE_ERROR--2

      Payload               : clases.Tweet@154283a

      JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html

      ********************************************************************************

      Exception stack is:

      1. null (java.lang.NullPointerException)

        clases.Tweet:8 (null)

      2. java.lang.NullPointerException (org.drools.runtime.rule.ConsequenceException)

        org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler:23 (null)

      3. Failed to invoke RulesComponent{Flujo1.commponent.22081703}. Component that caused exception is: RulesComponent{Flujo1.commponent.22081703}. Message payload is of type: Tweet (org.mule.component.ComponentException)

        org.mule.component.AbstractComponent:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)

      ********************************************************************************

      Root Exception stack trace:

      java.lang.NullPointerException

              at clases.Tweet.<init>(Tweet.java:8)

              at clases.Sospechoso.<init>(Sospechoso.java:9)

              at defaultpkg.Rule_Tweet_a_caso_sospechoso_0.consequence(Rule_Tweet_a_caso_sospechoso_0.java:7)

              at defaultpkg.Rule_Tweet_a_caso_sospechoso_0ConsequenceInvoker.evaluate(Rule_Tweet_a_caso_sospechoso_0ConsequenceInvoker.java:29)

              at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)

              at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)

              at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)

              at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660)

              at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:627)

              at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183)

              at org.mule.module.drools.Drools.assertEvent(Drools.java:167)

              at org.mule.module.bpm.Rules.handleEvent(Rules.java:131)

              at org.mule.module.bpm.RulesComponent.doInvoke(RulesComponent.java:84)

              at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:126)

              at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:61)

              at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:242)

              at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)

              at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)

              at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)

              at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)

              at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)

              at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)

              at org.mule.component.AbstractComponent.process(AbstractComponent.java:160)

              at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)

              at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:43)

              at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)

              at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)

              at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:43)

              at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)

              at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:116)

              at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:171)

              at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:165)

              at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:20)

              at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:34)

              at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:18)

              at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:58)

              at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:48)

              at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:54)

              at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:44)

              at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44)

              at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52)

              at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:32)

              at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:17)

              at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:113)

              at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:34)

              at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:164)

              at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)

              at org.mule.work.WorkerContext.run(WorkerContext.java:311)

              at java.util.concu...

      ********************************************************************************