Basic Controller Configuration Not working in Spring Boot - java

I am creating a sample project using Spring Boot and tried to map / with a simple String message. I have used #Controller annotation for this purpose. But for some reason the mapping is not working. I have also included #ComponentScan and #EnableWebMvc with no luck.
I have used maven spring-boot:run goal to run. Uploaded the project at https://github.com/tejact/SpringBasicsTreeHouse.
Here is the controller:
package Controller;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Component
#Controller
public class GifController {
#RequestMapping("/")
#ResponseBody
public String listAllGifs() {
return "Listing all gifs : Madhu";
}
}
The main application entry:
package com.teja;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
#EnableAutoConfiguration
#ComponentScan
#EnableWebMvc
public class AppConfig {
public static void main(String args[]) {
SpringApplication.run(AppConfig.class, args);
}
}
And Spring Boot logs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpingBasicsTreeHouse 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) > test-compile # SpingBasicsTreeHouse >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SpingBasicsTreeHouse ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # SpingBasicsTreeHouse ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 2 source files to C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SpingBasicsTreeHouse ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # SpingBasicsTreeHouse ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) < test-compile # SpingBasicsTreeHouse <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) # SpingBasicsTreeHouse ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2016-07-31 13:18:24.593 INFO 11084 --- [ main] com.teja.AppConfig : Starting AppConfig on Teja-PC with PID 11084 (C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse\target\classes started by Teja in C:\Users\Teja\git\SpringBasicsTreeHOuse\SpingBasicsTreeHouse)
2016-07-31 13:18:24.598 INFO 11084 --- [ main] com.teja.AppConfig : No active profile set, falling back to default profiles: default
2016-07-31 13:18:24.712 INFO 11084 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ae4a4a3: startup date [Sun Jul 31 13:18:24 EDT 2016]; root of context hierarchy
2016-07-31 13:18:26.868 INFO 11084 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-07-31 13:18:26.885 INFO 11084 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-07-31 13:18:26.886 INFO 11084 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2016-07-31 13:18:27.002 INFO 11084 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-07-31 13:18:27.003 INFO 11084 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2297 ms
2016-07-31 13:18:27.184 INFO 11084 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-07-31 13:18:27.191 INFO 11084 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-07-31 13:18:27.434 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ae4a4a3: startup date [Sun Jul 31 13:18:24 EDT 2016]; root of context hierarchy
2016-07-31 13:18:27.582 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-07-31 13:18:27.587 INFO 11084 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-07-31 13:18:28.004 INFO 11084 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-07-31 13:18:28.082 INFO 11084 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-07-31 13:18:28.087 INFO 11084 --- [ main] com.teja.AppConfig : Started AppConfig in 4.278 seconds (JVM running for 12.677)
Also my pom.xml looks like the following:
<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>TreeHouse</groupId>
<artifactId>SpingBasicsTreeHouse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

By default #ComponentScan scans the the current package and all the sub packages.
In your case AppConfig class is in package com.teja and the GifController is in Controller package, so it's not scanned.
Move GifController to com.teja.controller for example, or any other sub package of com.teja and it will work.
Usually I keep the bootstraping class and all the configuration classes in package named <com|org|etc>.<myCompany>.<myProject> and then create the other packages as sub packages of this one.
Also you don't need both #Component and #Controller. Remove #Component -#Controller already inherits #Component.

Related

I am using spring boot framework for my backend. Using mysql as database and tomcat as web server War file wont work

