Menu

can't run as java application - java.io.FileNotFoundException: rules\TemplateRules.xls (The system cannot find the path specified)

Help
2017-02-14
2017-02-14
  • Kerry Kennedy

    Kerry Kennedy - 2017-02-14

    In java IDE (Eclipse) , failed to run as "java application" (labelled Main.java in "openl-simple-project-from-archetype") ... There is no issue with running the cmd line console runnable start.cmd.
    I was also able to successfully import the deployable.zip in WebStudio and test the TemplateRules. openl-simple-project-from-archetype.
    Please suggest how to fix the problem.

    Here's the IDE console details output from the terminated javaw.exe.
    (I've also included the Main.java in a separate comment below)

    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Exception in thread "main" org.openl.exception.OpenlNotCheckedException: Can't instantiate engine instance
    at org.openl.runtime.EngineFactory.prepareInstance(EngineFactory.java:160)
    at org.openl.runtime.AEngineFactory.newInstance(AEngineFactory.java:49)
    at org.openl.runtime.AEngineFactory.newInstance(AEngineFactory.java:32)
    at org.openl.runtime.EngineFactory.newEngineInstance(EngineFactory.java:132)
    at org.openl.rules.openl_simple_project_from_archetype.Main.main(Main.java:19)
    Caused by: org.openl.exception.OpenLRuntimeException: Can't open source file or file is corrupted: FileNotFoundException: rules\TemplateRules.xls (The system cannot find the path specified)

    at org.openl.rules.lang.xls.load.WorkbookLoadUtils.loadWorkbook(WorkbookLoadUtils.java:33)
    at org.openl.rules.lang.xls.load.SimpleWorkbookLoaderFactory.createWorkbookLoader(SimpleWorkbookLoaderFactory.java:8)
    at org.openl.rules.lang.xls.load.WorkbookLoaders.getWorkbookLoader(WorkbookLoaders.java:23)
    at org.openl.rules.lang.xls.XlsWorkbookSourceCodeModule.<init>(XlsWorkbookSourceCodeModule.java:54)
    at org.openl.rules.lang.xls.XlsLoader.preprocessWorkbook(XlsLoader.java:296)
    at org.openl.rules.lang.xls.XlsLoader.parse(XlsLoader.java:86)
    at org.openl.rules.lang.xls.XlsParser.parseAsModule(XlsParser.java:48)
    at org.openl.engine.OpenLParseManager.parseSource(OpenLParseManager.java:41)
    at org.openl.engine.OpenLSourceManager.processSource(OpenLSourceManager.java:132)
    at org.openl.engine.OpenLCompileManager.compileModuleWithErrors(OpenLCompileManager.java:88)
    at org.openl.engine.OpenLManager.compileModuleWithErrors(OpenLManager.java:182)
    at org.openl.runtime.ASourceCodeEngineFactory.initializeOpenClass(ASourceCodeEngineFactory.java:94)
    at org.openl.runtime.EngineFactory.getCompiledOpenClass(EngineFactory.java:167)
    at org.openl.runtime.EngineFactory.prepareInstance(EngineFactory.java:152)
    ... 4 more
    

    Caused by: java.lang.RuntimeException:
    at org.openl.util.RuntimeExceptionWrapper.wrap(RuntimeExceptionWrapper.java:16)
    at org.openl.source.impl.FileSourceCodeModule.getByteStream(FileSourceCodeModule.java:54)
    at org.openl.rules.lang.xls.load.WorkbookLoadUtils.loadWorkbook(WorkbookLoadUtils.java:26)
    ... 17 more
    Caused by: java.io.FileNotFoundException: rules\TemplateRules.xls (The system cannot find the path specified)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.openl.source.impl.FileSourceCodeModule.getByteStream(FileSourceCodeModule.java:52)
    ... 18 more

     
  • Kerry Kennedy

    Kerry Kennedy - 2017-02-14

    /openl-simple-project-from-archetype/src/main/java/org/openl/rules/openl_simple_project_from_archetype/Main.java
    .................................................
    package org.openl.rules.openl_simple_project_from_archetype;

    import org.openl.rules.runtime.RulesEngineFactory;

    import java.io.File;

    /*
    * This class shows how to execute OpenL Tablets methods using Java wrapper.
    * Looks really simple...
    /
    public class Main {

    public static void main(String[] args) {
        File xlsFile = new File("rules/TemplateRules.xls");
    
        // Wrapper - is generated interface from TemplateRules.xls using maven openl:generate goal.
        RulesEngineFactory<Wrapper> engineFactory = new RulesEngineFactory<Wrapper>(xlsFile, Wrapper.class);
    
        Wrapper instance = engineFactory.newEngineInstance();
        String result = instance.hello(10);
        System.out.println(result);
    }
    

    }

     
  • Kerry Kennedy

    Kerry Kennedy - 2017-02-15

    WORKAROUND BUT BREAKS RUNNABLE: I found a bizarre workaround solution for the FileNotFoundException related to "Run as java application" with Main.java.
    RUNNABLE BROKEN: With the workaround, the runnable has the FileNotFound problem with the new location "src/main/openl/rules".
    RELATED ISSUE: so how do I resolve this conflict?
    Turns out that I was able to WORKAROUND the problem by using a temporary file location for the TemplateRules.xls while I changed the relative location reference in the "File xlsFile" declaration.
    1. Tried copying the TemplateRules.xls file to the project root file and used the "File xlsFile" declaration for the relative location "TemplateRules.xls" ... which worked.
    2. Similarly, tried "src/main" file location with "src/main/TemplateRules.xls" which also worked
    3. Then finalized file location as "src/main/openl/rules" (default) with the relative location "src/main/openl/rules/TemplateRules.xls" i.e. File xlsFile = new File("src/main/openl/rules/TemplateRules.xls") which also worked.

     

    Last edit: Kerry Kennedy 2017-02-16

Log in to post a comment.