Java Spring MVC на Heroku Ошибка: невозможно получить доступ к файлу цели / зависимости / webapp-runner.jar jarfile - PullRequest
0 голосов
/ 13 ноября 2018

Я использую Heroku для развертывания Java-приложения Spring MVC с базой данных PostgreSQL.Ссылка на базу данных работает хорошо, и PostgreSQL был успешно инициализирован.

Развертывание прошло успешно без ошибок или странных сообщений предупреждения, но теперь приложение не работает.

Вот журналы:

    heroku[web.1]: State changed from crashed to starting
    heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dspring.profiles.active="datajpa,heroku" -DMISIC_ROOT="." -jar target/dependency/webapp-runner.jar --port 28363 target/*.war`
    heroku[web.1]: State changed from starting to crashed
    heroku[web.1]: Process exited with status 1
    app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
    app[web.1]: Error: Unable to access jarfile target/dependency/webapp-runner.jar
    heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=misic.herokuapp.com request_id=a242ee89-5594-4f48-9d14-432d46b17600 fwd="178.21.66.110" dyno= connect= service= status=503 bytes= protocol=https

Я не нашел ответа на stackoverflow, который решил бы мою проблему.Почему Heroku не может найти webapp-runner.jar, я не знаю!На localhost все работает отлично.

Мой pom.xml (часть)

    <profiles>
        <profile>
            <id>postgres</id>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>${postgresql.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                    <version>${tomcat.version}</version>
                     <scope>provided</scope>
                </dependency>
            </dependencies>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>heroku</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.10</version>
                        <executions>        
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                        <version>8.5.29.0</version>
                                        <destFileName>webapp-runner.jar</destFileName>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>${postgresql.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tomcat</groupId>
                <artifactId>tomcat-jdbc</artifactId>
                <version>${tomcat.version}</version>
            </dependency>
        </dependencies>
    </profile>
</profiles>

версия Tomcat: 8.5.29

Procfile:

    web: java $JAVA_OPTS -Dspring.profiles.active="datajpa,heroku" -DMISIC_ROOT="." -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

Ссылка на Github: https://github.com/MisicSlavisa/misic


Я решил проблему.Heroku по какой-то причине не использует файл setings.xml.Когда я перенес содержимое этого файла в pom.xml и удалил его, все заработало.

Ответы [ 2 ]

0 голосов
/ 10 мая 2019

Для меня 1) Я столкнулся с этим, когда пытался настроить jhipster upp для развертывания через git, а не через jarfile. У меня это есть, потому что Node.js buildpack был запущен раньше, чем java, поэтому я был вынужден установить их с heroku:buildpacks add --index 2 heroku/nodejs и heroku: buildpacks добавить --index 1 heroku / java`, но даже после этого изменения у меня все еще было та же ошибка. 2) тогда я понял, что у меня есть упаковка банок в pom, xml вместо требуемой упаковки войны. Изменение этого значения в pom.xml помогло мне.

0 голосов
/ 13 ноября 2018

Убедитесь, что у вас есть что-то подобное в вашем pom.xml:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.github.jsimone</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>9.0.13.0</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Подробнее см. Развертывание веб-приложений Java на основе Tomcat с помощью Webapp Runner .

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