Closed niketkdoshi closed 5 years ago
@i-techsolutions please add a logger implementation dependency to your pom.xml. Power Flows DMN doesn't provide it by default, because of different needs by the end application, like i. e. your one. Proposed implementation you can add is:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.2</version>
</dependency>
Are you using maven?
@i-techsolutions please add a logger implementation dependency to your pom.xml. Power Flows DMN doesn't provide it by default, because of different needs by the end application, like i. e. your one. Proposed implementation you can add is:
<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>2.11.2</version> </dependency>
Still same error
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.powerflows.dmn.engine.evaluator.expression.provider.DefaultExpressionEvaluationProviderFactory.<clinit>(DefaultExpressionEvaluationProviderFactory.java:30) at org.powerflows.dmn.engine.configuration.DefaultDecisionEngineConfiguration.initEvaluationProviderFactory(DefaultDecisionEngineConfiguration.java:79) at org.powerflows.dmn.engine.configuration.DefaultDecisionEngineConfiguration.configure(DefaultDecisionEngineConfiguration.java:61) at dmntest.Dmntest.<init>(Dmntest.java:152) at dmntest.Dmntest.main(Dmntest.java:172) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 5 more
Import:
import org.apache.logging.slf4j.*; import org.slf4j.impl.*;
If you are using maven or gradle all dependencies are automagically provided.
Otherwise you need to manually download them:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.24</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.15</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7</version>
</dependency>
juel-impl
Thanks and it works. But still for yml load,it gives same error
juel-impl
Thanks and it works. But still for yml load,it gives same error
please add alf4j-api and other jars I listed
Below is my POM
`
<artifactId>dmn</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.24</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.15</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7</version>
</dependency>
`
It gives error for yml file only, rest it works fine.
Error with yml file is as below:
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.constructor.BaseConstructor at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 2 more
I'll need more details on
Or you can try this project test-project.zip
Hi,
I am getting below issue when I tried this.
run: Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.powerflows.dmn.engine.evaluator.expression.provider.DefaultExpressionEvaluationProviderFactory.<clinit>(DefaultExpressionEvaluationProviderFactory.java:30) at org.powerflows.dmn.engine.configuration.DefaultDecisionEngineConfiguration.initEvaluationProviderFactory(DefaultDecisionEngineConfiguration.java:79) at org.powerflows.dmn.engine.configuration.DefaultDecisionEngineConfiguration.configure(DefaultDecisionEngineConfiguration.java:61) at dmntest.Dmntest.<init>(Dmntest.java:166) at dmntest.Dmntest.main(Dmntest.java:186) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 5 more BUILD FAILED (total time: 0 seconds)
Here is my code, let me know If I am executing any wrong step. ` package dmntest; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.; import org.powerflows.dmn.engine.DecisionEngine; import org.powerflows.dmn.engine.configuration.DefaultDecisionEngineConfiguration; import org.powerflows.dmn.engine.model.decision.Decision; import org.powerflows.dmn.engine.model.decision.EvaluationMode; import org.powerflows.dmn.engine.model.decision.HitPolicy; import org.powerflows.dmn.engine.model.decision.expression.ExpressionType; import org.powerflows.dmn.engine.model.decision.field.ValueType; import org.powerflows.dmn.engine.model.evaluation.result.DecisionResult; import org.powerflows.dmn.engine.model.evaluation.variable.DecisionVariables; import org.powerflows.dmn.io.yaml.YamlDecisionReader; import lombok.extern.slf4j.Slf4j; public class Dmntest { public Dmntest() { try { /File loanQualifierFile = new File("D:\loan-qualifier.yml"); InputStream loanQualifierInputStream = new FileInputStream(loanQualifierFile); Optional loanQualifierDecision = new YamlDecisionReader().read(loanQualifierInputStream);
Decision decision = loanQualifierDecision.get(); //here developer has to build a valid decision object or read from .yml or .xml file
*/
Decision decision = Decision.builder()
.id("loan_qualifier")
.name("Loan qualifier")
.hitPolicy(HitPolicy.COLLECT)
.expressionType(ExpressionType.FEEL)
.withInput(in -> in
.name("age")
.type(ValueType.INTEGER)
.build())
.withInput(in -> in
.name("activeLoansNumber")
.description("Number of active loans on user's account")
.type(ValueType.INTEGER)
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.build())
.build())
.withInput(in -> in
.name("startDate")
.type(ValueType.DATE)
.build())
.withOutput(out -> out
.name("loanAmount")
.description("Loan amount in Euro")
.type(ValueType.DOUBLE)
.build())
.withOutput(out -> out
.name("loanTerm")
.description("Loan term in months")
.type(ValueType.INTEGER)
.build())
.withRule(rule -> rule
.description("Loan for 18 years")
.withInputEntry(in -> in
.name("age")
.evaluationMode(EvaluationMode.INPUT_COMPARISON)
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(18)
.build())
.build())
.withInputEntry(in -> in
.name("activeLoansNumber")
.evaluationMode(EvaluationMode.INPUT_COMPARISON)
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(0)
.build())
.build())
.withInputEntry(in -> in
.name("startDate")
.withExpression(ex -> ex
.type(ExpressionType.FEEL)
.value("[date and time(\"2019-01-01T12:00:00\")..date and time(\"2019-12-31T12:00:00\")]")
.build())
.build())
.withOutputEntry(out -> out
.name("loanAmount")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(10000)
.build())
.build())
.withOutputEntry(out -> out
.name("loanTerm")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(12)
.build())
.build())
.build())
.withRule(rule -> rule
.withInputEntry(in -> in
.name("age")
.withExpression(ex -> ex
.type(ExpressionType.FEEL)
.value(18)
.build())
.build())
.withInputEntry(in -> in
.name("startDate")
.withExpression(ex -> ex
.type(ExpressionType.FEEL)
.value("[date and time(\"2019-03-01T12:00:00\")..date and time(\"2019-03-31T12:00:00\")]")
.build())
.build())
.withOutputEntry(out -> out
.name("loanAmount")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(15000)
.build())
.build())
.withOutputEntry(out -> out
.name("loanTerm")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(6)
.build())
.build())
.build())
.withRule(rule -> rule
.withInputEntry(in -> in
.name("age")
.withExpression(ex -> ex
.type(ExpressionType.FEEL)
.value(">18")
.build())
.build())
.withOutputEntry(out -> out
.name("loanAmount")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(20000)
.build())
.build())
.withOutputEntry(out -> out
.name("loanTerm")
.withExpression(ex -> ex
.type(ExpressionType.LITERAL)
.value(12)
.build())
.build())
.build())
.build();
DecisionEngine decisionEngine = new DefaultDecisionEngineConfiguration().configure();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Serializable> variables = new HashMap<>();
variables.put("age", 18);
variables.put("activeLoansNumber", 0);
variables.put("startDate", format.parse("2019-01-05"));
DecisionVariables decisionVariables = new DecisionVariables(variables);
DecisionResult decisionResult = decisionEngine.evaluate(decision, decisionVariables);
System.out.println(decisionResult.isSingleEntryResult());
System.out.println(decisionResult.isSingleRuleResult());
System.out.println(decisionResult.isCollectionRulesResult());
System.out.println(decisionResult.getSingleEntryResult());
System.out.println(decisionResult.getSingleRuleResult());
System.out.println(decisionResult.getCollectionRulesResult());
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
}
} `
Below are the list of libraries I have taken:
Library Number 2 i.e protostuff-uberjar-1.0.5.jar I have taken for YAML File but still it doesnt loads yml file.
Please help so that I can try this DMN.
Thanks in advance.