Я пробовал слюни уже неделю и пытался создать небольшое приложение, которое получит кьяр из локального репозитория maven.Если я запускаю свое приложение в затмении, все работает нормально.Если собрать ubber jar с помощью maven-shade-plugin и запустить java -jar myapp.jar, приложение завершится неудачей, за исключением исключения, указанного в приложениях, несмотря на адекватное чтение артефакта kjar из локального репозитория maven (я проверил его, предоставив несуществующий артефакт, и он выдал правильную ошибку.)
Я искал почти день, и не смог найти объяснения в документации по drools, в предоставленных примерах на github или любой другой странице, проиндексированной Google: / / Я не знаю, связано ли это с ubber jar, так как во всех примерах не упоминается, как они развертывают приложение.Пожалуйста, помогите мне!
Я прикрепляю часть трассировки стека за исключением моего pom.xml.Я не изменил ни одного файла settings.xml, связанного с Maven, поскольку приложение, похоже, правильно получает информацию из локального репо.
Трассировка стека
0 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Loading kie.conf from
3 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Discovered kie.conf url=jar:file:/C:/Users/ccosta/git/myproject/rulesengine/target/rulesengine-0.0.1-shade.jar!/META-INF/kie.conf
65 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.drools.core.io.impl.ResourceFactoryServiceImpl
68 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.internal.services.KieBeliefsImpl
78 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.drools.compiler.kie.builder.impl.KieServicesImpl
79 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.internal.services.KieWeaversImpl
81 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.internal.services.KieRuntimesImpl
91 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.drools.core.marshalling.impl.MarshallerProviderImpl
93 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.internal.services.KieAssemblersImpl
101 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.scanner.MavenClassLoaderResolver
116 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl
117 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.drools.core.concurrent.ExecutorProviderImpl
126 [main] INFO org.kie.api.internal.utils.ServiceDiscoveryImpl - Adding Service org.kie.scanner.KieScannerFactoryServiceImpl
141 [main] DEBUG org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule Lookup. ReleaseId org.lid4.myproject:rules:0.0.1 was not in cache, checking classpath
142 [main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - Adding KieModule from classpath: file:/C:/Users/ccosta/git/myproject/rulesengine/target/rulesengine-0.0.1-shade.jar
148 [main] DEBUG org.drools.compiler.kie.builder.impl.ClasspathKieProject - KieModule URL type=jar url=/C:/Users/ccosta/git/myproject/rulesengine/target/rulesengine-0.0.1-shade.jar
410 [main] DEBUG org.drools.compiler.kie.builder.impl.ClasspathKieProject - Found and used pom.properties META-INF/maven/org.lid4.myproject/rulesengine/pom.properties
1057 [main] WARN org.appformer.maven.integration.embedder.MavenSettings - Environment variable M2_HOME is not set
1093 [main] DEBUG org.appformer.maven.integration.embedder.MavenEmbedderUtils - Not in OSGi: using plexus based maven parser
1489 [main] ERROR org.appformer.maven.integration.embedder.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)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.appformer.maven.integration.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.appformer.maven.integration.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:134)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:96)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:87)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.appformer.maven.integration.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:92)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:76)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:70)
at org.appformer.maven.integration.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:34)
at org.appformer.maven.support.PomModel$Parser.parse(PomModel.java:110)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getPomModel(AbstractKieModule.java:378)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getJarDependencies(AbstractKieModule.java:130)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:66)
at org.drools.compiler.kie.builder.impl.InternalKieModule.createModuleClassLoader(InternalKieModule.java:137)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:191)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
at org.lid4.myproject.rulesengine.App.main(App.java:22)
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141)
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:1)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 20 more
1492 [main] ERROR org.appformer.maven.integration.embedder.MavenProjectLoader - Unable to create new MavenEmbedder
org.appformer.maven.integration.embedder.MavenEmbedderException: java.util.NoSuchElementException
role: org.apache.maven.execution.MavenExecutionRequestPopulator
roleHint:
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:108)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:87)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.appformer.maven.integration.embedder.MavenProjectLoader.newMavenEmbedder(MavenProjectLoader.java:92)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:76)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:70)
at org.appformer.maven.integration.MavenPomModelGenerator.parse(MavenPomModelGenerator.java:34)
at org.appformer.maven.support.PomModel$Parser.parse(PomModel.java:110)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getPomModel(AbstractKieModule.java:378)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getJarDependencies(AbstractKieModule.java:130)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:66)
at org.drools.compiler.kie.builder.impl.InternalKieModule.createModuleClassLoader(InternalKieModule.java:137)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:191)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
at org.lid4.myproject.rulesengine.App.main(App.java:22)
... More of the same (removed to fulfil stackoverlow char limits)...
1520 [main] DEBUG org.appformer.maven.integration.embedder.MavenEmbedderUtils - Not in OSGi: using plexus based maven parser
1581 [main] ERROR org.appformer.maven.integration.embedder.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)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.appformer.maven.integration.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.appformer.maven.integration.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:134)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:96)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:87)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:56)
at org.appformer.maven.integration.embedder.MavenProjectLoader.loadMavenProject(MavenProjectLoader.java:121)
at org.appformer.maven.integration.Aether.getAether(Aether.java:75)
at org.appformer.maven.integration.MavenRepository.getMavenRepository(MavenRepository.java:95)
at org.appformer.maven.integration.ArtifactResolver.<init>(ArtifactResolver.java:52)
at org.appformer.maven.integration.ArtifactResolver.getResolverFor(ArtifactResolver.java:146)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:72)
at org.drools.compiler.kie.builder.impl.InternalKieModule.createModuleClassLoader(InternalKieModule.java:137)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:191)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
at org.lid4.myproject.rulesengine.App.main(App.java:22)
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141)
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:1)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 19 more
1582 [main] WARN org.appformer.maven.integration.embedder.MavenProjectLoader - Unable to parse pom.xml file of the running project: org.appformer.maven.integration.embedder.MavenEmbedderException: java.util.NoSuchElementException
role: org.apache.maven.execution.MavenExecutionRequestPopulator
roleHint:
1657 [main] DEBUG org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\ccosta\.m2\repository
1661 [main] DEBUG org.appformer.maven.integration.embedder.MavenEmbedderUtils - Not in OSGi: using plexus based maven parser
1716 [main] ERROR org.appformer.maven.integration.embedder.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)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.appformer.maven.integration.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.appformer.maven.integration.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:134)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:96)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:87)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:56)
at org.appformer.maven.integration.embedder.MavenProjectLoader.loadMavenProject(MavenProjectLoader.java:121)
at org.appformer.maven.integration.embedder.MavenProjectLoader.loadMavenProject(MavenProjectLoader.java:114)
at org.appformer.maven.integration.embedder.EmbeddedPomParser.<init>(EmbeddedPomParser.java:32)
at org.appformer.maven.integration.ArtifactResolver.<init>(ArtifactResolver.java:53)
at org.appformer.maven.integration.ArtifactResolver.getResolverFor(ArtifactResolver.java:146)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:72)
at org.drools.compiler.kie.builder.impl.InternalKieModule.createModuleClassLoader(InternalKieModule.java:137)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:191)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
at org.lid4.myproject.rulesengine.App.main(App.java:22)
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141)
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:1)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 19 more
1716 [main] WARN org.appformer.maven.integration.embedder.MavenProjectLoader - Unable to parse pom.xml file of the running project: org.appformer.maven.integration.embedder.MavenEmbedderException: java.util.NoSuchElementException
role: org.apache.maven.execution.MavenExecutionRequestPopulator
roleHint:
Pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.lid4.myproject</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1</version>
</parent>
<groupId>org.lid4.myproject</groupId>
<artifactId>rulesengine</artifactId>
<version>0.0.1</version>
<name>rulesengine</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.lid4.myproject</groupId>
<artifactId>rules</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>7.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>7.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>7.7.0.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.lid4.myproject.rulesengine.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.lid4.myproject.rulesengine.App</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/kie.conf</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Java-код
package org.lid4.intelligentdatabroker.rulesengine;
import org.apache.log4j.BasicConfigurator;
import org.drools.core.util.Drools;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.lid4.intelligentdatabroker.rules.Measurement;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
BasicConfigurator.configure();
KieServices ks = KieServices.Factory.get();
ks.newReleaseId("org.lid4.myproject", "rules", "0.0.1");
ks.newKieContainer(ks.newReleaseId("org.lid4.myproject", "rules", "0.0.1"));
// Install example1 in the local maven repo before to do this
//KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("org.lid4.myproject", "rules", "0.0.1"));
//KieSession kSession = kContainer.newKieSession();
//kSession.setGlobal("out", System.out);
Measurement m1 = new Measurement("1", "1");
//kSession.insert(m1);
//kSession.fireAllRules();
}
}
---------- Редактировать -----------
Теперь происходит сбой с
1641 [main] ERROR org.appformer.maven.integration.embedder.MavenEmbedder - Unable to build MavenEmbedder
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.settings.building.SettingsBuilder
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:249)
at org.appformer.maven.integration.embedder.PlexusComponentProvider.lookup(PlexusComponentProvider.java:42)
at org.appformer.maven.integration.embedder.MavenEmbedder.getSettings(MavenEmbedder.java:235)
at org.appformer.maven.integration.embedder.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:134)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:96)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:87)
at org.appformer.maven.integration.embedder.MavenEmbedder.<init>(MavenEmbedder.java:81)
at org.appformer.maven.integration.embedder.MavenProjectLoader.parseMavenPom(MavenProjectLoader.java:56)
at org.appformer.maven.integration.embedder.MavenProjectLoader.loadMavenProject(MavenProjectLoader.java:121)
at org.appformer.maven.integration.Aether.getAether(Aether.java:75)
at org.appformer.maven.integration.MavenRepository.getMavenRepository(MavenRepository.java:95)
at org.appformer.maven.integration.ArtifactResolver.<init>(ArtifactResolver.java:52)
at org.appformer.maven.integration.ArtifactResolver.getResolverFor(ArtifactResolver.java:146)
at org.kie.scanner.MavenClassLoaderResolver.getClassLoader(MavenClassLoaderResolver.java:72)
at org.drools.compiler.kie.builder.impl.InternalKieModule.createModuleClassLoader(InternalKieModule.java:137)
at org.drools.compiler.kie.builder.impl.KieModuleKieProject.<init>(KieModuleKieProject.java:56)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:191)
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
at org.lid4.intelligentdatabroker.rulesengine.App.main(App.java:23)
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141)
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:1)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 20 more
После добавления этой конфигурации в maven-shade-plugin.Так что я подозреваю, что это действительно проблема, связанная с maven-shade-plugin, но я не знаю другого способа создания ubber jar для использования Drools в приложении.
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/sisu/javax.inject.Named</resource>
</transformer>
Заранее спасибо,Карлос Коста