Running drools in Databricks

I am trying to implement a PoC to run Drools on Azure Databricks using Scala language. I assume there is no equivalent python client for Drools. I am aware of other BRE python-based frameworks available which I already tested.

When trying to run a sample code in Scala notebook I keep getting the exception below.

I have imported all necessary Drools libraries.

Drools lib version: 7.1.17.0-Final

Databricks: 11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12)

Can somebody advise what I am doing wrong ?

Has anybody come across working example ?

I would appreciate any support.

NoClassDefFoundError: Could not initialize class org.kie.internal.io.ResourceFactory$LazyHolder
import collection.JavaConverters._
import org.slf4j.ILoggerFactory
import org.kie.internal.io.ResourceFactory
import org.drools.core.impl.KnowledgeBaseFactory
import org.kie.api.io.ResourceType
import org.kie.api.runtime.KieSession
import org.kie.api.runtime.rule.RuleContext
import org.kie.internal.builder.KnowledgeBuilderFactory
import org.kie.api.internal.utils.ServiceRegistry

class SampleService {
    
  val resource= ResourceFactory.newClassPathResource("sample.drl")
  val kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder()
  kbuilder.add(resource,ResourceType.DRL)

  val kbase = KnowledgeBaseFactory.newKnowledgeBase()
  kbase.addPackages(kbuilder.getKnowledgePackages())

 def runAllRulesFor(): String = {
    val session = kbase.newKieSession()
    null  
  }

}

def result = new DroolsRuleService().runAllRulesForUDF;
println(result)



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation