you’ll need to write a minimal self contained unit test:
http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/Welcome...
You’ll need to submit the test to this module:
https://github.com/droolsjbpm/drools/tree/master/drools-decisiontables/sr...
Lots of programmatic builder tests, to follow as examples here:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...
Also did you try doing it non-programmaticaly first? The non-api way is the preferred and
recommended way. The api is there for tooling and stuff that is done purely at runtime.
Mark
On 31 Dec 2013, at 13:04, Frank Langelage <frank(a)lafr.de> wrote:
I'll answer myself:
it's mandatory to use "src/main/resources/" as the base folder inside
KieFilesystem.
kieFileSystem.write( "src/main/resources/" + fileName,
kieServices.getResources().newInputStreamResource( is ) );
with fileName = "etc/MailFilter.xls".
Now Apache POI breaks down processing my xls file which works with
drools 5.5 / JExcelApi:
Caused by: java.lang.NullPointerException
at
org.apache.poi.poifs.property.PropertyTableBase.populatePropertyTree(PropertyTableBase.java:100)
[poi.jar:3.9]
at
org.apache.poi.poifs.property.PropertyTableBase.<init>(PropertyTableBase.java:63)
[poi.jar:3.9]
at
org.apache.poi.poifs.property.PropertyTable.<init>(PropertyTable.java:63)
[poi.jar:3.9]
at
org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:159)
[poi.jar:3.9]
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:322)
[poi.jar:3.9]
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:303)
[poi.jar:3.9]
at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:70)
[poi-ooxml.jar:3.9]
at
org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:81)
[drools-decisiontables.jar:6.0.1.Final]
at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:93)
[drools-decisiontables.jar:6.0.1.Final]
at
org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:72)
[drools-decisiontables.jar:6.0.1.Final]
at
org.drools.decisiontable.DecisionTableProviderImpl.compileStream(DecisionTableProviderImpl.java:37)
[drools-decisiontables.jar:6.0.1.Final]
at
org.drools.decisiontable.DecisionTableProviderImpl.loadFromInputStream(DecisionTableProviderImpl.java:20)
[drools-decisiontables.jar:6.0.1.Final]
at
org.drools.compiler.compiler.DecisionTableFactory.loadFromInputStream(DecisionTableFactory.java:15)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.PackageBuilder.decisionTableToPackageDescr(PackageBuilder.java:474)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl$4.map(CompositeKnowledgeBuilderImpl.java:422)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:329)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:319)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:96)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:87)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:204)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:39)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:323)
[drools-compiler.jar:6.0.1.Final]
at
org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:193)
[drools-compiler.jar:6.0.1.Final]
at
biz.mbisoftware.fn.ejb.session.common.RuleBuilder.buildKieBase(RuleBuilder.java:117)
[ejb-session-common.jar:]
On 29.12.13 22:12, Frank Langelage wrote:
> 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(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users