How to read DMN files with the Kie Framework from an URL on my JBOSS?

44 views Asked by At

I want to read DMN models from the JBoss modules folder. I am already using .drl files from the same location.

Is there a way to define the URL from which the DMN files are obtained?

Initially, I tried the following code, but I now understand that JBoss resources are not included in the classpath.

KieServices kieServices = KieServices.Factory.get();
DMNRuntime dmnRuntime = kieServices.newKieClasspathContainer().newKieSession().getKieRuntime(DMNRuntime.class);

This code works for the src/main/resources, which is sadly not the right location.

So, I played around with something like this in the hope of making the location known to the KieSession.

        KieServices kieServices = KieServices.Factory.get();
        KieFileSystem kieFS = kieServices.newKieFileSystem();
        KieResources kieResources = kieServices.getResources();
        kieFS.write(kieResources.newUrlResource(getClass().getResource("/fuba/")));
        KieBuilder kb = kieServices.newKieBuilder(kieFS);
        kb.buildAll();
        KieRepository kieRepository = kieServices.getRepository();
        ReleaseId krDefaultReleaseId = kieRepository.getDefaultReleaseId();
        KieContainer kieContainer = kieServices.newKieContainer(krDefaultReleaseId);
        KieSession kieSession = kieContainer.newKieSession();
        DMNRuntime dmnRuntime = kieSession.getKieRuntime(DMNRuntime.class);

In both cases, the DMNRuntime found no models.

I use jboss 7.4 and kie 7.73.0.Final

0

There are 0 answers