I am working on a OSGi (apache felix) and maven based micro-service. I am in the process of learning jbpm. I have create a decision table that I need to invoke from my OSGi java project. Below is the code I am using from the javadoc of bpmn but seems like it is not working because although I imported bunch of dependencies from maven, still lot of other dependencies like
KnowledgeBaseConfiguration
ResourceFactoryService
ResourceFactoryService
KnowledgeBase
remain unresolved.
<drools.version>7.0.0.Final</drools.version>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>${drools.version}</version>
</dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-core -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-osgi-integration --><!-- https://mvnrepository.com/artifact/org.drools/drools-decisiontables -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>${drools.version}</version>
</dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-api -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
This is the logic that I found in the document of jbpm in the section of integration with OSGi
ServiceReference serviceRef = bundleContext.getServiceReference( ServiceRegistry.class.getName() );
ServiceRegistry registry = (ServiceRegistry) bundleContext.getService( serviceRef );
KnowledgeBuilderFactoryService knowledgeBuilderFactoryService = registry.get( KnowledgeBuilderFactoryService.class );
KnowledgeBaseFactoryService knowledgeBaseFactoryService = registry.get( KnowledgeBaseFactoryService.class );
ResourceFactoryService resourceFactoryService = registry.get( ResourceFactoryService.class );
KnowledgeBaseConfiguration kbaseConf = knowledgeBaseFactoryService.newKnowledgeBaseConfiguration( null, getClass().getClassLoader() );
KnowledgeBuilderConfiguration kbConf = knowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration( null, getClass().getClassLoader() );
KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService.newKnowledgeBuilder( kbConf );
kbuilder.add( resourceFactoryService.newClassPathResource( "MyProcess.bpmn", Dummy.class ), ResourceType.BPMN2 );
kbaseConf = knowledgeBaseFactoryService.newKnowledgeBaseConfiguration( null, getClass().getClassLoader() );
KnowledgeBase kbase = knowledgeBaseFactoryService.newKnowledgeBase( kbaseConf );
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
return Optional.empty();
My questions are :
- How to integrate jbpm and Osgi java to invoke and execute a bpmn or decision table?
- Why are these dependencies unresolved? I tried the latest 7.46.0.FINAL version of drools as well?