Reputation: 486
I have deployed my Spring Boot application on Heroku, and the build is succeeded. However, when I try to hit the end-points from the Postman, I get the 503 Service Unavailable
And, I inspect the Heroku logs and the bellow log shows where the app was crushed
2020-06-05T17:09:50.000000+00:00 app[api]: Build succeeded
2020-06-05T17:09:53.277483+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=17183 $JAVA_OPTS -jar target/ecommerce-0.0.1-SNAPSHOT.jar`
2020-06-05T17:09:55.407426+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-06-05T17:09:55.411915+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-06-05T17:09:55.581646+00:00 app[web.1]: no main manifest attribute, in target/ecommerce-0.0.1-SNAPSHOT.jar
2020-06-05T17:09:55.622586+00:00 heroku[web.1]: Process exited with status 1
2020-06-05T17:09:55.664598+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-05T17:10:16.658626+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/api/v1/item" host=xxx.com request_id=zz fwd="80.152.42.430" dyno= connect= service= status=503 bytes= protocol=https
2020-06-05T17:10:31.186284+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/api/v1/authenticate" host=xxx.com request_id=yy fwd="80.152.42.430" dyno= connect= service= status=503 bytes= protocol=https
Please note that, the application was working fine without crushing until I have applied security on the end-points. The bellow code shows how I configured the protected and unprotected end-points. The app crushes when I try to hit the endpoints whether is protected or unprotected. It seems to me that Heroku does not like the hard coded paths. Is this the correct way to give paths?
By the way, the app works fine locally.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.authorizeRequests()
.antMatchers("/api/v1/authenticate", "/api/v1/user/registration")
.permitAll()
.antMatchers( "/api/v1/item", "/api/v1/item/*")
.permitAll()
.anyRequest()
.authenticated()
.and()
.exceptionHandling()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class);
}
Procfile
web: java $JAVA_OPTS -jar target/ecommerce-0.0.1-SNAPSHOT.jar -Dserver.port=$PORT
Update
This is what I see on Postman as response:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>Application Error</title>
<style media="screen">
html,
body,
iframe {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe>
</body>
</html>
Upvotes: 0
Views: 4011