2

I am building a Spring MVC application that works totally fine on localhost. I wanted to see it hosted on Heroku so I deployed it and it was all successful.

The deployment went fine but now I always get error 404 when I try to access the website and I'm not sure why does this happen.

Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>slupov</groupId>
    <artifactId>slupov-personal</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <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.27.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


<!--    Spring Boot dependency-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
    </parent>

    <dependencies>

<!--        Thymeleaf dependency-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

<!--        Spring Boot starter web dependency-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--    Spring dev tools-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    </dependencies>

</project>

As of now, you can access it on https://slupov-personal.herokuapp.com/ or https://slupov.com.

Will be very grateful if someone lended a hand because it's my first time with Spring and Heroku and I really dont know how to deal with the issue by myself!

EDIT: Here's the Heroku logs:

2019-10-15T14:28:38.526201+00:00 heroku[web.1]: Starting process with command java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port 37873 target/*.war 2019-10-15T14:28:40.091613+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them. 2019-10-15T14:28:40.09589+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 2019-10-15T14:28:40.760384+00:00 app[web.1]: Expanding slupov-personal-1.0-SNAPSHOT.war into /app/target/tomcat.37873/webapps/expanded 2019-10-15T14:28:40.760455+00:00 app[web.1]: Adding Context for /app/target/tomcat.37873/webapps/expanded 2019-10-15T14:28:41.25762+00:00 app[web.1]: Oct 15, 2019 2:28:41 PM org.apache.coyote.AbstractProtocol init 2019-10-15T14:28:41.257634+00:00 app[web.1]: INFO: Initializing ProtocolHandler ["http-nio-37873"] 2019-10-15T14:28:41.30395+00:00 app[web.1]: Oct 15, 2019 2:28:41 PM org.apache.catalina.core.StandardService startInternal 2019-10-15T14:28:41.303953+00:00 app[web.1]: INFO: Starting service [Tomcat] 2019-10-15T14:28:41.305846+00:00 app[web.1]: Oct 15, 2019 2:28:41 PM org.apache.catalina.core.StandardEngine startInternal 2019-10-15T14:28:41.305848+00:00 app[web.1]: INFO: Starting Servlet engine: [Apache Tomcat/9.0.27] 2019-10-15T14:28:41.732349+00:00 heroku[web.1]: State changed from starting to up 2019-10-15T14:28:41.514987+00:00 app[web.1]: Oct 15, 2019 2:28:41 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment 2019-10-15T14:28:41.514996+00:00 app[web.1]: INFO: No global web.xml found 2019-10-15T14:28:43.417841+00:00 heroku[web.1]: source=web.1 dyno=heroku.149646462.7ddc0379-5dd4-4b99-9ce3-6fa4415e6836 sample#memory_total=182.68MB sample#memory_rss=160.79MB sample#memory_cache=21.89MB sample#memory_swap=0.00MB sample#memory_pgpgin=49361pages sample#memory_pgpgout=3106pages sample#memory_quota=512.00MB 2019-10-15T14:28:45.696204+00:00 app[web.1]: Oct 15, 2019 2:28:45 PM org.apache.catalina.core.ApplicationContext log 2019-10-15T14:28:45.696217+00:00 app[web.1]: INFO: 1 Spring WebApplicationInitializers detected on classpath 2019-10-15T14:28:45.956951+00:00 app[web.1]: Oct 15, 2019 2:28:45 PM org.apache.jasper.servlet.TldScanner scanJars 2019-10-15T14:28:45.956976+00:00 app[web.1]: INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 2019-10-15T14:28:46.038714+00:00 app[web.1]: Oct 15, 2019 2:28:46 PM org.apache.coyote.AbstractProtocol start 2019-10-15T14:28:46.038718+00:00 app[web.1]: INFO: Starting ProtocolHandler ["http-nio-37873"] 2019-10-15T14:29:04.546619+00:00 heroku[web.1]: source=web.1 dyno=heroku.149646462.7ddc0379-5dd4-4b99-9ce3-6fa4415e6836 sample#memory_total=226.06MB sample#memory_rss=204.18MB sample#memory_cache=21.89MB sample#memory_swap=0.00MB sample#memory_pgpgin=67528pages sample#memory_pgpgout=10167pages sample#memory_quota=512.00MB 2019-10-15T14:29:16.015657+00:00 heroku[router]: at=info method=GET path="/" host=slupov-personal.herokuapp.com request_id=e2a97f5d-582d-4880-b26d-f033bf54c29d fwd="87.116.88.98" dyno=web.1 connect=1ms service=57ms status=404 bytes=1230 protocol=https 2019-10-15T14:29:26.035499+00:00 heroku[web.1]: source=web.1 dyno=heroku.149646462.7ddc0379-5dd4-4b99-9ce3-6fa4415e6836 sample#load_avg_1m=0.98 2019-10-15T14:29:26.054298+00:00 heroku[web.1]: source=web.1 dyno=heroku.149646462.7ddc0379-5dd4-4b99-9ce3-6fa4415e6836 sample#memory_total=226.78MB sample#memory_rss=204.89MB sample#memory_cache=21.89MB sample#memory_swap=0.00MB sample#memory_pgpgin=67711pages sample#memory_pgpgout=10167pages sample#memory_quota=512.00MB

seamaster
  • 381
  • 1
  • 4
  • 12
  • Have you tried `heroku open`? What URL does it open? What is in your `heroku logs`? – madhead Oct 15 '19 at 14:25
  • @madhead I have - it opens slupov-personal.herokuapp.com I've edited my post to contain the Heroku logs now. – seamaster Oct 15 '19 at 14:49
  • Do you have a request mapping for `"/"` in your codebase? – madhead Oct 15 '19 at 14:51
  • @madhead I do, it works on a local machine. Here's my HomeController: https://github.com/Slupov/SlupovPersonal/blob/master/src/main/java/com/slupov/controllers/HomeController.java – seamaster Oct 15 '19 at 14:53
  • how do you run the app locally? Have you tried `heroku local`? – codefinger Oct 15 '19 at 15:20
  • @codefinger I run it on local Tomcat server installation. `heroku local` prints out the following lines: [WARN] Cannot read property '1' of null [FAIL] No Procfile and no package.json file found in Current Directory - See run --help which is strange because the Procfile is clearly in the correct directory. Even `heroku local --procfile=Procfile` does not locate it properly ... – seamaster Oct 15 '19 at 15:37

0 Answers0