spring-boot hangs a while during start - spring-boot

One of our spring-boot applications using camel hangs on start for anywhere between 1 to 5 minutes, but not consistently.
The production environment the application runs in is the raspberry pi, running openJDK. We are unable to reproduce the issue on development machines.
Even on the pis however, the issue is exceedingly rare and seems to happen only on some. In fact we currently only have one in the field where this is a consistent problem, but there it's somewhat of a critical issue due to it being solar powered. The problem has been observed once before on another Pi, where it wasn't critical, and not 100% consistent, and went away again after a while.
Unfortunately we cannot test the pi for hardware issues. Travelling costs would be significant, so before we have no other option left we cannot afford to go and replace it with the possibility that not even that will fix the issue. Also, the pis syslog shows no suspicious activity at all during and around the time the hang happens.
This just to explain why I am posting the question even though a hardware issue cannot be 100% excluded at the moment. We simply need to exclude everything else first.
Now for the actual question: Here is a complete trace (log.level.root = TRACE) of the application at the time the hang occurs. I can provide a complete trace of the startup, but didn't think spamming thousands of lines of logs would help much.I am mostly interested in whether you see anything suspicious. I have looked at these entries for some time and cannot see any hint to the cause of the hang, but my experience with the inner life of spring-boot is very limited.
2019-10-30 08:28:16.090 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Eagerly caching bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor' to allow for resolving potential circular references
2019-10-30 08:28:16.091 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Getting BeanInfo for class [org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor]
2019-10-30 08:28:16.106 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Caching PropertyDescriptors for class [org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor]
2019-10-30 08:28:16.107 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'applicationContext' of type [org.springframework.context.ApplicationContext]
2019-10-30 08:28:16.107 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
2019-10-30 08:28:16.107 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'beanName' of type [java.lang.String]
2019-10-30 08:28:16.107 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'class' of type [java.lang.Class]
2019-10-30 08:28:16.108 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'embeddedValueResolver' of type [org.springframework.util.StringValueResolver]
2019-10-30 08:28:16.109 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'order' of type [int]
2019-10-30 08:28:16.109 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'scheduledTasks' of type [java.util.Set]
2019-10-30 08:28:16.109 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'scheduler' of type [java.lang.Object]
2019-10-30 08:28:16.185 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Finished creating instance of bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor'
2019-10-30 08:28:16.186 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'persistenceExceptionTranslationPostProcessor'
2019-10-30 08:28:16.186 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Creating instance of bean 'persistenceExceptionTranslationPostProcessor'
2019-10-30 08:28:16.370 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'environment'
2019-10-30 08:28:16.375 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'persistenceExceptionTranslationPostProcessor' via factory method to bean named 'environment'
2019-10-30 08:28:16.379 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'configurationProperties'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'commandLineArgs'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'systemProperties'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'systemEnvironment'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'random'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'applicationConfig: [file:./application.properties]'
2019-10-30 08:28:16.381 TRACE 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.aop.proxy-target-class' in PropertySource 'applicationConfig: [classpath:/application.properties]'
2019-10-30 08:28:16.381 DEBUG 456 --- [main] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.aop.proxy-target-class' in any property source
2019-10-30 08:28:16.398 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Eagerly caching bean 'persistenceExceptionTranslationPostProcessor' to allow for resolving potential circular references
2019-10-30 08:28:16.399 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Getting BeanInfo for class [org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor]
2019-10-30 08:28:16.437 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Caching PropertyDescriptors for class [org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor]
2019-10-30 08:28:16.437 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'beanClassLoader' of type [java.lang.ClassLoader]
2019-10-30 08:28:16.437 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
2019-10-30 08:28:16.437 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'beforeExistingAdvisors' of type [boolean]
2019-10-30 08:28:16.438 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'class' of type [java.lang.Class]
2019-10-30 08:28:16.438 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'exposeProxy' of type [boolean]
2019-10-30 08:28:16.439 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'frozen' of type [boolean]
2019-10-30 08:28:16.440 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'opaque' of type [boolean]
2019-10-30 08:28:16.440 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'optimize' of type [boolean]
2019-10-30 08:28:16.441 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'order' of type [int]
2019-10-30 08:28:16.441 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'proxyClassLoader' of type [java.lang.ClassLoader]
2019-10-30 08:28:16.441 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'proxyTargetClass' of type [boolean]
2019-10-30 08:28:16.442 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'repositoryAnnotationType' of type [java.lang.Class]
2019-10-30 08:28:16.507 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Finished creating instance of bean 'persistenceExceptionTranslationPostProcessor'
2019-10-30 08:28:16.507 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'dataSourceInitializerPostProcessor'
2019-10-30 08:28:16.507 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Creating instance of bean 'dataSourceInitializerPostProcessor'
2019-10-30 08:28:16.522 DEBUG 456 --- [main] o.s.b.f.annotation.InjectionMetadata : Registered injected element on class [org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor]: AutowiredFieldElement for private org.springframework.beans.factory.BeanFactory org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.beanFactory
2019-10-30 08:28:16.522 DEBUG 456 --- [main] o.s.b.f.s.DefaultListableBeanFactory : Eagerly caching bean 'dataSourceInitializerPostProcessor' to allow for resolving potential circular references
2019-10-30 08:28:16.522 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Getting BeanInfo for class [org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor]
2019-10-30 08:28:16.532 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Caching PropertyDescriptors for class [org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor]
2019-10-30 08:28:16.533 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'class' of type [java.lang.Class]
2019-10-30 08:28:16.533 TRACE 456 --- [main] o.s.beans.CachedIntrospectionResults : Found bean property 'order' of type [int]
// Note the significant time jump!
2019-10-30 08:30:16.087 TRACE 454 --- [main] org.apache.sshd.client.SshClient : addSessionListener(SshClient[f66866])[org.apache.sshd.common.session.helpers.SessionTimeoutListener#b50150] registered
2019-10-30 08:30:16.088 TRACE 454 --- [main] .a.s.c.u.t.ThreadUtils$SshdThreadFactory : newThread(java.lang.ThreadGroup[name=main,maxpri=10])[sshd-SshClient[f66866]-timer-thread-1] runnable=java.util.concurrent.ThreadPoolExecutor$Worker#1b986cd[State = -1, empty queue]
2019-10-30 08:30:16.161 TRACE 454 --- [main] o.a.sshd.common.io.nio2.Nio2Connector : Creating Nio2Connector
2019-10-30 08:30:16.162 DEBUG 454 --- [main] o.a.camel.component.ssh.SshProducer : Starting producer: Producer[ssh://root:xxxxxx#192.168.1.1]
2019-10-30 08:30:16.162 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.162 DEBUG 454 --- [main] o.a.camel.component.exec.ExecProducer : Starting producer: Producer[exec://sudo]
2019-10-30 08:30:16.162 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.162 DEBUG 454 --- [main] o.a.camel.component.exec.ExecProducer : Starting producer: Producer[exec://sudo]
2019-10-30 08:30:16.162 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.162 DEBUG 454 --- [main] o.a.c.c.direct.DirectBlockingProducer : Starting producer: Producer[direct://switch-off-camera]
2019-10-30 08:30:16.162 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.163 DEBUG 454 --- [main] o.a.camel.component.seda.SedaProducer : Starting producer: Producer[seda://capture-image]
2019-10-30 08:30:16.163 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.163 DEBUG 454 --- [main] o.a.c.c.direct.DirectBlockingProducer : Starting producer: Producer[direct://switch-off-camera]
2019-10-30 08:30:16.163 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.163 DEBUG 454 --- [main] o.a.camel.component.seda.SedaProducer : Starting producer: Producer[seda://image-queue]
2019-10-30 08:30:16.163 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.163 DEBUG 454 --- [main] o.a.c.c.direct.DirectBlockingProducer : Starting producer: Producer[direct://failed-upload]
2019-10-30 08:30:16.163 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.163 DEBUG 454 --- [main] o.a.c.c.direct.DirectBlockingProducer : Starting producer: Producer[direct://switch-off-camera]
2019-10-30 08:30:16.163 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.164 TRACE 454 --- [main] org.apache.camel.support.ServiceSupport : Starting service
2019-10-30 08:30:16.164 DEBUG 454 --- [main] o.a.camel.component.seda.SedaProducer : Starting producer: Producer[seda://capture-command]
2019-10-30 08:30:16.164 DEBUG 454 --- [main] o.a.camel.spring.SpringCamelContext : Route: route1 >>> EventDrivenConsumerRoute[seda://start-deepsleep -> Pipeline[[Channel[Log(route1)[Starting deep sleep for ${body} seconds]], Channel[SetBody(Simple: sh -c '(sleep 15; io set out0 1; sleep 2; lpm -i ${body})' </dev/null >/dev/null 2>&1 &)], Channel[Log(route1)[Executing SSH command: ${body}]], C
2019-10-30 08:30:16.165 DEBUG 454 --- [main] o.a.camel.spring.SpringCamelContext : Starting consumer (order: 1000) on route: route1
2019-10-30 08:30:16.165 TRACE 454 --- [main] a.c.m.DefaultManagementLifecycleStrategy : Checking whether to register SedaConsumer[seda://start-deepsleep] from route: EventDrivenConsumerRoute[seda://start-deepsleep -> Pipeline[[Channel[Log(route1)[Starting deep sleep for ${body} seconds]], Channel[SetBody(Simple: sh -c '(sleep 15; io set out0 1; sleep 2; lpm -i ${body})' </dev/null >/dev/null 2>&1
2019-10-30 08:30:16.166 DEBUG 454 --- [main] javax.management.mbeanserver : name = org.apache.camel:context=camel-1,type=consumers,name=SedaConsumer(0x1f22f18)
2019-10-30 08:30:16.167 DEBUG 454 --- [main] javax.management.mbeanserver : name = org.apache.camel:context=camel-1,type=consumers,name=SedaConsumer(0x1f22f18)
2019-10-30 08:30:16.167 TRACE 454 --- [main] o.a.c.management.DefaultManagementAgent : Registering MBean with ObjectName: org.apache.camel:context=camel-1,type=consumers,name=SedaConsumer(0x1f22f18)
2019-10-30 08:30:16.168 TRACE 454 --- [main] o.a.c.m.DefaultManagementMBeanAssembler : Assembling MBeanInfo for: org.apache.camel:context=camel-1,type=consumers,name=SedaConsumer(0x1f22f18) from #ManagedResource object: org.apache.camel.management.mbean.ManagedConsumer#8572f0
2019-10-30 08:30:16.168 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from class: class org.apache.camel.management.mbean.ManagedConsumer
2019-10-30 08:30:16.174 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public java.lang.Integer org.apache.camel.management.mbean.ManagedConsumer.getInflightExchanges()
2019-10-30 08:30:16.175 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public org.apache.camel.Consumer org.apache.camel.management.mbean.ManagedConsumer.getConsumer()
2019-10-30 08:30:16.175 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public java.lang.String org.apache.camel.management.mbean.ManagedConsumer.getEndpointUri()
2019-10-30 08:30:16.175 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from sub class: class org.apache.camel.management.mbean.ManagedService
2019-10-30 08:30:16.176 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from class: class org.apache.camel.management.mbean.ManagedService
2019-10-30 08:30:16.180 TRACE 454 --- [ForkJoinPool.commonPool-worker-2] org.apache.camel.util.LRUCache : onRemoval class org.apache.camel.management.mbean.ManagedService -> null
2019-10-30 08:30:16.180 TRACE 454 --- [ForkJoinPool.commonPool-worker-3] org.apache.camel.util.LRUCache : onRemoval interface org.apache.camel.api.management.mbean.ManagedServiceMBean -> null
2019-10-30 08:30:16.180 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public java.lang.String org.apache.camel.management.mbean.ManagedService.getServiceType()
2019-10-30 08:30:16.180 TRACE 454 --- [ForkJoinPool.commonPool-worker-2] org.apache.camel.util.LRUCache : onRemoval class org.apache.camel.management.mbean.ManagedProducer -> null
2019-10-30 08:30:16.181 TRACE 454 --- [ForkJoinPool.commonPool-worker-3] org.apache.camel.util.LRUCache : onRemoval interface org.apache.camel.api.management.mbean.ManagedProducerMBean -> null
2019-10-30 08:30:16.181 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public boolean org.apache.camel.management.mbean.ManagedService.isSupportSuspension()
2019-10-30 08:30:16.182 TRACE 454 --- [ForkJoinPool.commonPool-worker-3] org.apache.camel.util.LRUCache : onRemoval interface org.apache.camel.api.management.ManagedInstance -> null
2019-10-30 08:30:16.182 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public boolean org.apache.camel.management.mbean.ManagedService.isStaticService()
2019-10-30 08:30:16.182 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public void org.apache.camel.management.mbean.ManagedService.setRoute(org.apache.camel.Route)
2019-10-30 08:30:16.182 TRACE 454 --- [main] o.a.camel.management.MBeanInfoAssembler : Extracting attributes and operations from method: public java.lang.String org.apache.camel.management.mbean.ManagedService.getCamelManagementName()
I've marked the gap in time where nothing appears to be happening. Now, there are a few entries in there that I've taken out. The quartz job-store is doing its thing with the h2 database, and a scheduled task by one of our services is already already running. No suspicious things, and we managed to exclude them entirely in some test runs, but it shows that the system as a whole isn't stalled. Spring-boot just seems to be waiting for something before continuing.
I was hoping that somebody more at home with spring-boot might tell me what spring-boot is waiting for in that time based on these logs.
We have also excluded the possibility of wrong logging times (i.e. that the hang isn't actually there, instead the clock jumps), especially since this is a pi.
It may or may not be noteworthy that the hang occurs between camel instantiating the endpoints and camel starting the routes. Usually these are only a second appart, but I'd expect to see some sings of trouble in the log if there would be a hang-up with that.

The problem is that the Pi you are deploying to does not have enough "noise" for the random number generator to start properly. Oracle has a solution for this issue: https://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmrand.html

Related

Unable to fetch the view file

On making a GET Request which returns a ModelAndView Object I am getting the following error
: GET "/tweet2?email=tim#gmail.com", parameters={masked} 2022-03-08
11:04:45.459 DEBUG 46576 --- [nio-8080-exec-3]
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to
com.example.demo.RestAPIExample#getTweetsByEmail(String) 2022-03-08
11:04:45.464 DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.s.v.ContentNegotiatingViewResolver : Selected '/' given [/]
2022-03-08 11:04:45.464 DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.servlet.view.InternalResourceView : View name 'tweets', model
{tweets=[com.example.demo.Tweet#3a7a85cb]} 2022-03-08 11:04:45.465
DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.servlet.view.InternalResourceView : Forwarding to [tweets]
2022-03-08 11:04:45.467 DEBUG 46576 --- [nio-8080-exec-3]
o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET
"/tweets?email=tim#gmail.com", parameters={masked} 2022-03-08
11:04:45.470 DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to
ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath
[resources/], classpath [static/], classpath [public/], ServletContext
[/]] 2022-03-08 11:04:45.472 DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2022-03-08 11:04:45.473 DEBUG 46576 --- [nio-8080-exec-3]
o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD"
dispatch, status 404 2022-03-08 11:04:45.473 DEBUG 46576 ---
[nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Completed
404 NOT_FOUND 2022-03-08 11:04:45.474 DEBUG 46576 ---
[nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : "ERROR"
dispatch for GET "/error?email=tim#gmail.com", parameters={masked}
2022-03-08 11:04:45.475 DEBUG 46576 --- [nio-8080-exec-3]
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to
org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
2022-03-08 11:04:45.482 DEBUG 46576 --- [nio-8080-exec-3]
o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json',
given [/] and supported [application/json, application/+json,
application/json, application/+json] 2022-03-08 11:04:45.483 DEBUG
46576 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor :
Writing [{timestamp=Tue Mar 08 11:04:45 IST 2022, status=404,
error=Not Found, path=/tweet2}] 2022-03-08 11:04:45.497 DEBUG 46576
--- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
Here is the code I wrote:
#GetMapping("/tweet2")
public ModelAndView getTweetsByEmail(#RequestParam String email) {
ModelAndView modelAndView = new ModelAndView("tweets");
List<Tweet> tweets = tweetMap.get(email);
modelAndView.getModel().put("tweets",tweets);
return modelAndView;
}
And there is a tweets.mustache file under the resources folder. Not sure why its unable to detect it

spring initialization hangs for few min

When starting Spring it will get hang for like 5 min
If you look at the log WebApplicationContext: initialization happens in 16:36
the next message is Initialized JPA EntityManagerFactory happens in 16:41 almost 5 min later
What could be the issue?
Thank you!
2019-05-09 16:36:59.619 INFO 18120 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 10419 ms
2019-05-09 16:41:18.196 INFO 18120 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'portal'
2019-05-09 16:41:18.362 INFO 18120 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-05-09 16:41:26.759 INFO 18120 --- [ restartedMain] s.s.l.DefaultSpringSecurityContextSource : URL 'ldap://ldap01:389', root DN is ''
2019-05-09 16:41:26.863 INFO 18120 --- [ restartedMain] .s.s.l.u.DefaultLdapAuthoritiesPopulator : groupSearchBase is empty. Searches will be performed from the context source base
2019-05-09 16:41:27.128 DEBUG 18120 --- [ restartedMain] com.xerox.printerfarm.config.SecurityConfig : secureEndPoints => /printers/**,/employees/user/**
2019-05-09 16:41:27.984 INFO 18120 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6935ce05, org.springframework.security.web.context.SecurityContextPersistenceFilter#5c58f813, org.springframework.security.web.header.HeaderWriterFilter#54fe23e9, org.springframework.security.web.authentication.logout.LogoutFilter#1f81a1d8, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#43759aa7, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#40017880, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#60c590e1, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#64a8529a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4cd90a9, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#6dd6807b, org.springframework.security.web.session.SessionManagementFilter#b218290, org.springframework.security.web.access.ExceptionTranslationFilter#b52b511, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#6d4bb1]
2019-05-09 16:41:28.354 INFO 18120 --- [ restartedMai
UPDATE
with some debug code from logger.org.springframework set to debug
2019-05-14 11:45:16.891 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'entityManagerFactory' via factory method to bean named 'entityManagerFactoryBuilder'
2019-05-14 11:45:16.891 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'entityManagerFactory' via factory method to bean named 'dataSource'
2019-05-14 11:45:16.995 DEBUG 22824 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'portal'
2019-05-14 11:45:18.665 DEBUG 22824 --- [ restartedMain] o.s.j.d.DriverManagerDataSource : Creating new JDBC DriverManager Connection to [jdbc:oracle:thin:#devserv1:1521/DEV01SID]
2019-05-14 11:45:24.169 DEBUG 22824 --- [ restartedMain] o.s.j.d.DriverManagerDataSource : Creating new JDBC DriverManager Connection to [jdbc:oracle:thin:#devserv1:1521/DEV01SID]
2019-05-14 11:45:24.703 DEBUG 22824 --- [ restartedMain] o.s.j.d.DriverManagerDataSource : Creating new JDBC DriverManager Connection to [jdbc:oracle:thin:#devserv1:1521/DEV01SID]
2019-05-14 11:46:14.229 DEBUG 22824 --- [alina-utility-2] org.apache.catalina.session.ManagerBase : Start expire sessions StandardManager at 1557848774228 sessioncount 0
2019-05-14 11:46:14.229 DEBUG 22824 --- [alina-utility-2] org.apache.catalina.session.ManagerBase : End expire sessions StandardManager processingTime 1 expired sessions: 0
---- 1 min here
2019-05-14 11:47:14.240 DEBUG 22824 --- [alina-utility-1] org.apache.catalina.session.ManagerBase : Start expire sessions StandardManager at 1557848834240 sessioncount 0
2019-05-14 11:47:14.240 DEBUG 22824 --- [alina-utility-1] org.apache.catalina.session.ManagerBase : End expire sessions StandardManager processingTime 0 expired sessions: 0
---- 1 min here
2019-05-14 11:48:14.246 DEBUG 22824 --- [alina-utility-1] org.apache.catalina.session.ManagerBase : Start expire sessions StandardManager at 1557848894246 sessioncount 0
2019-05-14 11:48:14.246 DEBUG 22824 --- [alina-utility-1] org.apache.catalina.session.ManagerBase : End expire sessions StandardManager processingTime 0 expired sessions: 0
---- 1 min here
2019-05-14 11:49:13.998 INFO 22824 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'portal'
2019-05-14 11:49:14.009 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'delegatingApplicationListener'
2019-05-14 11:49:14.018 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'liveReloadServerEventListener'
2019-05-14 11:49:14.019 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration$LiveReloadConfiguration'
2019-05-14 11:49:14.031 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'optionalLiveReloadServer'
2019-05-14 11:49:14.035 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'spring.devtools-org.springframework.boot.devtools.autoconfigure.DevToolsProperties'
2019-05-14 11:49:14.043 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'liveReloadServer' via factory method to bean named 'spring.devtools-org.springframework.boot.devtools.autoconfigure.DevToolsProperties'
2019-05-14 11:49:14.071 DEBUG 22824 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'optionalLiveReloadServer' via factory method to bean named 'liveReloadServer'
2019-05-14 11:49:14.083 DEBUG 22824 --- [ restartedMain] o.s.b.d.livereload.LiveReloadServer : Starting live reload server on port 35729

Spring Boot 2.1 MVC Logging

Upgrading Spring Boot 2.1.x from 2.0.x, not logging MVC mapping logs..
Spring Boot 2.0.x logs MVC Mapping at INFO level, it was very convinient and easily identifiable logs.
**Spring Boot 2.0.x**
2019-01-24 20:10:11.165 INFO [ main] s.w.s.m.m.a.RequestMappingHandlerMapping Mapped "{[/mapping2],methods=[GET]}" onto public java.lang.String com.test.controller.ControllerClass.method2()
2019-01-24 20:10:11.167 INFO [ main] s.w.s.m.m.a.RequestMappingHandlerMapping Mapped "{[/mapping1],methods=[GET]}" onto public java.lang.String com.test.controller.ControllerClass.method1()
As per Spring Boot 2.1.x documentation,
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#logging-refinements
There are no Info logs for MVC Mapping. Only summary logged as debug log.
We have to update level to TRACE to get more details.
**Spring Boot 2.0.x**
2019-01-24 20:16:08.549 TRACE 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
c.t.c.ControllerClass:
{GET /mapping1}: method1()
{GET /mapping2}: method2()
2019-01-24 20:16:08.554 TRACE 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
o.s.b.a.w.s.e.BasicErrorController:
{ /error}: error(HttpServletRequest)
{ /error, produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse)
2019-01-24 20:16:08.560 DEBUG 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : 4 mappings in 'requestMappingHandlerMapping'
2019-01-24 20:16:08.584 DEBUG 2516 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Detected 0 mappings in 'beanNameHandlerMapping'
By updating web log level to DEBUG or TRACE, We get more debug logs from Spring Web and they are not useful always. Unless, TRACE level, they are not much meaningful.
2019-01-24 20:39:59.767 TRACE 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : GET "/mapping1", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2019-01-24 20:39:59.768 TRACE 2516 --- [nio-8080-exec-5] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public java.lang.String com.test.controller.ControllerClass.method1()
2019-01-24 20:39:59.769 TRACE 2516 --- [nio-8080-exec-5] .w.s.m.m.a.ServletInvocableHandlerMethod : Arguments: []
2019-01-24 20:39:59.771 DEBUG 2516 --- [nio-8080-exec-5] m.m.a.RequestResponseBodyMethodProcessor : Using 'text/html', given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] and supported [text/plain, */*, text/plain, */*, application/json, application/*+json, application/json, application/*+json]
2019-01-24 20:39:59.771 TRACE 2516 --- [nio-8080-exec-5] m.m.a.RequestResponseBodyMethodProcessor : Writing ["Method1"]
2019-01-24 20:39:59.776 TRACE 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned.
2019-01-24 20:39:59.777 DEBUG 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Completed 200 OK, headers={masked}
Is it possible to get Spring log information ? and How ?
From Spring Boot 2.1 version to get RequestMappingHandlerMapping log on console try add
logging.level.org.springframework.web=trace
on application.properties file
It worked for me

Spring Boot : Having a custom annotation on spring rest controller class causing error in identifying handler mapping

I am using a custom annotation called #Toggle on top of a rest controller class in spring boot to intercept the handlerType to block rest calls.
See below code snippet:
#RestController
#Toggle(feature="feature.foo")
#RequestMapping("/foo")
public class FooController {
#RequestMapping("")
public Map hello() {
return Collections.singletonMap("message", "hello foo!");
}
}
But I am not able to access the api which fails even before dispatcher servlet find the handler method.
2018-02-17 18:51:31.520 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/foo]
2018-02-17 18:51:31.521 DEBUG 73947 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /foo
2018-02-17 18:51:31.523 DEBUG 73947 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/foo]
2018-02-17 18:51:31.523 DEBUG 73947 --- [nio-8080-exec-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/foo] are [/**]
2018-02-17 18:51:31.523 DEBUG 73947 --- [nio-8080-exec-2] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/foo] are {}
2018-02-17 18:51:31.524 DEBUG 73947 --- [nio-8080-exec-2] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/foo] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#333c8791]]] and 1 interceptor
2018-02-17 18:51:31.524 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/foo] is: -1
2018-02-17 18:51:31.525 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2018-02-17 18:51:31.525 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Successfully completed request
2018-02-17 18:51:31.529 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2018-02-17 18:51:31.529 DEBUG 73947 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2018-02-17 18:51:31.529 DEBUG 73947 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [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-02-17 18:51:31.530 DEBUG 73947 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
Found below logs which can throw some more light on the problem.
2018-02-17 20:30:24.172 DEBUG 94537 --- [ main] .i.s.PathMatchingResourcePatternResolver : Resolved location pattern [classpath*:in/karthick/spring/**/*.class] to resources [file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/AppConfig.class], file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/Constants.class], file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/FeatureToggleApplication.class], file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/web/FooController.class], file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/web/HelloController.class]]
2018-02-17 20:30:24.172 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Scanning file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/AppConfig.class]
2018-02-17 20:30:24.190 DEBUG 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Identified candidate component class: file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/AppConfig.class]
2018-02-17 20:30:24.191 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Scanning file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/Constants.class]
2018-02-17 20:30:24.191 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Ignored because not matching any filter: file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/Constants.class]
2018-02-17 20:30:24.191 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Scanning file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/FeatureToggleApplication.class]
2018-02-17 20:30:24.196 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Ignored because not matching any filter: file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/FeatureToggleApplication.class]
2018-02-17 20:30:24.196 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Scanning file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/web/FooController.class]
2018-02-17 20:30:24.205 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [servletConfigInitParams]
2018-02-17 20:30:24.205 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [servletContextInitParams]
2018-02-17 20:30:24.205 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [systemProperties]
2018-02-17 20:30:24.206 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [systemEnvironment]
2018-02-17 20:30:24.206 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [random]
2018-02-17 20:30:24.206 TRACE 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'feature.foo' in [applicationConfigurationProperties]
2018-02-17 20:30:24.206 DEBUG 94537 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'feature.foo' in any property source
2018-02-17 20:30:24.210 TRACE 94537 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Ignored because not matching any filter: file [/Users/karthick/feature-toggles/target/classes/in/karthick/spring/web/FooController.class]
However, if I use the same #Toggle annotation on a method inside rest controller class, the handler mapping finds the right method to invoke.
#RequestMapping("/foo")
#Toggle(feature = "feature.foo")
public Map hello() {
return Collections.singletonMap("message", "hello foo!");
}
How can I make sure spring boot maps to right handler method even if I use custom annotation on top of rest controller.

spring boot tempory h2 database table empty in junit4 test

I am using Spring Boot 1.2.5 and want to do some JUnit4 testing. I have an Eclipse project that contains the test. During initializiation a temporay H2 database is created. I have a schema.xml and data.xml. The initialization is fine, but later three of 5 tables are empty.
First I had the database created by Spring boot. No code from my side, just the XML in the resources folder. This runs without any problems. Then I found that in the test three of the five tables are empty. The schema still exists, but not data.
I then changed to manual creation of the H2 database/datasource bean and in the same method I checked if all records are present. This made no difference in the test results. I could only show that just after creation the database is populated as expected. It seems that during bean creation and JUnit test some routine is doing a delete on three specific tables.
package de.unit4.financials;
import javax.sql.DataSource;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.test.jdbc.JdbcTestUtils;
#SpringBootApplication
public class JUnitConfig {
Logger logger = LogManager.getLogger();
#Bean
public DataSource getDataSource() {
DataSource dataSource = null;
if (dataSource == null) {
dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).setName("FanUtilDB")
.addScript("classpath:schema.sql").addScript("classpath:data.sql").build();
}
logger.info("Datasource "+dataSource);
testDB(new JdbcTemplate(dataSource));
return dataSource;
}
public void testDB(JdbcTemplate jdbcTemplate) {
countTableRows("oas_company", jdbcTemplate);
countTableRows("oas_agm", jdbcTemplate);
countTableRows("oas_agmlist", jdbcTemplate);
countTableRows("com_usr", jdbcTemplate);
countTableRows("com_capab", jdbcTemplate);
}
private void countTableRows(String name, JdbcTemplate jdbcTemplate) {
int anzahl = JdbcTestUtils.countRowsInTable(jdbcTemplate, name);
logger.info(name + " = " + anzahl);
}
}
This is the output:
08:58:16.007 [main] INFO Datasource org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#60094a13 || de.unit4.financials.JUnitConfig getDataSource 54
08:58:16.197 [main] INFO oas_company = 28 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.199 [main] INFO oas_agm = 2 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.201 [main] INFO oas_agmlist = 2 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.203 [main] INFO com_usr = 52 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.205 [main] INFO com_capab = 17 || de.unit4.financials.JUnitConfig countTableRows 74
Later the JUnit test is run and it gives me this result:
08:58:19.099 [main] INFO Datasource org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#60094a13 || de.unit4.financials.periods.CurrentPeriodDBFactory getCurrentPeriod 63
08:58:19.127 [main] INFO oas_company = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.128 [main] INFO oas_agm = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.128 [main] INFO oas_agmlist = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.129 [main] INFO com_usr = 52 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.130 [main] INFO com_capab = 17 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
The DataSource object seems to be the same, but the record count is different. During the test, the first three are empty.
Here is the test:
package de.unit4.financials;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.jdbc.JdbcTestUtils;
#RunWith(SpringJUnit4ClassRunner.class)
#SpringApplicationConfiguration(classes = JUnitConfig.class)
public class FinancialsUtilApplicationTests {
static Logger logger = LogManager.getLogger();
#Autowired
JdbcTemplate jdbcTemplate;
#Test
public void contextLoads() {
}
#Test
public void testDB() {
countTableRows("oas_company");
countTableRows("oas_agm");
countTableRows("oas_agmlist");
countTableRows("com_usr");
countTableRows("com_capab");
}
/**
* #param name
*/
private void countTableRows(String name) {
int anzahl = JdbcTestUtils.countRowsInTable(jdbcTemplate, name);
logger.info(name + " = " + anzahl);
}
}
Here is the full console output:
08:58:12.555 [main] DEBUG o.s.t.c.j.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class de.unit4.financials.periods.PeriodRangeTest].
08:58:12.581 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating TestContextBootstrapper from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
08:58:12.607 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - Found explicit ContextLoader class [org.springframework.boot.test.SpringApplicationContextLoader] for context configuration attributes [ContextConfigurationAttributes#32e6e9c3 declaringClass = 'de.unit4.financials.periods.PeriodRangeTest', classes = '{class de.unit4.financials.JUnitConfig}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.boot.test.SpringApplicationContextLoader']
08:58:12.618 [main] DEBUG o.s.t.c.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.627 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - #TestExecutionListeners is not present for class [de.unit4.financials.periods.PeriodRangeTest]: using defaults.
08:58:12.644 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
08:58:12.672 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
08:58:12.688 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#73ad2d6, org.springframework.test.context.support.DirtiesContextTestExecutionListener#7085bdee, org.springframework.test.context.transaction.TransactionalTestExecutionListener#1ce92674, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#5700d6b1]
08:58:12.692 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.694 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.718 [main] DEBUG o.s.t.c.j.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class de.unit4.financials.periods.CurrentPeriodDBFactoryTest].
08:58:12.718 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating TestContextBootstrapper from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
08:58:12.720 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - Found explicit ContextLoader class [org.springframework.boot.test.SpringApplicationContextLoader] for context configuration attributes [ContextConfigurationAttributes#4566e5bd declaringClass = 'de.unit4.financials.periods.CurrentPeriodDBFactoryTest', classes = '{class de.unit4.financials.JUnitConfig}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.boot.test.SpringApplicationContextLoader']
08:58:12.721 [main] DEBUG o.s.t.c.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [de.unit4.financials.periods.CurrentPeriodDBFactoryTest]
08:58:12.722 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - #TestExecutionListeners is not present for class [de.unit4.financials.periods.CurrentPeriodDBFactoryTest]: using defaults.
08:58:12.727 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
08:58:12.729 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
08:58:12.729 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#2d928643, org.springframework.test.context.support.DirtiesContextTestExecutionListener#5025a98f, org.springframework.test.context.transaction.TransactionalTestExecutionListener#49993335, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#20322d26]
08:58:12.729 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.CurrentPeriodDBFactoryTest]
08:58:12.730 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.CurrentPeriodDBFactoryTest]
08:58:12.733 [main] DEBUG o.s.t.c.j.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class de.unit4.financials.periods.PeriodTest].
08:58:12.734 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating TestContextBootstrapper from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
08:58:12.736 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - Found explicit ContextLoader class [org.springframework.boot.test.SpringApplicationContextLoader] for context configuration attributes [ContextConfigurationAttributes#64bf3bbf declaringClass = 'de.unit4.financials.periods.PeriodTest', classes = '{class de.unit4.financials.JUnitConfig}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.boot.test.SpringApplicationContextLoader']
08:58:12.737 [main] DEBUG o.s.t.c.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [de.unit4.financials.periods.PeriodTest]
08:58:12.738 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - #TestExecutionListeners is not present for class [de.unit4.financials.periods.PeriodTest]: using defaults.
08:58:12.743 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
08:58:12.744 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
08:58:12.745 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#544fe44c, org.springframework.test.context.support.DirtiesContextTestExecutionListener#31610302, org.springframework.test.context.transaction.TransactionalTestExecutionListener#71318ec4, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#21213b92]
08:58:12.745 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodTest]
08:58:12.745 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodTest]
08:58:12.752 [main] DEBUG o.s.t.c.j.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class de.unit4.financials.FinancialsUtilApplicationTests].
08:58:12.753 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating TestContextBootstrapper from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
08:58:12.762 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - Found explicit ContextLoader class [org.springframework.boot.test.SpringApplicationContextLoader] for context configuration attributes [ContextConfigurationAttributes#3108bc declaringClass = 'de.unit4.financials.FinancialsUtilApplicationTests', classes = '{class de.unit4.financials.JUnitConfig}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.boot.test.SpringApplicationContextLoader']
08:58:12.762 [main] DEBUG o.s.t.c.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [de.unit4.financials.FinancialsUtilApplicationTests]
08:58:12.763 [main] DEBUG o.s.t.c.s.DefaultTestContextBootstrapper - #TestExecutionListeners is not present for class [de.unit4.financials.FinancialsUtilApplicationTests]: using defaults.
08:58:12.769 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
08:58:12.770 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
08:58:12.770 [main] INFO o.s.t.c.s.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#335eadca, org.springframework.test.context.support.DirtiesContextTestExecutionListener#210366b4, org.springframework.test.context.transaction.TransactionalTestExecutionListener#eec5a4a, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#2b2948e2]
08:58:12.770 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.FinancialsUtilApplicationTests]
08:58:12.770 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.FinancialsUtilApplicationTests]
08:58:12.786 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.787 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.788 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.789 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.790 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.790 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.793 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [de.unit4.financials.periods.PeriodRangeTest]
08:58:12.793 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [de.unit4.financials.periods.PeriodRangeTest]
08:58:13.324 [main] DEBUG o.s.t.c.s.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext#6193932a testClass = PeriodRangeTest, testInstance = de.unit4.financials.periods.PeriodRangeTest#647fd8ce, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration#159f197 testClass = PeriodRangeTest, locations = '{}', classes = '{class de.unit4.financials.JUnitConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.boot.test.SpringApplicationContextLoader', parent = [null]]]].
08:58:13.395 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
08:58:13.398 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
08:58:13.398 [main] DEBUG o.s.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
08:58:13.401 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [integrationTest] PropertySource with search precedence immediately lower than [systemEnvironment]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.5.RELEASE)
2015-07-20 08:58:13.766 INFO 8552 --- [ main] d.u.financials.periods.PeriodRangeTest : Starting PeriodRangeTest on gsender with PID 8552 (C:\Users\gsender\Documents\workspace-libs\FinancialsUtility\target\test-classes started by GSender in C:\Users\gsender\Documents\workspace-libs\FinancialsUtility)
2015-07-20 08:58:13.812 INFO 8552 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#524d6d96: startup date [Mon Jul 20 08:58:13 CEST 2015]; root of context hierarchy
2015-07-20 08:58:15.572 INFO 8552 --- [ main] o.s.j.d.e.EmbeddedDatabaseFactory : Creating embedded database 'FanUtilDB'
2015-07-20 08:58:15.823 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [schema.sql]
2015-07-20 08:58:15.851 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [schema.sql] in 28 ms.
2015-07-20 08:58:15.851 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [data.sql]
2015-07-20 08:58:15.990 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [data.sql] in 139 ms.
08:58:16.007 [main] INFO Datasource org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#60094a13 || de.unit4.financials.JUnitConfig getDataSource 54
08:58:16.197 [main] INFO oas_company = 28 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.199 [main] INFO oas_agm = 2 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.201 [main] INFO oas_agmlist = 2 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.203 [main] INFO com_usr = 52 || de.unit4.financials.JUnitConfig countTableRows 74
08:58:16.205 [main] INFO com_capab = 17 || de.unit4.financials.JUnitConfig countTableRows 74
2015-07-20 08:58:16.271 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/gsender/Documents/workspace-libs/FinancialsUtility/target/test-classes/schema.sql]
2015-07-20 08:58:16.285 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/gsender/Documents/workspace-libs/FinancialsUtility/target/test-classes/schema.sql] in 14 ms.
2015-07-20 08:58:16.289 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/C:/Users/gsender/Documents/workspace-libs/FinancialsUtility/target/test-classes/data.sql]
2015-07-20 08:58:16.391 INFO 8552 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/C:/Users/gsender/Documents/workspace-libs/FinancialsUtility/target/test-classes/data.sql] in 101 ms.
2015-07-20 08:58:16.555 INFO 8552 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-07-20 08:58:16.590 INFO 8552 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-07-20 08:58:16.682 INFO 8552 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.10.Final}
2015-07-20 08:58:16.684 INFO 8552 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-07-20 08:58:16.686 INFO 8552 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-07-20 08:58:16.979 INFO 8552 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-07-20 08:58:17.136 INFO 8552 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2015-07-20 08:58:17.424 INFO 8552 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2015-07-20 08:58:18.153 INFO 8552 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2015-07-20 08:58:18.178 INFO 8552 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2015-07-20 08:58:19.063 INFO 8552 --- [ main] d.u.financials.periods.PeriodRangeTest : Started PeriodRangeTest in 5.659 seconds (JVM running for 7.356)
08:58:19.099 [main] INFO Datasource org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#60094a13 || de.unit4.financials.periods.CurrentPeriodDBFactory getCurrentPeriod 63
08:58:19.127 [main] INFO oas_company = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.128 [main] INFO oas_agm = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.128 [main] INFO oas_agmlist = 0 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.129 [main] INFO com_usr = 52 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
08:58:19.130 [main] INFO com_capab = 17 || de.unit4.financials.FinancialsUtilApplicationTests countTableRows 40
2015-07-20 08:58:19.134 INFO 8552 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#524d6d96: startup date [Mon Jul 20 08:58:13 CEST 2015]; root of context hierarchy
2015-07-20 08:58:19.386 INFO 8552 --- [ Thread-1] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2015-07-20 08:58:19.387 INFO 8552 --- [ Thread-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2015-07-20 08:58:19.398 INFO 8552 --- [ Thread-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
For Table creation I use (example):
drop table IF EXISTS oas_company;
CREATE TABLE IF NOT EXISTS oas_company (
code varchar(12) NOT NULL,
code_cs int NOT NULL,
For data inserts I use:
delete from oas_agm;
INSERT INTO oas_agm(code, tstamp, name, sname, adddate, deldate, moddate, usrname)
VALUES('U4SW-JUNIT-1', 1, 'Account Test Entwicklung', 'debit', '2015-07-15 00:00:00.0', NULL, '2015-07-15 15:31:39.0', 'INSTALL');
Thanks for any help on this confusing result.
I found the solution: Hibernate recreates the tables after initialisation (by Spring Boot). I added spring.jpa.hibernate.ddl-auto=none to application.properties and the problem was gone.
This is the first time this happened in a project. It is also unclear why only three out of five tables are recreated. At first I assumed it was due to an "old" database file, but then I switched from H2 to HSQL and the problem stayed. An error from Hibernate showed me the path to solution (unable to delete...).

Resources