Hello,

I need your help!
I'm trying to migrate from Drools 5.5.0 to 6.0.1, creating the 
KnowledgeBase programmatically.

But buildAll gives me WARN "No files found for KieBase defaultKieBase".
What's missing? My code is based on the example found in documentation.
fileName is pointing to an xls file with decision table.
Writing it to kieFileSystem seemed to work correct, as 
kieFileSystem.read( fileName ).length is showing the right number of bytes.

Logging output:
DEBUG [RuleBuilder#buildKieBase] Get kieServices
DEBUG [RuleBuilder#buildKieBase] Get kieRepository
DEBUG [RuleBuilder#buildKieBase] Get new kieFileSystem
DEBUG [RuleBuilder#buildKieBase] Add 
/mbi/etc/MailFilter_hgm2e-langfr-sb2000-ipc.xls to kieFileSystem
DEBUG [RuleBuilder#buildKieBase] Get new kieBuilder
DEBUG [RuleBuilder#buildKieBase] 22016
DEBUG [RuleBuilder#buildKieBase] Build all Rules
WARN 
[org.drools.compiler.kie.builder.impl.AbstractKieModule#buildKnowledgePackages] 
No files found for KieBase defaultKieBase
INFO 
[org.drools.compiler.kie.builder.impl.KieRepositoryImpl#addKieModule] 
KieModule was added:MemoryKieModule[ 
ReleaseId=org.default:artifact:1.0.0-SNAPSHOT]
DEBUG [RuleBuilder#buildKieBase] Get new kieContainer
DEBUG [RuleBuilder#buildKieBase] Get kieBase

Code:
RuleBuilder.LOGGER.debug( "Get kieServices" );
KieServices kieServices = KieServices.Factory.get();

RuleBuilder.LOGGER.debug( "Get kieRepository" );
KieRepository kieRepository = kieServices.getRepository();

RuleBuilder.LOGGER.debug( "Get new kieFileSystem" );
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();

XADiskConnection connection = null;
try {
   connection = this.xaDisk.getConnection();
   XAFileInputStream fis = connection.createXAFileInputStream( new File( 
fileName ) );
   try ( InputStream is = new XAFileInputStreamWrapper( fis ) ) {
     RuleBuilder.LOGGER.debug( "Add " + fileName + " to kieFileSystem" );
     kieFileSystem.write( fileName, 
kieServices.getResources().newInputStreamResource( is ) );
   } catch ( IOException e ) {
     // ignore
   }
   fis.close();
} catch ( FileNotExistsException e ) {
   // Datei '%s' nicht gefunden
   ServiceStringResponse ssr = this.mbiFxtxtFacade.getTranslation( 
Integer.valueOf( 215421 ), locales );
   throw new MbiException( e, RuleBuilder.LOGGER, String.format( 
ssr.getValue(), fileName ) );
} catch ( InsufficientPermissionOnFileException | LockingFailedException 
| NoTransactionAssociatedException e ) {
   throw new MbiException( e, RuleBuilder.LOGGER );
} catch ( ResourceException | InterruptedException e ) {
   throw new MbiException( e, RuleBuilder.LOGGER );
} finally {
   if ( connection != null ) {
     connection.close();
   }
}

RuleBuilder.LOGGER.debug( "Get new kieBuilder" );
KieBuilder kieBuilder = kieServices.newKieBuilder( kieFileSystem );
RuleBuilder.LOGGER.debug( kieFileSystem.read( fileName ).length );

RuleBuilder.LOGGER.debug( "Build all Rules" );
kieBuilder.buildAll();

RuleBuilder.LOGGER.debug( "Get new kieContainer" );
KieContainer kieContainer = kieServices.newKieContainer( 
kieRepository.getDefaultReleaseId() );

RuleBuilder.LOGGER.debug( "Get kieBase" );
KieBase kieBase = kieContainer.getKieBase();

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to