<div dir="ltr">Hi,<div><br></div><div>With new Kie API, the way that we build KieBuilder, Session, KieBase is a bit different as we did before.</div><div><br></div><div>We can now create a KieFileSystem, add resources (drl, ....) and create a KieBuilder from the KieSystem</div>
<div><br></div><div><div>        KieFileSystem kfs = kieServices.newKieFileSystem()</div><div>                .write(&quot;src/main/resources/temp.drl&quot;, packages)</div><div>                .writeKModuleXML(createKieProjectWithPackages(kieServices).toXML());</div>
<div><br></div><div>        kieBuilder = kieServices.newKieBuilder(kfs).buildAll();</div><div><br></div><div style>That works fine for Java standalone projects (or in a JEE container or Web Container (Tomcat, Jetty) - I hope ?) but not in a OSGI environment.</div>
<div style><br></div><div style>In consequence the following step fails in my code :</div><div style><br></div><div style>kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId()).newKieSession();<br>
</div><div style><br></div><div style><div>Caused by: java.lang.RuntimeException: Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT</div><div><span class="" style="white-space:pre">        </span>at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:75)</div>
<div><br></div><div style>as getKieModule(ReleaseId releaseId, byte[] pomXml) return null</div><div style><br></div><div style>The following code should be imporved as until now we don&#39;t check classpath</div><div style>
<br></div><div style><div>    public KieModule getKieModule(ReleaseId releaseId, byte[] pomXml) {</div><div>        VersionRange versionRange = new VersionRange(releaseId.getVersion());</div><div><br></div><div>        KieModule kieModule = kieModuleRepo.load(releaseId, versionRange);</div>
<div>        if ( kieModule == null ) {</div><div>            log.debug( &quot;KieModule Lookup. ReleaseId {} was not in cache, checking classpath&quot;,</div><div>                    releaseId.toExternalForm() );</div><div>
            kieModule = checkClasspathForKieModule(releaseId);</div><div>        }</div><div><br></div><div>        if ( kieModule == null ) {</div><div>            log.debug( &quot;KieModule Lookup. ReleaseId {} was not in cache, checking maven repository&quot;,</div>
<div>                    releaseId.toExternalForm() );</div><div>            kieModule = <div style="display:inline;height:auto;width:auto">loadKieModuleFromMavenRepo</div>loadKieModuleFromMavenRepo(releaseId, pomXml);</div>
<div>        }</div><div><br></div><div>        return kieModule;</div><div>    }</div><div><br></div><div style>and loadKieModuleFromMavenRepo() does not find the resource as it has been created from scratch</div><div style>
<br></div><div style>Regards,</div><div style="display:inline;height:auto;width:auto"></div></div></div><div><br></div>-- <br><div>Charles Moulliard</div><div>Apache Committer / Sr. Enterprise Architect (RedHat)</div><div>
Twitter : @cmoulliard | Blog : <a href="http://cmoulliard.blogspot.com" target="_blank">http://cmoulliard.blogspot.com</a></div><div><br></div>
</div></div>