Drools kie-ci示例在ubber jar中失败但在eclipse IDE

时间:2018-05-22 16:57:33

标签: maven jar drools kie maven-shade-plugin

我现在已经尝试了一周的口水,而我正在尝试构建一个从本地maven存储库获取kjar的小应用程序。如果我在eclipse中运行我的应用程序,一切正常。如果使用maven-shade-plugin构建一个ubber jar并运行java -jar myapp.jar,应用程序将失败并附件中提供异常,尽管从本地maven存储库中充分读取了kjar工件(我通过提供非现有的工件并给出了正确的错误。)

我现在搜索了将近一天,并且无法在drools文档中找到解释,在github或Google索引的任何其他页面上提供的示例中: - /我不知道是否它与ubber jar有关,因为所有示例都没有提到他们如何部署应用程序。请帮帮我!

我附加了部分堆栈跟踪和异常以及我的pom.xml。我没有更改任何与Maven相关的settings.xml,因为应用程序似乎正确地从本地仓库检索信息。

堆栈跟踪

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>

提前致谢, 卡洛斯·科斯塔

2 个答案:

答案 0 :(得分:1)

我们从uber-JAR运行了Drools,并为maven-shade-plugin进行了以下配置。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <configuration>
      <createDependencyReducedPom>true</createDependencyReducedPom>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <!-- some transformers omitted -->
            <transformer
              implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
            <transformer
              implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/kie.conf</resource>
            </transformer>
            <transformer
              implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/sisu/javax.inject.Named</resource>
            </transformer>
          </transformers>
        </configuration>
      </execution>
    </executions>
  </plugin>

它与您的解决方案的区别仅在于增加了“ org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer”转换器。希望能帮助到你。

最诚挚的问候!

答案 1 :(得分:0)

这实际上只是我的2美分,因为您现在想做的是让我感到头疼。

但是我确实在您的堆栈跟踪中看到了 '1057 [main]警告org.appformer.maven.integration.embedder.MavenSettings-未设置环境变量M2_HOME'

  1. (Win7)控制面板/系统/高级系统设置->弹出系统属性/选项卡高级/按钮“环境变量”->弹出环境变量,底部窗口“系统变量”。
  2. 确保在那里同时有一个M2_HOME和MAVEN_HOME条目指向您的maven安装;必要时进行编辑或添加。

这可能是您的MavenEmbedder无法构建的原因。