I use Heroku to deploy my Spring MVC java application with PostgreSQL database. Link to database works good, and PostgreSQL was successfuly initialize.
The deployment succeeded with no errors or strange looking warning messages, but now the application fails.
Here are the logs:
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
I did not find any answer on stackoverflow, that would solve my problem. Why Heroku cann't find webapp-runner.jar, I do not know! On localhost everything works perfectly.
My pom.xml (part)
<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>
version 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
Link to Github: https://github.com/MisicSlavisa/misic
I resolved the problem. Heroku, for some reason, does not use file setings.xml. When I transferred the contents of this file to pom.xml and deleted it, everything worked.