How can I run Spring MVC application on Heroku?
<p>I have simple application on Spring MVC which runned on tomcat 7.0.72 in IDEA. How can I run this application on Heroku (if it's possible). I have Heroku account and I did create app on it. I use Maven for deploy and Git for push it in Heroku. Files of app will be below. So, when I run it on localhost by tomcat it works. But when I push it on heroku I get it:</p>

<blockquote>
  <p>Application Error: </p>
  
  <p>An error occurred in the application and your page could not be
  served. Please try again in a few moments. If you are the application owner, check your logs for details.</p>
</blockquote>

<p>This is my pom.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;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"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;com.mardmitry&lt;/groupId&gt;
    &lt;artifactId&gt;bestmuzon&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;name&gt;BestMuzon&lt;/name&gt;
    &lt;!--&lt;url&gt;http://maven.apache.org&lt;/url&gt;--&gt;

    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;spring-framework-version&gt;4.1.5.RELEASE&lt;/spring-framework-version&gt;
        &lt;tomcat.version&gt;8.5.6&lt;/tomcat.version&gt;
    &lt;/properties&gt;

    &lt;dependencies&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
            &lt;version&gt;${spring-framework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
            &lt;version&gt;${spring-framework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
            &lt;version&gt;${spring-framework-version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!--JSF (include "jsf-api" and "jsf-impl")--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
            &lt;artifactId&gt;javax.faces&lt;/artifactId&gt;
            &lt;version&gt;2.2.10&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-embed-core&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-embed-logging-juli&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-jasper-el&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
            &lt;artifactId&gt;tomcat-jsp-api&lt;/artifactId&gt;
            &lt;version&gt;${tomcat.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.github.jsimone&lt;/groupId&gt;
            &lt;artifactId&gt;webapp-runner&lt;/artifactId&gt;
            &lt;version&gt;8.0.30.2&lt;/version&gt;
        &lt;/dependency&gt;

    &lt;/dependencies&gt;

    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt;
                &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.2&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;url&gt;https://bestmuzonproject.herokuapp.com/&lt;/url&gt;
                    &lt;!--&lt;url&gt;http://localhost:8080/manager/text&lt;/url&gt;--&gt;
                    &lt;server&gt;TomcatServer&lt;/server&gt;
                    &lt;path&gt;/mkyongWebApp&lt;/path&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;

            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.3&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;phase&gt;package&lt;/phase&gt;
                        &lt;goals&gt;&lt;goal&gt;copy&lt;/goal&gt;&lt;/goals&gt;
                        &lt;configuration&gt;
                            &lt;artifactItems&gt;
                                &lt;artifactItem&gt;
                                    &lt;groupId&gt;com.github.jsimone&lt;/groupId&gt;
                                    &lt;artifactId&gt;webapp-runner&lt;/artifactId&gt;
                                    &lt;version&gt;8.0.30.2&lt;/version&gt;
                                    &lt;destFileName&gt;webapp-runner.jar&lt;/destFileName&gt;
                                &lt;/artifactItem&gt;
                            &lt;/artifactItems&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>Structure of my app:
<a href="https://i.stack.imgur.com/Bu9BW.png" rel="nofollow">Structure of app</a></p>

<p>web.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1"&gt;

    &lt;!-- Add Support for Spring --&gt;
    &lt;!-- Создает Spring Container, доступный всем сервлетам и фильтрам --&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;WEB-INF/applicationContext.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;listener&gt;
        &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;

    &lt;!-- Обрабатывает все запросы. Центральное понятие--&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
        &lt;url-pattern&gt;*.form&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;

    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
&lt;/web-app&gt;
</code></pre>

<p>MainController:</p>

<pre><code>package com.mardmitry.controllers;

import com.mardmitry.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class MainController {
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView main() {

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("userJSP", new User());
        modelAndView.setViewName("index");
        return modelAndView;
    }

    /*как только на index.jsp подтвердится форма
    &lt;spring:form method="post"  modelAttribute="userJSP" action="check-user"&gt;,
    то попадем вот сюда
     */
    @RequestMapping(value = "/check-user")
    public ModelAndView checkUser(@ModelAttribute("userJSP") User user) {
        ModelAndView modelAndView = new ModelAndView();   
        modelAndView.setViewName("secondPage");
        modelAndView.addObject("userJSP", user);

        return modelAndView; 
    }
}
</code></pre>

<p>index.jsp:</p>

<pre><code>&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %&gt;
&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;

&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Best Muzon&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;spring:form method="post"  modelAttribute="userJSP" action="check-user"&gt;

      Name: &lt;spring:input path="name"/&gt; (path="" - указывает путь, используемый в modelAttribute=''. в нашем случае User.name)  &lt;br/&gt;
      Password: &lt;spring:input path="password"/&gt;   &lt;br/&gt;
      &lt;spring:button&gt;Next Page&lt;/spring:button&gt;

  &lt;/spring:form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Build log in Git:</p>

<pre><code>Counting objects: 359, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (282/282), done.
Writing objects: 100% (359/359), 20.70 MiB | 99.00 KiB/s, done.
Total 359 (delta 130), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----&gt; Java app detected
remote: -----&gt; Installing OpenJDK 1.8... done
remote: -----&gt; Installing Maven 3.3.9... done
remote: -----&gt; Executing: mvn -B -DskipTests clean dependency:list install
remote:        [INFO] Scanning for projects...
remote:        [INFO]
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Building BestMuzon 1.0-SNAPSHOT
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO]
remote:        [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ bestmuzon ---
remote:        [INFO] Deleting /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/target
remote:        [INFO]
remote:        [INFO] --- maven-dependency-plugin:2.3:list (default-cli) @ bestmuzon ---
remote:        [INFO]
remote:        [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ bestmuzon ---
remote:        [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote:        [INFO] skip non existing resourceDirectory /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/src/main/resources
remote:        [INFO]
remote:        [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ bestmuzon ---
remote:        [INFO] Changes detected - recompiling the module!
remote:        [INFO] Compiling 2 source files to /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/target/classes
remote:        [INFO]
remote:        [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ bestmuzon ---
remote:        [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote:        [INFO] skip non existing resourceDirectory /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/src/test/resources
remote:        [INFO]
remote:        [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ bestmuzon ---
remote:        [INFO] No sources to compile
remote:        [INFO]
remote:        [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ bestmuzon ---
remote:        [INFO] Tests are skipped.
remote:        [INFO]
remote:        [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ bestmuzon ---
remote:        [INFO] Building jar: /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/target/bestmuzon-1.0-SNAPSHOT.jar
remote:        [INFO]
remote:        [INFO] --- maven-dependency-plugin:2.3:copy (default) @ bestmuzon ---
remote:        [INFO] Configured Artifact: com.github.jsimone:webapp-runner:8.0.30.2:jar
remote:        [INFO] Copying webapp-runner-8.0.30.2.jar to /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/target/dependency/webapp-runner.jar
remote:        [INFO]
remote:        [INFO] --- maven-install-plugin:2.4:install (default-install) @ bestmuzon ---
remote:        [INFO] Installing /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/target/bestmuzon-1.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/com/mardmitry/bestmuzon/1.0-SNAPSHOT/bestmuzon-1.0-SNAPSHOT.jar
remote:        [INFO] Installing /tmp/build_90aea2b2f1ce2e21c7e6a87e78ae382d/pom.xml to /app/tmp/cache/.m2/repository/com/mardmitry/bestmuzon/1.0-SNAPSHOT/bestmuzon-1.0-SNAPSHOT.pom
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD SUCCESS
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time: 3.629 s
remote:        [INFO] Finished at: 2016-10-20T10:34:05+00:00
remote:        [INFO] Final Memory: 22M/171M
remote:        [INFO] ------------------------------------------------------------------------
remote: -----&gt; Discovering process types
remote:        Procfile declares types -&gt; web
remote:
remote: -----&gt; Compressing...
remote:        Done: 70M
remote: -----&gt; Launching...
remote:        Released v23
remote:        https://bestmuzonproject.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
To https://git.heroku.com/bestmuzonproject.git
 + 8306e15...83a9a0c master -&gt; master (forced update)
</code></pre>

<p>Heroku logs:</p>

<pre><code>2016-10-20T10:34:13.261601+00:00 heroku[api]: Deploy 83a9a0c by arxangel192@mail.ru
2016-10-20T10:34:13.261601+00:00 heroku[api]: Release v23 created by arxangel192@mail.ru
2016-10-20T10:34:13.409620+00:00 heroku[slug-compiler]: Slug compilation finished
2016-10-20T10:34:13.409611+00:00 heroku[slug-compiler]: Slug compilation started
2016-10-20T10:34:13.962566+00:00 heroku[web.1]: Restarting
2016-10-20T10:34:13.963376+00:00 heroku[web.1]: State changed from up to starting
2016-10-20T10:34:16.874279+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-10-20T10:34:17.556730+00:00 heroku[web.1]: Starting process with command `sh target/bin/webapp`
2016-10-20T10:34:18.183328+00:00 heroku[web.1]: Process exited with status 143
2016-10-20T10:34:19.795333+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-20T10:34:19.796435+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-20T10:34:19.682528+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-10-20T10:34:19.686998+00:00 app[web.1]: sh: 0: Can't open target/bin/webapp
2016-10-20T10:34:19.777080+00:00 heroku[web.1]: Process exited with status 127
2016-10-20T10:34:23.291738+00:00 heroku[web.1]: Starting process with command `sh target/bin/webapp`
2016-10-20T10:34:24.945775+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-10-20T10:34:24.946678+00:00 app[web.1]: sh: 0: Can't open target/bin/webapp
2016-10-20T10:34:25.024482+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-20T10:34:25.009062+00:00 heroku[web.1]: Process exited with status 127
2016-10-20T10:34:57.262474+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bestmuzonproject.herokuapp.com request_id=1acd63ba-7e38-4279-881c-2eb1a1708a63 fwd="178.94.207.167" dyno= connect= service= status=503 bytes=
2016-10-20T10:35:38.838802+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bestmuzonproject.herokuapp.com request_id=cafaddfe-5c81-4d00-a47d-9c1111d6053b fwd="178.94.207.167" dyno= connect= service= status=503 bytes=
</code></pre>