OptaPlanner 7.21.0 не может быть выполнен из файла JAR - ошибка каталога dataDir - PullRequest
0 голосов
/ 08 июля 2019

Я пытаюсь создать свой исполняемый jar-файл после завершения приложения и хочу экспортировать его на другие машины.Однако я получаю указанную ошибку.Любые предложения?

Я пробовал Jar с зависимостями и оттенком в соответствии с POM

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.optaplanner.examples.nurserostering</groupId>
    <artifactId>NurseRostering</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Staff Rostering</name>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <!-- https://mvnrepository.com/artifact/org.eclipse.platform/org.eclipse.swt -->
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-core</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>mchange-commons-java</artifactId>
            <version>0.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.10</version>
        </dependency> <!-- Internal dependencies -->
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-persistence-common</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency><!-- Most examples use the XStream integration -->
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-persistence-xstream</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency><!-- TODO add examples that use the JAXB integration -->
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-persistence-jaxb</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency><!-- TODO add examples that use the jackson integration -->
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-persistence-jackson</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-benchmark</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-test</artifactId>
            <scope>test</scope>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-api</artifactId>
            <version>7.21.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-decisiontables</artifactId>
            <scope>runtime</scope>
            <version>7.21.0.Final</version>
        </dependency>
        <!-- External dependencies -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.jfree</groupId>
            <artifactId>jfreechart</artifactId>
            <version>1.0.19</version>
        </dependency>
        <dependency>
            <groupId>org.jfree</groupId>
            <artifactId>jcommon</artifactId>
            <version>1.0.23</version>
        </dependency>
        <!-- Common utils -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>runtime</scope>
            <version>1.1.3</version>
        </dependency>


        <!-- Examples only dependencies. -->
        <!-- WARNING: every examples only dependency must be properly dealt with 
            in optaplanner-distribution/src/main/assembly/assembly-optaplanner.xml -->
        <!-- Converters -->
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.15</version>

        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.4.0-b180830.0438</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.24</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-javafx</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>13-ea+9</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>13-ea+9</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>13-ea+9</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-fontawesome-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-core</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>13-ea+9</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-octicons-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-fontelico-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-ionicons-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-ionicons4-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-entypo-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-themify-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-materialdesign-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
        <dependency>
            <groupId>org.kordamp.ikonli</groupId>
            <artifactId>ikonli-foundation-pack</artifactId>
            <version>11.3.4</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <!-- Run shade goal on package phase -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <!-- add Main-Class to manifest file -->
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.optaplanner.examples.nurserostering.app.NurseRosteringApp</mainClass>

                                    <!-- -Dlog4j.configurationFile=../properties/idStrikeSolver-log4j.properties 
                                        -Duser.timezone="UTC" -->
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/kie.conf</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Исключение:

Exception in thread "main" java.lang.IllegalStateException: The directory dataDir (/home/rodney/Desktop/data/nurserostering) does not exist.
 Either the working directory should be set to the directory that contains the data directory (which is not the data directory itself), or the system property org.optaplanner.examples.dataDir should be set properly.
 The data directory is different in a git clone (optaplanner/optaplanner-examples/data) and in a release zip (examples/sources/data).
 In an IDE (IntelliJ, Eclipse, NetBeans), open the "Run configuration" to change "Working directory" (or add the system property in "VM options").
    at org.optaplanner.examples.common.app.CommonApp.determineDataDir(CommonApp.java:52)
    at org.optaplanner.examples.common.app.CommonApp.createSolutionBusiness(CommonApp.java:127)
    at org.optaplanner.examples.common.app.CommonApp.init(CommonApp.java:117)
    at org.optaplanner.examples.common.app.CommonApp.init(CommonApp.java:113)
    at org.optaplanner.examples.nurserostering.app.NurseRosteringApp.main(NurseRosteringApp.java:41)

1 Ответ

1 голос
/ 08 июля 2019

Позвольте мне ответить на этот вопрос, скопировав вопрос:)

... Каталог dataDir (/home/rodney/Desktop/data/nurserostering) не существует.Либо рабочий каталог должен быть установлен в каталог, содержащий каталог data (который не является самим каталогом data), либо ... Каталог данных отличается в git-клоне (optaplanner/optaplanner-examples/data) и в почтовом выпуске (examples/sources/data).В IDE (IntelliJ, Eclipse, NetBeans) откройте «Запуск конфигурации», чтобы изменить «Рабочий каталог» ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...