Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
71 views
in Technique[技术] by (71.8m points)

java - Application Error after a successful deployment at Heroku

I have a spring-boot project working fine in IntelliJ IDE, which I tried to deploy at Heroku server. The project was successfully deployed, but when I tried to access it from POSTMAN, I get the 503 error: the service is not available.

Here the logging after a successful deployment from Heroku:

-----> Building on the Heroku-20 stack
-----> Java app detected
-----> Installing JDK 1.8... done
-----> Executing Maven
       $ ./mvnw -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO] 
       [INFO] ----------------< io.slcoder:authentication-server >-----------------
       [INFO] Building authentication-server 0.0.1-SNAPSHOT
       [INFO] --------------------------------[ war ]---------------------------------
       [INFO] 
       [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ authentication-server ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ authentication-server ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ authentication-server ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] Copying 1 resource
       [INFO] Copying 1 resource
       [INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ authentication-server ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 9 source files to /tmp/build_d09a68b1_/target/classes
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ authentication-server ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] skip non existing resourceDirectory /tmp/build_d09a68b1_/src/test/resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ authentication-server ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 1 source file to /tmp/build_d09a68b1_/target/test-classes
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ authentication-server ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-war-plugin:3.3.1:war (default-war) @ authentication-server ---
       [INFO] Packaging webapp
       [INFO] Assembling webapp [authentication-server] in [/tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT]
       [INFO] Processing war project
       [INFO] Building war: /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war
       [INFO] 
       [INFO] --- spring-boot-maven-plugin:2.4.1:repackage (repackage) @ authentication-server ---
       [INFO] Replacing main artifact with repackaged archive
       [INFO] 
       [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ authentication-server ---
       [INFO] Installing /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.war
       [INFO] Installing /tmp/build_d09a68b1_/pom.xml to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time:  8.024 s
       [INFO] Finished at: 2021-01-28T20:29:08Z
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types -> (none)
-----> Compressing...
       Done: 149.5M

Application log at Heroku:

2021-01-28T21:06:14.000000+00:00 app[api]: Build started by user [email protected]
2021-01-28T21:06:43.212587+00:00 app[api]: Release v12 created by user [email protected]
2021-01-28T21:06:43.212587+00:00 app[api]: Deploy f113390b by user [email protected]
2021-01-28T21:06:50.000000+00:00 app[api]: Build succeeded
2021-01-28T21:06:55.588865+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=8710722d-c858-423a-bb8b-9268ef8318f3 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-28T21:06:59.516531+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=0d6f4102-5dba-44b4-b717-d6d732d236bd fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:50.789994+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=fcba05fd-3c76-4830-af3e-dfc697b2f190 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:52.530644+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=77736faf-0206-49dc-80be-3a1c0b5f061a fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:20:59.963444+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=c66098e0-1893-4d3f-90e3-e08f3afe0cea fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:21:02.909523+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=ee94b09c-f8c8-4783-a951-0c511007f93f fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https

Here is my POM.xml file:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>io.slcoder</groupId>
    <artifactId>authentication-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>authentication-server</name>
    <description>Server dedicated to authentication</description>
    <packaging>war</packaging>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties :

spring.datasource.url=jdbc:mysql://zt9j9hwaktmzqprk:eayk987igm1t1shd@esilxl0nthgloe1y.chr7pe7iynqr.eu-west-1.rds.amazonaws.com:3306/vqa34ov9ga2iumfm
spring.datasource.username=zt9j9hwaktmzqprk
spring.datasource.password=****************
spring.datasource.initialization-mode = always
spring.datasource.max-active=10

Could anyone help me out ? thanks in advance.

question from:https://stackoverflow.com/questions/65945017/application-error-after-a-successful-deployment-at-heroku

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ultimately, the core issue is that Heroku does not know how to run your application. You usually tell Heroku how to run your application with a Procfile.

However, since you're running Spring Boot, we will detect this and write out a Procfile for you. This did not happen here because you package your application as a WAR file which we cannot run as a standalone application.

If you change your Spring Boot packaging to JAR, Heroku should detect your app as a Spring boot app and you don't even need a Procfile. Try changing <packaging>war</packaging> to <packaging>jar</packaging> in your pom.xml.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...