When i build it using mavan. the war file was generated, and I deployed it in tomcat but it wont work??
the war file doesnt work. If i try to click the link in tomcat. The web app says 404. So what is wrong with this. i attached my main class file, application properties and pom.xml file. If i build a war file. then i deployed in tomcat. My database doesnt create any tables I guess there is something wrong with my jdbc connection and my tomcat webapp. so please verify the code and gimme some answers
Main Class
package com.eot.eot;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
#SpringBootApplication
public class EotApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
System.getProperties().put("server.port", 8081);
SpringApplication.run(EotApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(EotApplication.class);
}
#Component
#Order(Ordered.HIGHEST_PRECEDENCE)
public class CorsFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods",
"ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Key, Authorization");
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
chain.doFilter(req, res);
}
}
public void init(FilterConfig filterConfig) {
// not needed
}
public void destroy() {
//not needed
}
}
}
Application properties
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/onlinedb
spring.datasource.username= root
spring.datasource.password= 1234
spring.jpa.show-sql= true
spring.jpa.hibernate.ddl-auto= update
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5Dialect
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 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.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.eot</groupId>
<artifactId>eot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>eot</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<start-class>com.eot.eot.EotApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
terminal mavan build
PS D:\Studies\EOT\EOT-BE\eot> & "d:\Studies\EOT\EOT-BE\eot\mvnw.cmd" clean -f "d:\Studies\EOT\EOT-BE\eot\pom.xml"
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< com.eot:eot >-----------------------------
[INFO] Building eot 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # eot ---
[INFO] Deleting d:\Studies\EOT\EOT-BE\eot\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.889 s
[INFO] Finished at: 2021-05-03T09:04:53+05:30
[INFO] ------------------------------------------------------------------------
PS D:\Studies\EOT\EOT-BE\eot> & "d:\Studies\EOT\EOT-BE\eot\mvnw.cmd" install -f "d:\Studies\EOT\EOT-BE\eot\pom.xml"
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< com.eot:eot >-----------------------------
[INFO] Building eot 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # eot ---
[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 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # eot ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to d:\Studies\EOT\EOT-BE\eot\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # eot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory d:\Studies\EOT\EOT-BE\eot\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # eot ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to d:\Studies\EOT\EOT-BE\eot\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # eot ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.eot.eot.EotApplicationTests
09:07:15.570 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
09:07:15.690 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
09:07:15.916 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.eot.eot.EotApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
09:07:16.094 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither #ContextConfiguration nor #ContextHierarchy found for test
class [com.eot.eot.EotApplicationTests], using SpringBootContextLoader
09:07:16.149 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.eot.eot.EotApplicationTests]: class path resource [com/eot/eot/EotApplicationTests-context.xml] does not exist
09:07:16.151 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.eot.eot.EotApplicationTests]: class path resource [com/eot/eot/EotApplicationTestsContext.groovy] does not exist
09:07:16.151 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.eot.eot.EotApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
09:07:16.154 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.eot.eot.EotApplicationTests]: EotApplicationTests does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
09:07:16.564 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.eot.eot.EotApplicationTests]
09:07:17.114 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [d:\Studies\EOT\EOT-BE\eot\target\classes\com\eot\eot\EotApplication.class]
09:07:17.119 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found #SpringBootConfiguration com.eot.eot.EotApplication for test
class com.eot.eot.EotApplicationTests
09:07:18.250 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - #TestExecutionListeners is not present for class [com.eot.eot.EotApplicationTests]: using defaults.
09:07:18.252 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
09:07:18.685 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#7d42c224, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#56aaaecd, org.springframework.test.context.event.ApplicationEventsTestExecutionListener#522a32b1, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#35390ee3, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#5e01a982, org.springframework.test.context.support.DirtiesContextTestExecutionListener#5ddea849, org.springframework.test.context.transaction.TransactionalTestExecutionListener#5ee2b6f9, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#23d1e5d0, org.springframework.test.context.event.EventPublishingTestExecutionListener#704f1591, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#58fb7731, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#13e547a9, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#3fb6cf60, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#37ddb69a, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#349c1daf, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener#dfddc9a]
09:07:18.726 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext#18c5069b testClass = EotApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration#3a0d172f testClass = EotApplicationTests, locations = '{}', classes = '{class com.eot.eot.EotApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer#13d9cbf5, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer#c667f46, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer#0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer#3b5fad2d, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer#30b6ffe0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer#0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer#609bcfb6, org.springframework.boot.test.context.SpringBootTestArgs#1, org.springframework.boot.test.context.SpringBootTestWebEnvironment#c267ef4], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes
= map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with #DirtiesContext [false] with mode [null].
09:07:19.110 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.5)
2021-05-03 09:07:21.560 INFO 2648 --- [ main] com.eot.eot.EotApplicationTests : Starting EotApplicationTests using Java 11.0.10 on DESKTOP-QPK38JR with PID 2648 (started by Thiru in d:\Studies\EOT\EOT-BE\eot)
2021-05-03 09:07:21.572 INFO 2648 --- [ main] com.eot.eot.EotApplicationTests : No active profile set, falling back to default profiles: default
2021-05-03 09:07:26.508 INFO 2648 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-05-03 09:07:26.968 INFO 2648 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 425 ms. Found 3 JPA repository interfaces.
2021-05-03 09:07:30.618 INFO 2648 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-05-03 09:07:31.093 INFO 2648 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.30.Final
2021-05-03 09:07:32.522 INFO 2648 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-05-03 09:07:34.614 INFO 2648 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-05-03 09:07:37.186 INFO 2648 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-05-03 09:07:37.408 INFO 2648 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2021-05-03 09:07:42.498 INFO 2648 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-05-03 09:07:42.548 INFO 2648 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-05-03 09:07:45.363 WARN 2648 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-05-03 09:07:46.741 INFO 2648 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-03 09:07:48.091 WARN 2648 --- [ main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2021-05-03 09:07:48.795 INFO 2648 --- [ main] com.eot.eot.EotApplicationTests : Started EotApplicationTests in 29.627 seconds (JVM running for 39.577)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 35.433 s - in com.eot.eot.EotApplicationTests
2021-05-03 09:07:50.415 INFO 2648 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-05-03 09:07:50.424 INFO 2648 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-05-03 09:07:50.453 INFO 2648 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-05-03 09:07:50.599 INFO 2648 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-war-plugin:3.3.1:war (default-war) # eot ---
[INFO] Packaging webapp
[INFO] Assembling webapp [eot] in [d:\Studies\EOT\EOT-BE\eot\target\eot-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Building war: d:\Studies\EOT\EOT-BE\eot\target\eot-0.0.1-SNAPSHOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.5:repackage (repackage) # eot ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # eot ---
[INFO] Installing d:\Studies\EOT\EOT-BE\eot\target\eot-0.0.1-SNAPSHOT.war to C:\Users\Thiru\.m2\repository\com\eot\eot\0.0.1-SNAPSHOT\eot-0.0.1-SNAPSHOT.war
[INFO] Installing d:\Studies\EOT\EOT-BE\eot\pom.xml to C:\Users\Thiru\.m2\repository\com\eot\eot\0.0.1-SNAPSHOT\eot-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:17 min
[INFO] Finished at: 2021-05-03T09:08:42+05:30
[INFO] ------------------------------------------------------------------------
```[tomcat webapp][1]
[1]: https://i.stack.imgur.com/utjwv.png

Spring Boot 404 on REST API calls only

Issue:
I'm working on a Spring-Boot Web Application that needs to be deployed on tomcat (WAR file). When running the application as Java (right click application.java file and run as Java in Eclipse) or running via mvnw.cmd spring-boot:run, everything works PERFECTLY (home page shows, all CRUD operations work).
When I export a WAR file and deploy to tomcat, my static web content and homepage still load fine, but any API calls return a 404 response.
This project was created using Spring Initializr. I've tried exporting via Eclipse war export, and mvnw.cmd package. Placed the WAR file in webapps directory on server and ran.
Directory structure:
Application file:
package com.blank.systemshare;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class SystemshareApplication {
public static void main(String[] args) {
SpringApplication.run(SystemshareApplication.class, args);
}
}
ServletInitializer:
package com.blank.systemshare;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SystemshareApplication.class);
}
}
Controller:
package com.blank.systemshare.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blank.systemshare.exception.ResourceNotFoundException;
import com.blank.systemshare.model.System;
import com.blank.systemshare.repository.SystemRepository;
#RestController
#RequestMapping("/api/v1/")
public class SystemController {
#Autowired
private SystemRepository systemRepository;
// get systems
#GetMapping("systems")
public List<System> getSystems() {
return this.systemRepository.findAllByOrderByVersionDesc();
}
// create system
#PostMapping("systems")
public System createSystem(#RequestBody System system) {
return this.systemRepository.save(system);
}
// update system
#PutMapping("systems/{id}")
public ResponseEntity<System> updateSystem(#PathVariable(value = "id") Long systemId,
#Valid #RequestBody System systemDetails) throws ResourceNotFoundException {
System system = systemRepository.findById(systemId)
.orElseThrow(() -> new ResourceNotFoundException("System not found - ID: " + systemId));
system.setVersion(systemDetails.getVersion());
system.setUrl(systemDetails.getUrl());
system.setCredentials(systemDetails.getCredentials());
system.setFrameworks(systemDetails.getFrameworks());
system.setFw_credentials(systemDetails.getFw_credentials());
system.setNotes(systemDetails.getNotes());
system.setOwner(systemDetails.getOwner());
return ResponseEntity.ok(this.systemRepository.save(system));
}
//delete system
#DeleteMapping("systems/{id}")
public Map<String, Boolean> deleteSystem(#PathVariable(value = "id") Long systemId) throws ResourceNotFoundException {
System system = systemRepository.findById(systemId)
.orElseThrow(() -> new ResourceNotFoundException("System not found - ID: " + systemId));
this.systemRepository.delete(system);
Map<String, Boolean> response = new HashMap<>();
response.put("deleted", Boolean.TRUE);
return response;
}
}
Repository:
package com.blank.systemshare.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.blank.systemshare.model.System;
#Repository
public interface SystemRepository extends JpaRepository<System, Long>{
public List<System> findAllByOrderByVersionDesc();
}
App.js
var systemShareApp = angular.module('systemShareApp', [])
.controller('mainController', ($scope, $http, $window) => {
$scope.version = '1.0';
$scope.systemData = {};
$scope.createSystemFormData = {};
$scope.editSystemFormData = {};
$scope.dbErrorStatus = false;
// Get all systems
var getAllSystems = function() {
$http.get('/systemshare/api/v1/systems')
.success((data) => {
$scope.systemData = data;
$scope.dbErrorStatus = false;
console.log(data);
})
.error((error) => {
console.log('Error: ' + error);
$scope.dbErrorStatus = true;
});
};
//initial load of page - get systems.
getAllSystems();
// Create a new system
$scope.createSystem = () => {
$http.post('/systemshare/api/v1/systems', $scope.createSystemFormData)
.success((data) => {
$scope.createSystemFormData = {};
getAllSystems();
})
.error((error) => {
console.log('Error: ' + error);
});
};
// Delete a system
$scope.deleteSystem = (systemID) => {
$http.delete('/systemshare/api/v1/systems/' + systemID)
.success((data) => {
getAllSystems();
})
.error((data) => {
console.log('Error: ' + data);
});
};
// Update a system
$scope.updateSystem = (systemID) => {
$http.put('/systemshare/api/v1/systems/' + systemID, $scope.editSystemFormData)
.success((data) => {
$scope.editSystemFormData = {};
getAllSystems();
})
.error((data) => {
console.log('Error: ' + data);
});
};
//select system function for transfer of object data in list to modal.
$scope.selectSystem = function(system) {
$scope.thisSystem = system;
//editSystemFormData Modal updates:
$scope.editSystemFormData.owner = system.owner;
$scope.editSystemFormData.version = system.version;
$scope.editSystemFormData.url = system.url;
$scope.editSystemFormData.credentials = system.credentials;
$scope.editSystemFormData.frameworks = system.frameworks;
$scope.editSystemFormData.fw_credentials = system.fw_credentials;
$scope.editSystemFormData.notes = system.notes;
};
});
Application.properties
spring.datasource.url=jdbc:postgresql://xx.xx.xxx.xxx:5432/systemshare
spring.datasource.username=xx
spring.datasource.password=xx
spring.jpa.show-sql=true
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
server.servlet.contextPath=/systemshare
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 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.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.blank</groupId>
<artifactId>systemshare</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>systemshare</name>
<description>System Share Project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
mvnw.cmd spring-boot:run output (working scenario)
mvnw.cmd spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.blank:systemshare >------------------------
[INFO] Building systemshare 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) > test-compile # systemshare >>>
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # systemshare ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # systemshare ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Users\user\Documents\JavaProjects\systemshare\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # systemshare ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\JavaProjects\systemshare\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # systemshare ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\user\Documents\JavaProjects\systemshare\target\test-classes
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) < test-compile # systemshare <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:run (default-cli) # systemshare ---
[INFO] Attaching agents: []
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-21 14:50:58.430 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : Starting SystemshareApplication on L37853WUS with PID 19748 (C:\Users\user\Documents\JavaProjects\systemshare\target\classes started by userin C:\Users\mck
eb2\Documents\JavaProjects\systemshare)
2020-04-21 14:50:58.435 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : No active profile set, falling back to default profiles: default
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\user\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files th
at do not exist: file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfi
sh/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/U
sers/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-04-21 14:50:58.513 INFO 19748 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-04-21 14:50:59.303 INFO 19748 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-21 14:50:59.383 INFO 19748 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 71ms. Found 1 JPA repository interfaces.
2020-04-21 14:51:00.475 INFO 19748 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-04-21 14:51:00.489 INFO 19748 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-21 14:51:00.490 INFO 19748 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-04-21 14:51:00.674 INFO 19748 --- [ restartedMain] o.a.c.c.C.[.[localhost].[/systemshare] : Initializing Spring embedded WebApplicationContext
2020-04-21 14:51:00.675 INFO 19748 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2161 ms
2020-04-21 14:51:00.858 INFO 19748 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-21 14:51:00.942 INFO 19748 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-21 14:51:01.117 INFO 19748 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-21 14:51:01.228 INFO 19748 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-21 14:51:01.603 INFO 19748 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-04-21 14:51:01.621 INFO 19748 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-04-21 14:51:02.803 INFO 19748 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-21 14:51:02.810 INFO 19748 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-21 14:51:02.825 INFO 19748 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-04-21 14:51:03.186 WARN 19748 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view
to disable this warning
2020-04-21 14:51:03.334 INFO 19748 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-21 14:51:03.402 INFO 19748 --- [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2020-04-21 14:51:03.571 INFO 19748 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/systemshare'
2020-04-21 14:51:03.575 INFO 19748 --- [ restartedMain] c.p.systemshare.SystemshareApplication : Started SystemshareApplication in 5.624 seconds (JVM running for 6.47)
2020-04-21 14:51:17.737 INFO 19748 --- [nio-8080-exec-1] o.a.c.c.C.[.[localhost].[/systemshare] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-04-21 14:51:17.737 INFO 19748 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-04-21 14:51:17.745 INFO 19748 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 7 ms
WAR deployed on tomcat (non-working scenario)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-21 14:55:49.434 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on L37853WUS with PID 12280 (C:\Users\user\Documents\Software\apache-tomcat-8.5.29\webapps\systemshare\WEB-INF\classes started by user in C:\Users\user\Documents\Software\apache-tomcat-8.5.29\bin)
2020-04-21 14:55:49.451 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : No active profile set, falling back to default profiles: default
2020-04-21 14:55:52.213 INFO 12280 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-21 14:55:52.458 INFO 12280 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 200ms. Found 1 JPA repository interfaces.
2020-04-21 14:55:53.923 INFO 12280 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4212 ms
2020-04-21 14:55:55.125 INFO 12280 --- [ost-startStop-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-21 14:55:55.675 INFO 12280 --- [ost-startStop-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-21 14:55:56.461 INFO 12280 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-21 14:55:57.051 INFO 12280 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-04-21 14:55:57.633 INFO 12280 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-04-21 14:55:57.728 INFO 12280 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-04-21 14:56:01.538 INFO 12280 --- [ost-startStop-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-04-21 14:56:01.578 INFO 12280 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-04-21 14:56:03.216 WARN 12280 --- [ost-startStop-1] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-21 14:56:03.699 INFO 12280 --- [ost-startStop-1] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-21 14:56:04.075 INFO 12280 --- [ost-startStop-1] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2020-04-21 14:56:04.472 INFO 12280 --- [ost-startStop-1] com.blank.systemshare.ServletInitializer : Started ServletInitializer in 16.741 seconds (JVM running for 32.139)
21-Apr-2020 14:56:04.517 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [C:\Users\user\Documents\Software\apache-tomcat-8.5.29\webapps\systemshare.war] has finished in [25,067] ms
Specific 404 error message from Chrome devtools:
{
"timestamp":"2020-04-21T19:50:27.749+0000",
"status":404,
"error":"Not Found",
"message":"No message available",
"path":"/systemshare/api/v1/systems"
}
Also, tomcat logs don't show anything useful.
Removing the ServletInitializer.java class and updating my application file to the following resolved the issue (extending SpringBootServletInitializer and overriding the configure method). Note that I tried this before, but built the application using both Eclipse and InteliJ. Both times the same issue still occurred. This final time I built using mvnw package and the WAR generated in the target directory worked.
package com.blank.systemshare;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
#SpringBootApplication
public class SystemshareApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SystemshareApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SystemshareApplication.class);
}
}
Try server.servlet.context-path instead of server.servlet.contextPath.

Getting 404 error with spring boot application on localhost no exceptions in log

I am new to spring-boot and have created a dummy app which has one controller method.
The packaging type for the application is mentioned as jar in pom file.
On deployment there are no errors in logs.
But still after a successful build and deployment when i try to access my localhost from browser i get a 404 error.
Below are the things which i have already tried to resolve the issue :
1) Including my main class and controller class in same package.
2) Having my main class in root package and controller in sub package.
3) Defining #RestController on class as well as method.
4) Extending SpringBootServletInitializer in my main class
package com.test.controller;
#SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
**Controller class**
package com.test.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#RestController
public class TestController {
public final Logger logger = LoggerFactory.getLogger(TestController.class);
#RequestMapping(value = "/test", method = RequestMethod.GET)
public String test() {
logger.info("This is a test message to check if logback is working");
return "Hello World";
}
}
So as per the result i should have got a Hello World message on my web page but instead i got an 404 error.
Below is the log on service startup :
"C:\Program Files\Java\jdk1.8.0_161\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Repositories\Personal\Mindship\resume-parser "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\plugins\maven\lib\maven3\bin\m2.conf" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version2019.1.3 spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building resume-parser 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) > test-compile # resume-parser >>>
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # resume-parser ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # resume-parser ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # resume-parser ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Repositories\Personal\Mindship\resume-parser\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # resume-parser ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) < test-compile # resume-parser <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) # resume-parser ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2019-07-19 14:21:43.166 INFO 7384 --- [ main] c.r.controller.ResumeParserApplication : Starting ResumeParserApplication on WKSBAN09VDF8243 with PID 7384 (C:\Repositories\Personal\Mindship\resume-parser\target\classes started by ankit.srivastava in C:\Repositories\Personal\Mindship\resume-parser)
2019-07-19 14:21:43.187 INFO 7384 --- [ main] c.r.controller.ResumeParserApplication : No active profile set, falling back to default profiles: default
2019-07-19 14:21:47.574 INFO 7384 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-07-19 14:21:47.685 INFO 7384 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-19 14:21:47.689 INFO 7384 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-07-19 14:21:47.956 INFO 7384 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-19 14:21:47.956 INFO 7384 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4599 ms
2019-07-19 14:21:48.900 INFO 7384 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-19 14:21:49.338 INFO 7384 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-07-19 14:21:49.338 INFO 7384 --- [ main] c.r.controller.ResumeParserApplication : Started ResumeParserApplication in 7.906 seconds (JVM running for 17.28)
2019-07-19 14:22:55.499 INFO 7384 --- [nio-8080-exec-8] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-07-19 14:22:55.500 INFO 7384 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-07-19 14:22:55.528 INFO 7384 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Completed initialization in 20 ms

Spring-boot war application is running well on windows but not in ubuntu

I have a spring-boot war application that runs perfectly in windows and ios, then I tried to run it in linux. It did run and build normally but when I tried to open it via browser it returns invalid http responses in chrome and some undeciphered codes in Firefox. I used this pc to run another spring-boot projects and they work just fine. I'm using Maven 3.3.9 and Ubuntu 16.04.
Here's what my pom.xml looks like
<?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>com.example</groupId>
<artifactId>hris</artifactId>
<version>0.1</version>
<packaging>war</packaging>
<name>hris</name>
<description>sso template for hris</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212.jre7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>3.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
<version>2.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4 -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<!-- CAS Integration -->
<dependency>
<groupId>com.kakawait</groupId>
<artifactId>cas-security-spring-boot-starter</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>com.github.dandelion</groupId>
<artifactId>datatables-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here's what's written out when I run the app
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building dapil 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.5.9.RELEASE:run (default-cli) > test-compile # hris >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # hris ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 953 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # hris ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # hris ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /******/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # hris ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.5.9.RELEASE:run (default-cli) < test-compile # hris <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.9.RELEASE:run (default-cli) # hris ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
2018-04-12 12:49:22.096 INFO 30740 --- [ main] c.example.hris.HRISApplication : Starting HRISApplication on Lenovo-G40-70 with PID 30740 (/*******/target/classes started by ****** in **********)
2018-04-12 12:49:22.101 INFO 30740 --- [ main] c.example.hris.HRISApplication : No active profile set, falling back to default profiles: default
2018-04-12 12:49:22.632 INFO 30740 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e79a00: startup date [Thu Apr 12 12:49:22 WIB 2018]; root of context hierarchy
2018-04-12 12:49:24.064 WARN 30740 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example.hris]' package. Please check your configuration.
2018-04-12 12:49:25.583 INFO 30740 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 12000 (https)
2018-04-12 12:49:25.611 INFO 30740 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-04-12 12:49:25.613 INFO 30740 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23
2018-04-12 12:49:25.766 INFO 30740 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-04-12 12:49:25.767 INFO 30740 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3141 ms
2018-04-12 12:49:26.053 INFO 30740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-12 12:49:26.054 INFO 30740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-12 12:49:26.054 INFO 30740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-12 12:49:26.055 INFO 30740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-12 12:49:26.056 INFO 30740 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-04-12 12:49:26.057 INFO 30740 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-04-12 12:49:28.032 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e79a00: startup date [Thu Apr 12 12:49:22 WIB 2018]; root of context hierarchy
2018-04-12 12:49:28.050 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Detected #ModelAttribute methods in siteController
2018-04-12 12:49:28.175 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/edit/{id}],methods=[POST]}" onto public java.lang.String com.example.hris.controller.AuthController.postAuthEdit(com.example.hris.dto.form.cmd.AuthItemCmd,org.springframework.validation.BindingResult,org.springframework.web.servlet.mvc.support.RedirectAttributes)
2018-04-12 12:49:28.176 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/create],methods=[GET]}" onto public java.lang.String com.example.hris.controller.AuthController.getAuthAdd(org.springframework.ui.Model)
2018-04-12 12:49:28.177 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/create],methods=[POST]}" onto public java.lang.String com.example.hris.controller.AuthController.postAuthAdd(com.example.hris.dto.form.cmd.AuthItemChildCmd,org.springframework.validation.BindingResult,org.springframework.web.servlet.mvc.support.RedirectAttributes)
2018-04-12 12:49:28.177 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/update/{id}],methods=[GET]}" onto public java.lang.String com.example.hris.controller.AuthController.getAuthEdit(java.lang.Long,org.springframework.ui.Model,org.springframework.web.servlet.mvc.support.RedirectAttributes)
2018-04-12 12:49:28.178 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/delete],methods=[POST]}" onto public boolean com.example.hris.controller.AuthController.postUserDeactivate(java.lang.String)
2018-04-12 12:49:28.178 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/manage],methods=[GET]}" onto public java.lang.String com.example.hris.controller.AuthController.indexGet(com.example.hris.dto.form.search.AuthItemSearchForm,org.springframework.validation.BindingResult,org.springframework.ui.Model)
2018-04-12 12:49:28.179 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/table],methods=[POST]}" onto public com.github.dandelion.datatables.core.ajax.DatatablesResponse<com.example.hris.dto.table.AuthItemItem> com.example.hris.controller.AuthController.postTableSearch(com.example.hris.dto.form.search.AuthItemSearchForm,javax.servlet.http.HttpServletRequest)
2018-04-12 12:49:28.181 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/signin],methods=[GET]}" onto public java.lang.String com.example.hris.controller.SiteController.login()
2018-04-12 12:49:28.181 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.example.hris.controller.SiteController.index()
2018-04-12 12:49:28.185 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-12 12:49:28.186 INFO 30740 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-04-12 12:49:28.250 INFO 30740 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-12 12:49:28.251 INFO 30740 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-12 12:49:28.337 INFO 30740 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-12 12:49:29.686 INFO 30740 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2018-04-12 12:49:29.830 INFO 30740 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#551f663f, org.springframework.security.web.context.SecurityContextPersistenceFilter#223b66, org.springframework.security.web.header.HeaderWriterFilter#37dc0139, org.jasig.cas.client.session.SingleSignOutFilter#4b658c91, org.springframework.security.web.authentication.logout.LogoutFilter#274ccf4f, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#13f8799a, org.springframework.security.cas.web.CasAuthenticationFilter#764ed709, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#422b1740, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#6e1eddc, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#7886ebc0, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#58ce6961, org.springframework.security.web.session.SessionManagementFilter#48408088, org.springframework.security.web.access.ExceptionTranslationFilter#4fa73638, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#46775723]
2018-04-12 12:49:29.853 INFO 30740 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#2ff438ee, org.springframework.security.web.context.SecurityContextPersistenceFilter#d3ea90c, org.springframework.security.web.header.HeaderWriterFilter#41ef1e45, org.springframework.security.web.authentication.logout.LogoutFilter#4e1c5a6a, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#3657e01, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#381dbdc1, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#1b991b1, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#4dd194c2, org.springframework.security.web.session.SessionManagementFilter#3b7b329e, org.springframework.security.web.access.ExceptionTranslationFilter#7f495bf9, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#ad57ac4]
2018-04-12 12:49:30.176 INFO 30740 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-04-12 12:49:31.983 INFO 30740 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 12000 (https)
2018-04-12 12:49:31.991 INFO 30740 --- [ main] c.example.hris.HRISApplication : Started HRISApplication in 10.454 seconds (JVM running for 16.918)
2018-04-12 12:49:48.922 INFO 30740 --- [ Thread-4] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e79a00: startup date [Thu Apr 12 12:49:22 WIB 2018]; root of context hierarchy
2018-04-12 12:49:48.928 INFO 30740 --- [ Thread-4] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I tried this on Ubuntu 17.10 but the same thing happened. Is there anything I can do to fix it? Thanks in advance
EDIT: I'm have openjdk8 in both version of ubuntu and windows. I'm not sure about the ios since its my friend's.
Here's how they look like when I tried to build it
in chromium & in firefox
I had this problem with spring-boot version 1.4.0.RELEASE and got resolved when switched to version 2.1.8.RELEASE

Web process failed to bind to $PORT within 90 seconds of launch

I am trying to deploy simple spring boot application with a single REST on heroku. The application is located here: application
My Procfile looks like this
web: java -jar target/java-cloud-sample-0.0.1-SNAPSHOT.jar -Dserver.port=$PORT
Build log on heroku looks like this
-----> Java app detected
-----> Installing JDK... version 9 installed
-----> Installing Maven... version 3.5.0 installed
-----> Maven home: /app/tmp/cache/.maven
-----> Java home: /tmp/build_26e32238a62f5da3214e452f0481421a/.jdk
-----> Build dir: /tmp/build_26e32238a62f5da3214e452f0481421a
-----> Executing build...
mvn -B -Duser.home=/tmp/build_26e32238a62f5da3214e452f0481421a -Dmaven.repo.local=/app/tmp/cache/.m2/repository -DskipTests=true -U clean install
[INFO] MAVEN_OPTS=-Xmx384m -Xss128m
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building java-cloud-sample 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # java-cloud-sample ---
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.6.RELEASE:build-info (default) # java-cloud-sample ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # java-cloud-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.2:compile (default-compile) # java-cloud-sample ---
[INFO] Required automodules detected. Please don't publish this project to a public artifact repository!
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /tmp/build_26e32238a62f5da3214e452f0481421a/target/classes
[INFO]
....
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # java-cloud-sample ---
[INFO] Installing /tmp/build_26e32238a62f5da3214e452f0481421a/target/java-cloud-sample-0.0.1-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/com/lapots/breed/platform/cloud/java-cloud-sample/0.0.1-SNAPSHOT/java-cloud-sample-0.0.1-SNAPSHOT.jar
[INFO] Installing /tmp/build_26e32238a62f5da3214e452f0481421a/pom.xml to /app/tmp/cache/.m2/repository/com/lapots/breed/platform/cloud/java-cloud-sample/0.0.1-SNAPSHOT/java-cloud-sample-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.037 s
[INFO] Finished at: 2017-09-03T14:01:08Z
[INFO] Final Memory: 32M/107M
[INFO] ------------------------------------------------------------------------
-----> Cleaning enviroment
- Deleting local Maven repository... done
-----> Discovering process types
Procfile declares types -> web
-----> Compressing...
Done: 309.9M
-----> Launching...
! Warning: Your slug size exceeds our soft limit (309 MB) which may affect boot time.
Released v7
https://java-cloud-sample.herokuapp.com/ deployed to Heroku
Here is the log I get for the application
2017-09-03T14:05:04.778676+00:00 heroku[web.1]: Starting process with command `java -jar target/java-cloud-sample-0.0.1-SNAPSHOT.jar -Dserver.port=14556`
2017-09-03T14:05:10.685730+00:00 app[web.1]:
2017-09-03T14:05:10.685803+00:00 app[web.1]: . ____ _ __ _ _
2017-09-03T14:05:10.685868+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2017-09-03T14:05:10.685937+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2017-09-03T14:05:10.685992+00:00 app[web.1]: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2017-09-03T14:05:10.686055+00:00 app[web.1]: ' |____| .__|_| |_|_| |_\__, | / / / /
2017-09-03T14:05:10.686108+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2017-09-03T14:05:10.708407+00:00 app[web.1]: :: Spring Boot :: (v1.5.6.RELEASE)
2017-09-03T14:05:10.708470+00:00 app[web.1]:
2017-09-03T14:05:11.192342+00:00 app[web.1]: 2017-09-03 14:05:11.185 INFO 4 --- [ main] c.l.b.p.c.j.JavaCloudSampleApplication : Starting JavaCloudSampleApplication v0.0.1-SNAPSHOT on f4c891ec-7872-4f32-996e-1fe573ea2ca7 with PID 4 (/app/target/jav
a-cloud-sample-0.0.1-SNAPSHOT.jar started by u57312 in /app)
2017-09-03T14:05:11.193055+00:00 app[web.1]: 2017-09-03 14:05:11.192 INFO 4 --- [ main] c.l.b.p.c.j.JavaCloudSampleApplication : No active profile set, falling back to default profiles: default
2017-09-03T14:05:11.474167+00:00 app[web.1]: 2017-09-03 14:05:11.473 INFO 4 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#62150f9e: startup da
te [Sun Sep 03 14:05:11 UTC 2017]; root of context hierarchy
2017-09-03T14:05:14.172407+00:00 app[web.1]: WARNING: An illegal reflective access operation has occurred
2017-09-03T14:05:14.172418+00:00 app[web.1]: WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/app/target/java-cloud-sample-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.10.RELEASE.jar!/) to method java.lang.Class
Loader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
2017-09-03T14:05:14.172419+00:00 app[web.1]: WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
2017-09-03T14:05:14.172420+00:00 app[web.1]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2017-09-03T14:05:14.172425+00:00 app[web.1]: WARNING: All illegal access operations will be denied in a future release
2017-09-03T14:05:15.430298+00:00 app[web.1]: 2017-09-03 14:05:15.430 INFO 4 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-09-03T14:05:15.451153+00:00 app[web.1]: 2017-09-03 14:05:15.450 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-09-03T14:05:15.452398+00:00 app[web.1]: 2017-09-03 14:05:15.452 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-09-03T14:05:15.582784+00:00 app[web.1]: 2017-09-03 14:05:15.582 INFO 4 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-09-03T14:05:15.583083+00:00 app[web.1]: 2017-09-03 14:05:15.582 INFO 4 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4117 ms
2017-09-03T14:05:16.006331+00:00 app[web.1]: 2017-09-03 14:05:16.006 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-09-03T14:05:16.013268+00:00 app[web.1]: 2017-09-03 14:05:16.013 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2017-09-03T14:05:16.013794+00:00 app[web.1]: 2017-09-03 14:05:16.013 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-09-03T14:05:16.013969+00:00 app[web.1]: 2017-09-03 14:05:16.013 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-09-03T14:05:16.014080+00:00 app[web.1]: 2017-09-03 14:05:16.013 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-09-03T14:05:16.014311+00:00 app[web.1]: 2017-09-03 14:05:16.014 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-09-03T14:05:16.014462+00:00 app[web.1]: 2017-09-03 14:05:16.014 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2017-09-03T14:05:16.014603+00:00 app[web.1]: 2017-09-03 14:05:16.014 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2017-09-03T14:05:16.730294+00:00 app[web.1]: 2017-09-03 14:05:16.729 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#
62150f9e: startup date [Sun Sep 03 14:05:11 UTC 2017]; root of context hierarchy
2017-09-03T14:05:16.957338+00:00 app[web.1]: 2017-09-03 14:05:16.957 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/rest/hello]}" onto public java.lang.String com.lapots.breed.platform.cloud.javacloudsample.rest.HelloRestCon
troller.hello()
2017-09-03T14:05:16.967662+00:00 app[web.1]: 2017-09-03 14:05:16.967 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Objec
t>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-09-03T14:05:16.968232+00:00 app[web.1]: 2017-09-03 14:05:16.968 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.b
oot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-09-03T14:05:17.015875+00:00 app[web.1]: 2017-09-03 14:05:17.015 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestH
andler]
2017-09-03T14:05:17.015988+00:00 app[web.1]: 2017-09-03 14:05:17.015 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-03T14:05:17.073204+00:00 app[web.1]: 2017-09-03 14:05:17.072 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequ
estHandler]
2017-09-03T14:05:17.600843+00:00 app[web.1]: 2017-09-03 14:05:17.600 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json
]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.603060+00:00 app[web.1]: 2017-09-03 14:05:17.602 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || ap
plication/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
2017-09-03T14:05:17.606261+00:00 app[web.1]: 2017-09-03 14:05:17.606 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || ap
plication/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.610341+00:00 app[web.1]: 2017-09-03 14:05:17.610 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/js
on]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.611621+00:00 app[web.1]: 2017-09-03 14:05:17.611 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/js
on]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.616752+00:00 app[web.1]: 2017-09-03 14:05:17.616 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]
}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2017-09-03T14:05:17.617046+00:00 app[web.1]: 2017-09-03 14:05:17.616 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || applicatio
n/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.630560+00:00 app[web.1]: 2017-09-03 14:05:17.629 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springf
ramework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2017-09-03T14:05:17.642704+00:00 app[web.1]: 2017-09-03 14:05:17.642 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || appl
ication/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.650903+00:00 app[web.1]: 2017-09-03 14:05:17.650 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]
}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
2017-09-03T14:05:17.653138+00:00 app[web.1]: 2017-09-03 14:05:17.651 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json
],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
2017-09-03T14:05:17.654524+00:00 app[web.1]: 2017-09-03 14:05:17.653 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || applicatio
n/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.657622+00:00 app[web.1]: 2017-09-03 14:05:17.655 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || applicat
ion/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.663382+00:00 app[web.1]: 2017-09-03 14:05:17.658 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json
]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.672330+00:00 app[web.1]: 2017-09-03 14:05:17.672 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" o
nto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2017-09-03T14:05:17.683275+00:00 app[web.1]: 2017-09-03 14:05:17.683 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}
" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-09-03T14:05:17.685550+00:00 app[web.1]: 2017-09-03 14:05:17.685 INFO 4 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/
json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2017-09-03T14:05:17.962047+00:00 app[web.1]: 2017-09-03 14:05:17.961 INFO 4 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-03T14:05:17.981648+00:00 app[web.1]: 2017-09-03 14:05:17.981 INFO 4 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2017-09-03T14:05:18.309932+00:00 app[web.1]: 2017-09-03 14:05:18.309 INFO 4 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-09-03T14:05:18.328371+00:00 app[web.1]: 2017-09-03 14:05:18.325 INFO 4 --- [ main] c.l.b.p.c.j.JavaCloudSampleApplication : Started JavaCloudSampleApplication in 9.561 seconds (JVM running for 10.785)
2017-09-03T14:05:45.484008+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=java-cloud-sample.herokuapp.com request_id=fe61c421-b7c6-47a5-ad20-cb78b2593c53 fwd="93.171.108.185" dyno= connect= service= status=503 bytes= pr
otocol=https
2017-09-03T14:05:50.186722+00:00 heroku[web.1]: Process running mem=514M(100.5%)
2017-09-03T14:05:50.186875+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2017-09-03T14:06:17.392379+00:00 heroku[web.1]: Process running mem=514M(100.5%)
2017-09-03T14:06:17.392521+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2017-09-03T14:06:35.116087+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2017-09-03T14:06:35.116157+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-09-03T14:06:35.322422+00:00 heroku[web.1]: Process exited with status 137
2017-09-03T14:06:35.338320+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-03T14:06:36.190416+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=java-cloud-sample.herokuapp.com request_id=1b975133-4ab4-4ea0-8366-985fd34ee359 fwd="93.171.108.185" dyno= connect= service= status=503 bytes= protoco
l=https
2017-09-03T14:06:36.814442+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=java-cloud-sample.herokuapp.com request_id=04f98634-63bf-48ea-ac2e-7a43b8c52b85 fwd="93.171.108.185" dyno= connect= service= status=503 bytes= protoco
l=https
2017-09-03T14:07:00.220008+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/rest/hello" host=java-cloud-sample.herokuapp.com request_id=5b88705e-ac20-4913-818f-4aa0e9f79914 fwd="93.171.108.185" dyno= connect= service= status=503 byte
s= protocol=https
What is the problem? Why it cannot bind to $PORT?
To solve the problem I did two things.
Firstly, as it exceed 512 mb I set config var
JAVA_TOOL_OPTIONS = -Xmx300m
Second I changed slightly command line for starting the app
java $JAVA_OPTS -Dserver.port=$PORT -jar target/java-cloud-sample-0.0.1-SNAPSHOT.jar
And now it works!

Categories

Resources