Springboot logging layout - spring-boot

I don't understand what the numbers after logging level indicate
2019-03-05 10:57:51.112 INFO 45469 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1358 ms
2019-03-05 10:57:51.698 INFO 45469 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-05 10:57:51.702 INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
For example INFO 45469 what does 45469 indicate?
Other example
1857 [main] 2021-06-23T17:23:04.222+0300 INFO org.springframework.boot.SpringApplication -
1856 [main] 2021-06-23T17:23:04.221+0300 DEBUG org.springframework.boot.StartupInfoLogger -
1853 [main] 2021-06-23T17:23:04.218+0300 INFO org.springframework.boot.StartupInfoLogger -
what is the purpose of the first column?

By looking at the log4j2.xml in spring boot project, it seems the default pattern for the console is :
<Property name="CONSOLE_LOG_PATTERN">
%clr{%d{${LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}
</Property>
So the number should indicates the PID, so the ID of the process which runs your app.

Personally I never used the default format (for my own logs, yours are the startup logs). My first thing is to replace it whith my configuration. It looks and based on this it should be the PID (process ID).

Related

Spring boot: I am getting whitelabel error pae instead of view

I am writing spring boot application with spring MVC and H2 in memory database. I have a controller with mapping /posts on findAllPosts() method which returns post.jsp view. But when i run application and hit localhost:8080/posts it shows error page. In console it also shows mapping done for /posts.
Controller class-
package com.H2DatabaseDemo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.H2DatabaseDemo.model.Post;
import com.H2DatabaseDemo.services.PostService;
#Controller
public class H2DemoController {
#Autowired
private PostService postService;
#RequestMapping("/posts")
public String findAllPost(Model model)
{
List<Post> thePosts=postService.findAllPost();
model.addAttribute("posts",thePosts);
return "posts";
}
}
Appication class-
package com.H2DatabaseDemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
#SpringBootApplication
public class H2DatabaseDemoApplication {
public static void main(String[] args) {
SpringApplication.run(H2DatabaseDemoApplication.class, args);
}
}
property file-
spring.h2.console.enabled=true
spring.h2.console.path=/console
spring.datasource.url=jdbc:h2:mem:h2demo-app
spring.mvc.view.prefix: /WEB-INF/view/
spring.mvc.view.suffix: .jsp
stack trace-
:: Spring Boot :: (v2.0.4.RELEASE)
2018-09-16 09:19:50.379 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : Starting H2DatabaseDemoApplication on DESKTOP-7NILS0D with PID 12868 (D:\springCourse\H2DatabaseDemo\target\classes started by Mrugesh in D:\springCourse\H2DatabaseDemo)
2018-09-16 09:19:50.384 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : No active profile set, falling back to default profiles: default
2018-09-16 09:19:50.459 INFO 12868 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3d299e3: startup date [Sun Sep 16 09:19:50 IST 2018]; root of context hierarchy
2018-09-16 09:19:52.000 INFO 12868 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$74090544] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-16 09:19:52.796 INFO 12868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-09-16 09:19:52.833 INFO 12868 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-09-16 09:19:52.834 INFO 12868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-09-16 09:19:52.849 INFO 12868 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_171/bin/server;C:/Program Files/Java/jre1.8.0_171/bin;C:/Program Files/Java/jre1.8.0_171/lib/amd64;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\Mrugesh\AppData\Roaming\npm;C:\Users\Mrugesh\AppData\Local\Microsoft\WindowsApps;C:\Users\Mrugesh\AppData\Local\GitHubDesktop\bin;C:\eclipse;;.]
2018-09-16 09:19:53.018 INFO 12868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-09-16 09:19:53.018 INFO 12868 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2562 ms
2018-09-16 09:19:53.160 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-09-16 09:19:53.162 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet webServlet mapped to [/console/*]
2018-09-16 09:19:53.167 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-16 09:19:53.167 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-16 09:19:53.168 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-16 09:19:53.168 INFO 12868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-16 09:19:53.408 INFO 12868 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-09-16 09:19:53.806 INFO 12868 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-09-16 09:19:53.876 INFO 12868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-09-16 09:19:53.905 INFO 12868 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-09-16 09:19:54.036 INFO 12868 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-09-16 09:19:54.038 INFO 12868 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-09-16 09:19:54.085 INFO 12868 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-09-16 09:19:54.280 INFO 12868 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-09-16 09:19:54.962 INFO 12868 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#93824eb'
2018-09-16 09:19:54.965 INFO 12868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-09-16 09:19:55.623 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:55.918 INFO 12868 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3d299e3: startup date [Sun Sep 16 09:19:50 IST 2018]; root of context hierarchy
2018-09-16 09:19:55.974 WARN 12868 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : 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
2018-09-16 09:19:56.017 INFO 12868 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/posts]}" onto public java.lang.String com.H2DatabaseDemo.controller.H2DemoController.findAllPost(org.springframework.ui.Model)
2018-09-16 09:19:56.027 INFO 12868 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-16 09:19:56.028 INFO 12868 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-16 09:19:56.060 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:56.060 INFO 12868 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-16 09:19:56.366 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-09-16 09:19:56.370 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-09-16 09:19:56.378 INFO 12868 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-09-16 09:19:56.610 INFO 12868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-09-16 09:19:56.614 INFO 12868 --- [ main] c.H.H2DatabaseDemoApplication : Started H2DatabaseDemoApplication in 6.721 seconds (JVM running for 7.372)
2018-09-16 09:20:06.742 INFO 12868 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-09-16 09:20:06.742 INFO 12868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-09-16 09:20:06.884 INFO 12868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 142 ms
2018-09-16 09:20:07.138 INFO 12868 --- [nio-8080-exec-1] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
Over the controller method add RequestMapping("/")
Please add these dependencies in your pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

Intellij Springboot problems on startup

I am really new with spring boot, so I started with some tutorials to create a simple Rest example (my final goal is to integrate it with mongodb, but I need to start!).
I created a new project on IntelliJ with Spring Initializr and choosed Web and Mongodb as features.
Then I added only a class,
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HelloController {
#RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
When I run the project, the console is
2018-09-03 20:08:33.139 INFO 1363 --- [ main]
test.test.TestApplication : Starting TestApplication on
MacBook-Pro-di-Stefano.local with PID 1363
(/Users/stefanomiceli/IdeaProjects/test/target/classes started by
stefanomiceli in /Users/stefanomiceli/IdeaProjects/test)
2018-09-03 20:08:33.141 INFO 1363 --- [ main]
test.test.TestApplication : No active profile set,
falling back to default profiles: default
2018-09-03 20:08:33.173 INFO 1363 --- [ main]
ConfigServletWebServerApplicationContext : Refreshing
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#15713d56: startup date [Mon Sep 03 20:08:33 PDT 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.springframework.cglib.core.ReflectUtils$1
(file:/Users/stefanomiceli/.m2/repository/org/springframework/spring-
core/5.0.8.RELEASE/spring-core-5.0.8.RELEASE.jar) to method
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of
org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further
illegal reflective access operations
WARNING: All illegal access operations will be denied in a future
release
2018-09-03 20:08:33.950 INFO 1363 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with
port(s): 8080 (http)
2018-09-03 20:08:33.969 INFO 1363 --- [ main]
o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-09-03 20:08:33.969 INFO 1363 --- [ main]
org.apache.catalina.core.StandardEngine : Starting Servlet Engine:
Apache Tomcat/8.5.32
2018-09-03 20:08:33.972 INFO 1363 --- [ost-startStop-1]
o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat
Native library which allows optimal performance in production
environments was not found on the java.library.path:
[/Users/stefanomiceli/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-09-03 20:08:34.021 INFO 1363 --- [ost-startStop-1] o.a.c.c.C.
[Tomcat].[localhost].[/] : Initializing Spring embedded
WebApplicationContext
2018-09-03 20:08:34.021 INFO 1363 --- [ost-startStop-1]
o.s.web.context.ContextLoader : Root WebApplicationContext:
initialization completed in 852 ms
2018-09-03 20:08:34.059 INFO 1363 --- [ost-startStop-1]
o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet
mapped to [/]
2018-09-03 20:08:34.061 INFO 1363 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'characterEncodingFilter' to: [/*]
2018-09-03 20:08:34.062 INFO 1363 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'hiddenHttpMethodFilter' to: [/*]
2018-09-03 20:08:34.062 INFO 1363 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'httpPutFormContentFilter' to: [/*]
2018-09-03 20:08:34.062 INFO 1363 --- [ost-startStop-1]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
'requestContextFilter' to: [/*]
2018-09-03 20:08:34.143 INFO 1363 --- [ main]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path
[/**/favicon.ico] onto handler of type [class
org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 20:08:34.310 INFO 1363 --- [ main]
s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for
#ControllerAdvice:
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#15713d56: startup date [Mon Sep 03 20:08:33 PDT 2018]; root of context hierarchy
2018-09-03 20:08:34.344 INFO 1363 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-03 20:08:34.345 INFO 1363 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-03 20:08:34.362 INFO 1363 --- [ main]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path
[/webjars/**] onto handler of type [class
org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 20:08:34.362 INFO 1363 --- [ main]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto
handler of type [class
org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 20:08:34.550 INFO 1363 --- [ main]
org.mongodb.driver.cluster : Cluster created with
settings {hosts=[localhost:27017], mode=SINGLE,
requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms',
maxWaitQueueSize=500}
2018-09-03 20:08:34.582 INFO 1363 --- [localhost:27017]
org.mongodb.driver.connection : Opened connection
[connectionId{localValue:1, serverValue:55}] to localhost:27017
2018-09-03 20:08:34.585 INFO 1363 --- [localhost:27017]
org.mongodb.driver.cluster : Monitor thread successfully
connected to server with description
ServerDescription{address=localhost:27017, type=STANDALONE,
state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0,
1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216,
logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1582641}
2018-09-03 20:08:34.739 INFO 1363 --- [ main]
o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX
exposure on startup
2018-09-03 20:08:34.768 INFO 1363 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s):
8080 (http) with context path ''
2018-09-03 20:08:34.772 INFO 1363 --- [ main]
test.test.TestApplication : Started TestApplication in
1.834 seconds (JVM running for 7.413)
But when I go on localhost:8080/ I get 404 error. What did I do wrong in my helloworld? Is there anything that should I make before running the application?
You need to either
Fix the project structure in order to place the Application Entry Point (TestApplication in this case) in the base package (see image below).
Or use #ComponentScan like this (not recommended):
#SpringBootApplication
#ComponentScan("prova") // add the names of the packages where the controllers, services, repositories, etc, are going to be stored.
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
Your package structure is wrong:
prova.HelloController
test.test.TestApplication
The HelloController must be on the same level or below TestApplication.
You can do it 2 ways.
1.(preferable) Your controller package naming should be test.test.prova
i.e. Your springboot application should follow the package naming structure of Main class.
e.g. If your Main class has package name = com.test, so the controller package name should be com.test.controller
Another way is adding #ComponentScan to your Main class.
e.g.#SpringBootApplication
#ComponentScan("prova")

Spring Boot startup slow on Raspberry PI

Using Spring Boot 2 for an IoT application, I notice that the startup time for Spring is disproportionally slow. The platform is a Raspberry PI 2B - of course, this is going to be significantly slower than a PC. For normal code execution I measure a 20x to 50x difference.
Spring boot startup time on my PC (Win10 x64): 5 seconds
Spring boot startup time on the PI (Ubuntu Server, ARM java in docker running a jar): 11 minutes
If I use the highest factor I've ever measured (50x), I would expect to see a startup time of less than half of the current state. So far, I tried:
Excluding dependencies from auto configuration (now minimal with only only spring-boot-starter-web, kotlin, undertow, webflux, reactor and kafka)
Logging on DEBUG to see what was happening during quiet periods (mostly beans being set up, nothing suspicious, though some beans take several seconds to load)
Different docker image for Java on ARM (no effect)
CPU is consistently at 100%, memory is around 20% and there is plenty of disk space
My preliminary conclusion is that loading beans eats all the CPU cycles. I imagine that initializing a bean should not take several seconds, but it does. What could be the bottleneck here? Can I get Spring to load faster in any way?
Here is the first part of the output from a PC:
2018-01-06 13:43:03.462 INFO 9144 --- [ main] c.e.b.BasestationApplicationKt : Starting BasestationApplicationKt on GPC with PID 9144 (C:\Data\Code\app\git\basestation\out\production\classes started by User in C:\Data\Code\app\git)
2018-01-06 13:43:03.471 INFO 9144 --- [ main] c.e.b.BasestationApplicationKt : The following profiles are active: dev
2018-01-06 13:43:03.637 INFO 9144 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#294e5088: startup date [Sat Jan 06 13:43:03 CET 2018]; root of context hierarchy
2018-01-06 13:43:05.578 INFO 9144 --- [ main] org.xnio : XNIO version 3.3.8.Final
2018-01-06 13:43:05.600 INFO 9144 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.3.8.Final
2018-01-06 13:43:05.695 WARN 9144 --- [ main] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2018-01-06 13:43:05.695 WARN 9144 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2018-01-06 13:43:05.721 INFO 9144 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2018-01-06 13:43:05.722 INFO 9144 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2088 ms
2018-01-06 13:43:05.851 INFO 9144 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-06 13:43:05.857 INFO 9144 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-06 13:43:07.323 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public com.app.basestation.model.Message com.app.basestation.BasestationController.home()
2018-01-06 13:43:07.330 INFO 9144 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-06 13:43:07.349 INFO 9144 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-06 13:43:07.509 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#294e5088: startup date [Sat Jan 06 13:43:03 CET 2018]; root of context hierarchy
2018-01-06 13:43:08.519 INFO 9144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-01-06 13:43:08.553 INFO 9144 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-01-06 13:43:08.678 INFO 9144 --- [ main] o.s.b.w.e.u.UndertowServletWebServer : Undertow started on port(s) 11112 (http)
And the output from the PI:
2018-01-06 12:48:41.689 INFO 1 --- [ main] c.e.b.BasestationApplicationKt : Starting BasestationApplicationKt on ubuntu with PID 1 (/app.jar started by root in /)
2018-01-06 12:48:42.019 INFO 1 --- [ main] c.e.b.BasestationApplicationKt : The following profiles are active: prd
2018-01-06 12:48:49.827 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#128c152: startup date [Sat Jan 06 12:48:49 UTC 2018]; root of context hierarchy
2018-01-06 12:54:05.276 INFO 1 --- [ main] org.xnio : XNIO version 3.3.8.Final
2018-01-06 12:54:08.404 INFO 1 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.3.8.Final
2018-01-06 12:54:15.847 WARN 1 --- [ main] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2018-01-06 12:54:15.852 WARN 1 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2018-01-06 12:54:19.930 INFO 1 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2018-01-06 12:54:19.934 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 330155 ms
2018-01-06 12:54:42.544 INFO 1 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-06 12:54:43.206 INFO 1 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-06 12:57:18.683 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public com.app.basestation.model.Message com.app.basestation.BasestationController.home()
2018-01-06 12:57:19.734 INFO 1 --- [ 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.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-06 12:57:19.758 INFO 1 --- [ 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.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-06 12:57:44.597 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#128c152: startup date [Sat Jan 06 12:48:49 UTC 2018]; root of context hierarchy
2018-01-06 12:59:36.677 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-01-06 12:59:37.807 INFO 1 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-01-06 12:59:42.664 INFO 1 --- [ main] o.s.b.w.e.u.UndertowServletWebServer : Undertow started on port(s) 11112 (http)
Update:
For those reading this, I moved back to OpenJDK in 2019 due to the new Oracle policies. What I noticed is that OpenJDK has made significant performance improvements recently. If you use OpenJDK 11 and above, it has similar performance to Oracle JDK and you can easily configure its language level to work with Java 8 code. That said, if this does not work for you, try the below.
I moved to a new image: Oracle JDK instead of OpenJDK as #snodnipper suggested.
There were several things I had to do including installing a more recent version of Java 8 than the one available in the standard repository. This is the Dockerfile that ended up working for me, and now the application starts in 2 minutes.
FROM resin/raspberrypi3-buildpack-deps:jessie-scm
ENV LANG C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN ["cross-build-start"]
RUN echo "deb http://archive.raspberrypi.org/debian/ jessie main ui staging" > /etc/apt/sources.list.d/raspi.list
RUN rm -f /usr/bin/entry.sh
RUN wget -qO - http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add -
RUN { \
echo '#!/bin/bash'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home && \
chmod +x /usr/local/bin/docker-java-home
RUN apt-key adv --recv-key --keyserver keyserver.ubuntu.com C2518248EEA14886 && \
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" >> /etc/apt/sources.list.d/raspi.list
RUN set -x && \
apt-get update && \
apt-cache madison oracle-java8-installer && \
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
apt-get install -y oracle-java8-installer oracle-java8-set-default && \
rm -rf /var/lib/apt/lists/* && \
[ "$JAVA_HOME" = "$(docker-java-home)" ]
RUN [ "cross-build-end" ]
ADD build/libs/app-0.0.1-SNAPSHOT.jar /app.jar
ENV JAVA_OPTS=""
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar

Spring Boot not starting on Digital Ocean

I have a Droplet running Ubuntu with Java JDK 1.8 installed. I have transferred my spring boot fat jar. I can execute it no problems on my local machine. On Digital Ocean, it hangs as seen below indefinitely. I just upgraded the memory from 512MB to 1GB and same issue.
2016-09-02 22:02:13.010 INFO 2529 --- [ main] com.example.Application : Starting Application v1.0-SNAPSHOT on restfulProducts with PID 2529 (/home/aaron/restApp/springboot-1.0-SNAPSHOT.jar started by aaron in /home/aaron/restApp)
2016-09-02 22:02:13.022 INFO 2529 --- [ main] com.example.Application : No active profile set, falling back to default profiles: default
2016-09-02 22:02:13.250 INFO 2529 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#736e9adb: startup date [Fri Sep 02 22:02:13 UTC 2016]; root of context hierarchy
2016-09-02 22:02:16.880 INFO 2529 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$41018882] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-09-02 22:02:18.233 INFO 2529 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-09-02 22:02:18.280 INFO 2529 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-02 22:02:18.283 INFO 2529 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.4
2016-09-02 22:02:18.512 INFO 2529 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-09-02 22:02:18.512 INFO 2529 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5271 ms
2016-09-02 22:02:18.948 INFO 2529 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-02 22:02:18.957 INFO 2529 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-02 22:02:18.958 INFO 2529 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-02 22:02:18.958 INFO 2529 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-02 22:02:18.958 INFO 2529 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
Fateddy's suggestion did not work, however it identified the correct problem; low entropy. The https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged which uses haveged worked perfectly.

Spring Hibernate connecting to AWS RDS error

I am able to run my web application when I point to my local database:
Server version: 5.6.26 MySQL Community Server (GPL)
2015-10-10 13:37:20.598 INFO 2872 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProce
ssors (for example: not eligible for auto-proxying)
2015-10-10 13:37:20.657 INFO 2872 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAd
visor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-10 13:37:22.419 INFO 2872 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-10-10 13:37:23.022 INFO 2872 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-10-10 13:37:23.025 INFO 2872 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-10-10 13:37:23.320 INFO 2872 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-10-10 13:37:23.321 INFO 2872 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 11366 ms
2015-10-10 13:37:27.384 INFO 2872 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2015-10-10 13:37:28.649 INFO 2872 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegratio
nFilter#28ba6f1f, org.springframework.security.web.context.SecurityContextPersistenceFilter#4d9d07dd, org.springframework.security.web.header.HeaderWriterFilter#6ea013e0, org.springframework.security.web.csrf.CsrfFilter#695c931a, org.springframework.security.web.authenti
cation.logout.LogoutFilter#2243a064, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#288989d8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#2b027994, org.springframework.security.web.servletapi.SecurityContext
HolderAwareRequestFilter#69764da4, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#4c99f499, org.springframework.security.web.session.SessionManagementFilter#484a49a7, org.springframework.security.web.access.ExceptionTranslationFilter#46e34c
8f, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#f2c41d9]
2015-10-10 13:37:29.010 INFO 2872 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-10-10 13:37:29.039 INFO 2872 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-10-10 13:37:29.041 INFO 2872 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-10-10 13:37:29.041 INFO 2872 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2015-10-10 13:37:30.042 INFO 2872 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-10-10 13:37:30.117 INFO 2872 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-10-10 13:37:30.384 INFO 2872 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.10.Final}
2015-10-10 13:37:30.404 INFO 2872 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-10-10 13:37:30.408 INFO 2872 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-10-10 13:37:31.228 INFO 2872 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-10-10 13:37:31.426 INFO 2872 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2015-10-10 13:37:31.949 INFO 2872 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
I am able to access my 2 AWS RDS databases from my desktop using Hedidi. The databases have different versions:
MySQL 5.6.23
MySQL 5.1.73a
But when I point to my database and run again I get the follow exception:
2015-10-10 13:42:40.605 INFO 512 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-10-10 13:42:41.142 INFO 512 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-10-10 13:42:41.146 INFO 512 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-10-10 13:42:41.656 INFO 512 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-10-10 13:42:41.657 INFO 512 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 10478 ms
2015-10-10 13:42:46.992 INFO 512 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: com.mysql.jdbc.Driver
2015-10-10 13:42:48.872 INFO 512 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegration
Filter#390fc764, org.springframework.security.web.context.SecurityContextPersistenceFilter#69bdf685, org.springframework.security.web.header.HeaderWriterFilter#71a70302, org.springframework.security.web.csrf.CsrfFilter#754e07d4, org.springframework.security.web.authentic
ation.logout.LogoutFilter#2eac817e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#46dea8a1, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#4c69ba89, org.springframework.security.web.servletapi.SecurityContextH
olderAwareRequestFilter#36ac2a3f, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#aa7fb44, org.springframework.security.web.session.SessionManagementFilter#ac2d960, org.springframework.security.web.access.ExceptionTranslationFilter#54bfdd50,
org.springframework.security.web.access.intercept.FilterSecurityInterceptor#1c99fb02]
2015-10-10 13:42:49.358 INFO 512 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-10-10 13:42:49.398 INFO 512 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-10-10 13:42:49.399 INFO 512 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-10-10 13:42:49.399 INFO 512 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2015-10-10 13:42:50.449 INFO 512 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-10-10 13:42:50.546 INFO 512 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-10-10 13:42:50.913 INFO 512 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.10.Final}
2015-10-10 13:42:50.941 INFO 512 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-10-10 13:42:50.945 INFO 512 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-10-10 13:42:51.855 INFO 512 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-10-10 13:42:52.080 WARN 512 --- [ main] o.h.e.jdbc.internal.JdbcServicesImpl : HHH000342: Could not obtain connection to query metadata : Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2015-10-10 13:42:52.095 WARN 512 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exc
eption is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at configuration.Application.main(Application.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:205)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 21 common frames omitted
Here is the only thing I change:
#database.driverManagerDataSource.setDriverClassName=com.mysql.jdbc.Driver
#database.driverManagerDataSource.setUrl=jdbc:mysql://localhost:3306/question_time_server
#database.driverManagerDataSource.setUsername=root
#database.driverManagerDataSource.setPassword=
database.driverManagerDataSource.setDriverClassName=com.mysql.jdbc.Driver
database.driverManagerDataSource.setUrl=jdbc:mysql://csrwot1tk8jt.eu-west-1.rds.amazonaws.com:3306/mobilequestionnaire
database.driverManagerDataSource.setUsername=????
database.driverManagerDataSource.setPassword=????
Here is my gradle file:
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
classpath 'com.bmuschko:gradle-cargo-plugin:2.1.1'
classpath 'mysql:mysql-connector-java:5.1.16'
classpath 'org.springframework:springloaded:1.2.0.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'com.bmuschko.cargo'
jar {
baseName = 'MobileQuestionnaire'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework:spring-jdbc:4.1.0.RELEASE")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("mysql:mysql-connector-java:5.1.+")
compile("org.webjars:bootstrap:3.0.3")
compile("org.webjars:jquery:2.0.3-1")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.7.RELEASE")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
I thought it would be a simple matter of just pointing from my local to AWS RDS. But it's not...
Any ideas?
I think you are missing the dbinstance before the hash number:
jdbc:mysql://<dbinstance>.csrwot1tk8jt.eu-west-1.rds.amazonaws.com:3306/mobilequestionnaire
I connect to RDS like this (using java config):
// dataSource.setUrl("jdbc:mysql://something.cfscmuq3e7df.us-west-2.rds.amazonaws.com:3306/database");
Also, please check that the elastic beanstalk is configured with the amazon RDS. I no issues building and deploying locally, with my application pointing to the AWS RDS, but once I tried to deploy on the aws elastic beanstalk, i had this issue.
Please look here for a description of how to do it:
Adding an Amazon RDS Database to Your Elastic Beanstalk Environment

Resources