title: ruby scripts - (NameError) undefined local variable or method `null' for main:Object
body: <p>My code</p>
  
  <pre><code>require "json"
  require "erb"
  
  flowvar = $workflowvar
  path = 'src/main/resources/'+$workflowvar+'.drl'
  rule = ""
  
  File.open(path,"w") do |f|
      f.puts "package com.drools.demo\;"+"\n"+"import org.mule.MessageExchangePattern\;"+"\n"+"import com.drools.demo.cashliquidassets\;"+"\n"+"global org.mule.module.bpm.MessageService mule\;"+"\n"+
      "dialect \"mvel\""+"\n"+"dialect \"java\""+"\n"+"declare cashliquidassets"+"\n"+"@role\(\'event\'\)"+"\n"+"end"+"\n"
      f.close
  end
  
  def concateRule(attribute,val)
      if(val==null || val=="") 
              return "";
      end
      if(attribute != null)
              if (attribute == "taxonomy_code" || attribute == "parent_taxonomy_code" || attribute == "report_name")
                  return "";
              end
      end
  
      if val.start_with('&lt;&gt;')
              return attribute+" != "+val[3,val.length].strip
      elsif val.start_with('&gt;')
              return attribute+" &gt; "+val
      elsif val.start_with('&lt;')
              return attribute+" &lt; "+val
      elsif val.include? ","
              return attribute+".contains("+val+"\)"
      else
          return attribute+" == "+ val
      end
  end
  
  json = JSON.parse($payload)
  json.each do |hash1|
    hash1.keys.each do |key|
      hash1[key].each do |inner_hash,value|
      @inner_hash = inner_hash
      @values = value
          str = concateRule @inner_hash,$values
      end
    end
  
  end
  </code></pre>
  
  <p>Compile is working fine, but in runtime, I am getting this following error. Any suggestions </p>
  
  <hr>
  
  <p>Root Exception stack trace:</p>
  
  <p><strong>org.jruby.exceptions.RaiseException: (NameError) undefined local
  variable or method `null' for main:Object</strong></p>
  
  <pre><code>at RUBY.concateRule(&lt;script&gt;:15)
  at RUBY.block in (root)(&lt;script&gt;:43)
  at org.jruby.RubyHash.each(org/jruby/RubyHash.java:1350)
  at RUBY.block in (root)(&lt;script&gt;:40)
  at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1735)
  at RUBY.block in (root)(&lt;script&gt;:39)
  at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1735)
  at RUBY.&lt;main&gt;(&lt;script&gt;:38)
  </code></pre>
  
  <hr>