У меня есть проект maven, который имеет все связанные зависимости в pom. xml, и все jar-файлы доступны в папке репозитория .m2. Этот проект был создан как самостоятельный, который имеет основной метод. Когда я запускаю приложение из Eclipse, оно работает нормально. Когда я запускаю команду propmt с помощью команды mvn -q clean compile exe c: java -Dexe c .mainClass = "com.package.trigger.App", тоже работает нормально. Но когда я создаю этот проект как исполняемый файл jar и запускаю из командной строки с помощью команды java -jar trigger-engine-usa-project-0.0.1-SNAPSHOT-jar-with-dependencies.jar, на KieServices выдается нулевой указатель. Factory.get (); line.
Вот мой код:
Yaml yaml = new Yaml();
try (InputStream in = App.class.getResourceAsStream("/application.yml")) {
KJAR kjars = yaml.loadAs(in, KJAR.class);
// System.out.println("kjars.toString():::: "+kjars.toString());
KieServices kieServices = KieServices.Factory.get();
ReleaseId releaseId = kieServices.newReleaseId(kjars.getGroupId(), kjars.getArtifactId(), kjars.getVersion());
kjars.setContainer(kieServices.newKieContainer(releaseId));
System.out.println(kjars);
также печатаются кьяры из файла .yml
Журнал в случае успеха: ::
kjars.toString():::: KJAR [groupId=com.package, artifactId=trigger-engine-knowledge-france, version=1.0.2-SNAPSHOT, scanningInterval=600000, countryCode=FR, container=null, scanner=null]
kieServices:::: org.drools.compiler.kie.builder.impl.KieServicesImpl@420a8de2
releaseId:::: com.package:trigger-engine-knowledge-france:1.0.2-SNAPSHOT
KJAR [groupId=com.package, artifactId=trigger-engine-knowledge-france, version=1.0.2-SNAPSHOT, scanningInterval=600000, countryCode=FR, container=org.drools.compiler.kie.builder.impl.KieContainerImpl@3e023639, scanner=null]
Suggestions returned from rules execution is empty
Журнал ошибок: :::
--------------Query Execution starts-----------------
Size of data obtained from DB::::: 64
--------------Query Execution ends-----------------
--------------Rules Execution starts-----------------
kjars.toString():::: KJAR [groupId=com.package, artifactId=trigger-engine-knowledge-france, version=1.0.2-SNAPSHOT, scanningInterval=600000, countryCode=FR, container=null, scanner=null]
kieServices:::: null
Exception in thread "main" java.lang.NullPointerException
at com.package.trigger.rules.impl.RuleExecutorImpl.loadAndExecuteCPARules(RuleExecutorImpl.java:109)
at com.package.trigger.service.impl.TestAPIServiceImpl.executeTestRule(TestAPIServiceImpl.java:41)
at com.package.trigger.App.main(App.java:42)
После некоторых исследований я добавил, что плагины maven shade также все еще не работают. Кто-нибудь, пожалуйста, помогите мне в этом. Я пытался решить эту проблему в течение последних трех недель. Я ценю любые предложения по этому вопросу. Пожалуйста ... Здесь я упоминаю мою пом. xml также. пом. xml ::: http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0
<groupId>com.package</groupId>
<artifactId>trigger-engine-usa-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>trigger-engine-usa-project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.drools>7.18.0.Final-redhat-00004</version.drools>
<version.redshift.jdbc>1.2.10.1009</version.redshift.jdbc>
<version.amazonaws.sdk>1.11.592</version.amazonaws.sdk>
<version.maven.compiler>3.5.1</version.maven.compiler>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
<dependencies>
<dependency>
<groupId>com.package</groupId>
<artifactId>trigger-engine-usa-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.package</groupId>
<artifactId>trigger-engine-knowledge-france</artifactId>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<!-- KIE -->
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>7.23.0.Final-redhat-00003</version>
</dependency>
<!-- <dependency> <groupId>org.kie</groupId> <artifactId>kie-ci-osgi</artifactId>
</dependency> -->
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>7.18.0.Final-redhat-00004</version>
</dependency>
<!-- Drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${version.drools}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${version.drools}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>${version.drools}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-workbench-models-guided-dtable</artifactId>
<version>${version.drools}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
<!-- Being used temporarily -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-redshift</artifactId>
<version>${version.amazonaws.sdk}</version>
</dependency>
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42-no-awssdk</artifactId>
<version>${version.redshift.jdbc}</version>
</dependency>
<!-- YAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.12.Final</version>
</dependency>
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven.compiler}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/kie.conf</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>com.package.trigger.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration>
<archive> <manifest> <mainClass>com.package.trigger.App</mainClass> </manifest>
</archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </configuration> </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<printSummary>true</printSummary>
<skipTests>${skip.unit.tests}</skipTests>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<skipITs>${skip.integration.tests}</skipITs>
<includes>
<include>**/*IT.java</include>
</includes>
<excludes>
<exclude>**/*.sql</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>