0

有人可以帮我理解为什么我会出现以下错误吗?

我正在尝试使用 Drools 6.5.0 动态构建业务规则。下面是我的java代码:

    String KIE_GROUP_ID = "rules_test";
    String KIE_ARTIFACT_ID = "rules_test";
    String KIE_POM_VERSION = "1.0";
    String propertyName = "myProperty";
    String K_SESSION = "_kSession";

    String drlFile = compiler.compile(rulesAsParameters, Files.newInputStream(Paths.get(ruleFileTemplatePath)));

    KieBaseModel kieBase = kieModuleModel.newKieBaseModel(propertyName)
    .setDefault( false )
    .setEqualsBehavior( EqualityBehaviorOption.EQUALITY )
    .setEventProcessingMode( EventProcessingOption.STREAM );
    kieBase.newKieSessionModel(propertyName.concat(K_SESSION) )
    .setDefault( false )
    .setType( KieSessionModel.KieSessionType.STATEFUL )
    .setClockType( ClockTypeOption.get("realtime") );

    kfs.write(String.format(KFS_VIRTUAL_RULE_FILE_PATH, propertyName), drlFile);
    kfs.writeKModuleXML(kieModuleModel.toXML());

    final ReleaseId releaseId = services.newReleaseId(KIE_GROUP_ID, KIE_ARTIFACT_ID, KIE_POM_VERSION);
    kfs.generateAndWritePomXML(releaseId);
    KieBuilder kieBuilder = services.newKieBuilder(kfs);
    kieBuilder.buildAll();

    kieContainer = services.newKieContainer(releaseId);
    container.getKieBase(propertyName).newKieSession().insert(myRequestObject).fireAllRules();

功能运行良好,规则构建成功,我能够触发规则并获得正确的结果。但我在日志中不断看到以下错误:

    2019-01-10 01:23:49.793 [WARN ]  [main] MavenSettings - Environment variable M2_HOME is not set
    2019-01-10 01:23:49.820 [DEBUG]  [main] MavenEmbedderUtils - Not in OSGi: using plexus based maven parser
    2019-01-10 01:23:50.229 [ERROR]  [main] MavenEmbedder - Unable to build MavenEmbedder
    org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
    role: org.apache.maven.execution.MavenExecutionRequestPopulator
    roleHint: 
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:133) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:95) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:86) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:80) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:77) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:61) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:55) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:33) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kproject.xml.PomModel$Parser.parse(PomModel.java:110) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildPomModel(KieBuilderImpl.java:471) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getPomModel(KieBuilderImpl.java:448) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.init(KieBuilderImpl.java:134) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:169) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCache.buildKieBases(DroolsRuleCache.java:95) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCache.<init>(DroolsRuleCache.java:63) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCacheFactory.initialize(DroolsRuleCacheFactory.java:24) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.psi.fz.listener.BootStrapListener.contextInitialized(BootStrapListener.java:40) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:217) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:251) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.epay.appserver.EpayAppServer.<init>(EpayAppServer.java:126) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.epay.appserver.EpayAppServer.main(EpayAppServer.java:68) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    Caused by: java.util.NoSuchElementException
    at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:1) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    ... 28 more
    2019-01-10 01:23:50.231 [ERROR]  [main] KieScanner - Unable to create new MavenEmbedder
    org.kie.scanner.embedder.MavenEmbedderException: java.util.NoSuchElementException
    role: org.apache.maven.execution.MavenExecutionRequestPopulator
    roleHint: 
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:107) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:86) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenEmbedder.<init>(MavenEmbedder.java:80) ~[fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:77) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:61) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:55) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.kie.scanner.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:33) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kproject.xml.PomModel$Parser.parse(PomModel.java:110) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildPomModel(KieBuilderImpl.java:471) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getPomModel(KieBuilderImpl.java:448) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.init(KieBuilderImpl.java:134) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:169) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCache.buildKieBases(DroolsRuleCache.java:95) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCache.<init>(DroolsRuleCache.java:63) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.fz.rules.engine.DroolsRuleCacheFactory.initialize(DroolsRuleCacheFactory.java:24) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.psi.fz.listener.BootStrapListener.contextInitialized(BootStrapListener.java:40) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:217) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:251) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.epay.appserver.EpayAppServer.<init>(EpayAppServer.java:126) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    at com.oath.epay.appserver.EpayAppServer.main(EpayAppServer.java:68) [fraudwebservice-4.4.1-SNAPSHOT-shaded.jar:?]
    Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
    role: org.apache.maven.execution.MavenExecutionRequestPopulator

错误被抛出:kieBuilder.buildAll()。

4

0 回答 0