I have a maven based spring web application where I also have several spring-batch jobs integrated. Now to monitor these jobs I want to add Spring Batch Admin to this app.
What I have done so far is this.
1. added this in web.xml inside contextConfigLocation
classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml,
classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml
Added batch-default.properties file with following content.
batch.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
batch.jdbc.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;Database=TestMe
batch.jdbc.user=aa
batch.jdbc.password=aa
batch.database.incrementer.class=org.springframework.jdbc.support.incremente.SqlServerMaxValueIncrementer
batch.data.source.init=false
batch.business.schema.script=
batch.schema.script=
batch.drop.script=
batch.remote.base.url=
& the file with this name batch-SQLSERVER.properties
batch.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
batch.jdbc.url=jdbc:sqlserver://localhost:1433;SelectMethod=cursor;Database=TestMe
batch.jdbc.user=aa
batch.jdbc.password=aa
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer
batch.data.source.init=false
batch.business.schema.script=
batch.schema.script=
batch.drop.script=
batch.remote.base.url=
My db tables for the jobs are already created.
I get the following error:
[TRACE] 2015-03-26 12:01:04.299 [localhost-startStop-1] PropertySourcesPropertyResolver - getProperty("ENVIRONMENT:hsql", String)
[DEBUG] 2015-03-26 12:01:04.299 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT:hsql' in [servletConfigInitParams]
[DEBUG] 2015-03-26 12:01:04.299 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT:hsql' in [servletContextInitParams]
[DEBUG] 2015-03-26 12:01:04.299 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT:hsql' in [jndiProperties]
[DEBUG] 2015-03-26 12:01:04.299 [localhost-startStop-1] JndiTemplate - Looking up JNDI object with name [ENVIRONMENT:hsql]
[DEBUG] 2015-03-26 12:01:04.302 [localhost-startStop-1] JndiPropertySource - JNDI lookup for name [ENVIRONMENT:hsql] threw NamingException with message: Name [ENVIRONMENT:hsql] is not bound in this Context. Unable to find [ENVIRONMENT:hsql].. Returning null.
[DEBUG] 2015-03-26 12:01:04.302 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT:hsql' in [systemProperties]
[DEBUG] 2015-03-26 12:01:04.302 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT:hsql' in [systemEnvironment]
[TRACE] 2015-03-26 12:01:04.303 [localhost-startStop-1] SystemEnvironmentPropertySource - PropertySource [systemEnvironment] does not contain 'ENVIRONMENT:hsql'
[TRACE] 2015-03-26 12:01:04.303 [localhost-startStop-1] SystemEnvironmentPropertySource - PropertySource [systemEnvironment] does not contain 'ENVIRONMENT:HSQL'
[DEBUG] 2015-03-26 12:01:04.303 [localhost-startStop-1] PropertySourcesPropertyResolver - Could not find key 'ENVIRONMENT:hsql' in any property source. Returning [null]
[TRACE] 2015-03-26 12:01:04.303 [localhost-startStop-1] PropertySourcesPropertyResolver - getProperty("ENVIRONMENT", String)
[DEBUG] 2015-03-26 12:01:04.303 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT' in [servletConfigInitParams]
[DEBUG] 2015-03-26 12:01:04.303 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT' in [servletContextInitParams]
[DEBUG] 2015-03-26 12:01:04.303 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT' in [jndiProperties]
[DEBUG] 2015-03-26 12:01:04.303 [localhost-startStop-1] JndiTemplate - Looking up JNDI object with name [java:comp/env/ENVIRONMENT]
[DEBUG] 2015-03-26 12:01:04.304 [localhost-startStop-1] JndiLocatorDelegate - Converted JNDI name [java:comp/env/ENVIRONMENT] not found - trying original name [ENVIRONMENT]. javax.naming.NameNotFoundException: Name [ENVIRONMENT] is not bound in this Context. Unable to find [ENVIRONMENT].
[DEBUG] 2015-03-26 12:01:04.304 [localhost-startStop-1] JndiTemplate - Looking up JNDI object with name [ENVIRONMENT]
[DEBUG] 2015-03-26 12:01:04.304 [localhost-startStop-1] JndiPropertySource - JNDI lookup for name [ENVIRONMENT] threw NamingException with message: Name [ENVIRONMENT] is not bound in this Context. Unable to find [ENVIRONMENT].. Returning null.
[DEBUG] 2015-03-26 12:01:04.304 [localhost-startStop-1] PropertySourcesPropertyResolver - Searching for key 'ENVIRONMENT' in [systemProperties]
[DEBUG] 2015-03-26 12:01:04.304 [localhost-startStop-1] PropertySourcesPropertyResolver - Found key 'ENVIRONMENT' in [systemProperties] with type [String] and value 'SQLSERVER'
[TRACE] 2015-03-26 12:01:04.306 [localhost-startStop-1] PropertyPlaceholderHelper - Resolved placeholder 'ENVIRONMENT:hsql'
[TRACE] 2015-03-26 12:01:04.316 [localhost-startStop-1] TypeConverterDelegate - Converting String to [boolean] using property editor [org.springframework.beans.propertyeditors.CustomBooleanEditor#59bde227]
[TRACE] 2015-03-26 12:01:04.317 [localhost-startStop-1] TypeConverterDelegate - Converting String to [boolean] using property editor [org.springframework.beans.propertyeditors.CustomBooleanEditor#59bde227]
[TRACE] 2015-03-26 12:01:04.317 [localhost-startStop-1] TypeConverterDelegate - Converting String to [int] using property editor [org.springframework.beans.propertyeditors.CustomNumberEditor#414a9c78]
[DEBUG] 2015-03-26 12:01:04.318 [localhost-startStop-1] DefaultListableBeanFactory - Finished creating instance of bean 'placeholderProperties'
[INFO ] 2015-03-26 12:01:04.319 [localhost-startStop-1] PropertyPlaceholderConfigurer - Loading properties file from class path resource [org/springframework/batch/admin/bootstrap/batch.properties]
[INFO ] 2015-03-26 12:01:04.319 [localhost-startStop-1] PropertyPlaceholderConfigurer - Loading properties file from class path resource [batch-default.properties]
[INFO ] 2015-03-26 12:01:04.320 [localhost-startStop-1] PropertyPlaceholderConfigurer - Loading properties file from class path resource [batch-SQLSERVER.properties]
[ERROR] 2015-03-26 12:01:04.325 [localhost-startStop-1] ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'sessionFactory' defined in URL [file:/C:/tomcat-7.0.54/wtpwebapps/testme/WEB-INF/classes/applicationContext-dao.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
hibernate.show_sql=${hibernate.show_sql}
hibernate.format.sql=${hibernate.format.sql}
hibernate.query.substitutions=${hibernate.query.substitutions}
"
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) [catalina.jar:7.0.54]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) [catalina.jar:7.0.54]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [catalina.jar:7.0.54]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [catalina.jar:7.0.54]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
Mar 26, 2015 12:01:04 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'sessionFactory' defined in URL [file:/C:/tomcat-7.0.54/wtpwebapps/testme/WEB-INF/classes/applicationContext-dao.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
hibernate.show_sql=${hibernate.show_sql}
hibernate.format.sql=${hibernate.format.sql}
hibernate.query.substitutions=${hibernate.query.substitutions}
"
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
About my requirements I need to be able to monitor jobs in my current application using the Spring batch admin.
Thank you for viewing it. I did follow the documentation on site. I also refer the code from spring in action book. I am using the version 1.3.0.RELEASE of spring batch with spring 3.2.0.RELEASE.
From the stacktrace itself I can say that the issue is with not reading the properties properly. But if I remove these file/configurations my application works just fine. I am passing -DEVIRONMENT="SQLSERVER" as runtime arguement. Please provide your inputs.
I have refered this question on SO : Integrating Spring Batch Admin in existing application.
I have answered similar issue in this question. When you integrate spring batch admin and spring batch application picks property resource loading configuration from spring batch admin. You need to override it to include locations where spring boot usually keeps config files.
Also I added comment there, we started with similar approach to have single spring boot application with spring batch jobs and spring batch admin for monitoring, this proved to be pain to integrate, we made it work but we had to configure all aspects much harder than if it was spring batch only app. You cannot use java configuration, only xml and much things are colliding (when you add #EnableScheduling annotation to use spring schedulers some of spring batch beans starts to be scheduled etc.)
We ended up with two apps, one which holds jobs and has spring batch only, and other application that has spring batch admin on top of same mysql DB which we use for monitoring only. You loose triggering of jobs through UI and rest from spring batch admin but we are triggering jobs through message queue so we needed only monitoring and that is good solution for us.
Related
I have
#EnableAutoConfiguration(exclude = HibernateJpaAutoConfiguration.class)
in my code, but Spring still starts Hibernate stuff, how to fix this without full excluding of DataSourceAutoConfiguration?
Spring boot 2.2.0.RELEASE.
[DEBUG] 2019-11-14 19:01:17.494 [main] TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
[DEBUG] 2019-11-14 19:01:17.495 [main] TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
[DEBUG] 2019-11-14 19:01:17.495 [main] ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
[DEBUG] 2019-11-14 19:01:17.497 [main] TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
[DEBUG] 2019-11-14 19:01:17.497 [main] TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
[DEBUG] 2019-11-14 19:01:17.498 [main] ConfigurationImpl - Setting custom MessageInterpolator of type org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator
[DEBUG] 2019-11-14 19:01:17.499 [main] ConfigurationImpl - Setting custom ConstraintValidatorFactory of type org.springframework.validation.beanvalidation.SpringConstraintValidatorFactory
[DEBUG] 2019-11-14 19:01:17.499 [main] ConfigurationImpl - Setting custom ParameterNameProvider of type org.springframework.validation.beanvalidation.LocalValidatorFactoryBean$1
[DEBUG] 2019-11-14 19:01:17.501 [main] ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
[DEBUG] 2019-11-14 19:01:17.501 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via user class loader
[DEBUG] 2019-11-14 19:01:17.501 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
[DEBUG] 2019-11-14 19:01:17.502 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
[DEBUG] 2019-11-14 19:01:17.502 [main] ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
[DEBUG] 2019-11-14 19:01:17.509 [main] ValidatorFactoryImpl - HV000234: Using org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator as ValidatorFactory-scoped message interpolator.
[DEBUG] 2019-11-14 19:01:17.509 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.JPATraversableResolver as ValidatorFactory-scoped traversable resolver.
[DEBUG] 2019-11-14 19:01:17.510 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
[DEBUG] 2019-11-14 19:01:17.510 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
[DEBUG] 2019-11-14 19:01:17.510 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
[DEBUG] 2019-11-14 19:01:17.620 [main] TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
[DEBUG] 2019-11-14 19:01:17.620 [main] TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
[DEBUG] 2019-11-14 19:01:17.620 [main] ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
[DEBUG] 2019-11-14 19:01:17.620 [main] ConfigurationImpl - Setting custom MessageInterpolator of type org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator
[DEBUG] 2019-11-14 19:01:17.621 [main] ConfigurationImpl - Setting custom ConstraintValidatorFactory of type org.springframework.validation.beanvalidation.SpringConstraintValidatorFactory
[DEBUG] 2019-11-14 19:01:17.621 [main] ConfigurationImpl - Setting custom ParameterNameProvider of type org.springframework.validation.beanvalidation.LocalValidatorFactoryBean$1
[DEBUG] 2019-11-14 19:01:17.621 [main] ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
[DEBUG] 2019-11-14 19:01:17.621 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via user class loader
[DEBUG] 2019-11-14 19:01:17.621 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
[DEBUG] 2019-11-14 19:01:17.622 [main] ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
[DEBUG] 2019-11-14 19:01:17.622 [main] ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
[DEBUG] 2019-11-14 19:01:17.628 [main] ValidatorFactoryImpl - HV000234: Using org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator as ValidatorFactory-scoped message interpolator.
[DEBUG] 2019-11-14 19:01:17.628 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.JPATraversableResolver as ValidatorFactory-scoped traversable resolver.
[DEBUG] 2019-11-14 19:01:17.628 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
[DEBUG] 2019-11-14 19:01:17.628 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
[DEBUG] 2019-11-14 19:01:17.628 [main] ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
You need
#EnableAutoConfiguration(
exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class
})
The log messages are all related to Hibernate Validator rather than Hibernate (the ORM). Even the messages that mention javax.persistence and JPA are from Hibernate Validator as it does some work to detect what sort of environment it is running in.
I'm developing a Spring Boot + Microservices example. I've taken reference from link: https://github.com/PacktPublishing/Mastering-Spring-Cloud/tree/master/Chapter06/sample-spring-cloud-comm-feign.
In this example, I'm able to start the discovery-service and gateway-service successfully, but when I tried to start any other service I am getting below error.
One thing which I notice that instructions are not very clear on how to execute the code even not mentioned clearly in the book.
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
19:05:25.564 ERROR
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
19:05:25.564 INFO Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1992eaf4: startup date [Mon Dec 24 19:05:14 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#48aca48b
19:05:25.564 INFO Unregistering application customer-service with eureka with status DOWN
19:05:25.564 WARN Saw local status change event StatusChangeEvent [timestamp=1545658525564, current=DOWN, previous=UP]
19:05:25.564 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service: registering service...
19:05:25.564 INFO Stopping beans in phase 0
19:05:25.579 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service - registration status: 204
19:05:26.017 INFO Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#4a064404: startup date [Mon Dec 24 19:05:26 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1992eaf4
19:05:26.061 INFO JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
19:05:26.221 INFO Flipping property: localhost.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
19:05:26.221 INFO Shutdown hook installed for: NFLoadBalancer-PingTimer-localhost
19:05:26.254 INFO Client: localhost instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
19:05:26.288 INFO Using serverListUpdater PollingServerListUpdater
19:05:26.288 INFO DynamicServerListLoadBalancer for client localhost initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList#1ba156fc
19:05:26.585 INFO Unregistering JMX-exposed beans on shutdown
19:05:26.585 INFO Unregistering JMX-exposed beans
19:05:26.585 INFO Shutting down DiscoveryClient ...
19:05:26.585 INFO Unregistering ...
19:05:26.606 INFO DiscoveryClient_CUSTOMER-SERVICE/localhost:customer-service - deregister status: 200
19:05:26.607 INFO Completed shut down of DiscoveryClient
19:05:26.607 INFO Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#4a064404: startup date [Mon Dec 24 19:05:26 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1992eaf4
19:05:26.607 WARN Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)
at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:283)
at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:253)
at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:177)
at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:140)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:991)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:76)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:272)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at pl.piomin.services.customer.CustomerApplication.main(CustomerApplication.java:22)
19:05:26.607 INFO Shutdown hook removed for: NFLoadBalancer-PingTimer-localhost
19:05:26.607 INFO Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#1491344a: startup date [Mon Dec 24 19:05:17 IST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1992eaf4
19:05:26.607 WARN Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
Change the port in application.yml where ever you have below properties. In your system the tomcat is probably running in default 8080 port.
server:
port: ${PORT:8080}
Hope the above change may help you.
https://github.com/spring-cloud/spring-cloud-netflix/commit/12583fd0c25638f95c14973d921ca28cdcd17df5
update your spring cloud version to Greenwich.SR6, the question will dispear
Im wanting to feed multiple configuration files based on properties into –
<beans:property name="locations">
<beans:list>
<beans:value>classpath:properties/local.properties</beans:value>
<beans:value>classpath:properties/${spring.profiles.active}.properties</beans:value>
</beans:list>
</beans:property>
And was under the impression I could use –
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>profile-a, profile-b</param-value>
</context-param>
I get this error – so its not parsing the param-values -
14:13:12.065 [localhost-startStop-1] TRACE o.s.c.e.PropertySourcesPropertyResolver - getProperty("spring.profiles.active", String)
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletConfigInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in [servletContextInitParams] with type [String] and value profile-a, profile-b'
14:13:12.065 [localhost-startStop-1] TRACE o.s.util.PropertyPlaceholderHelper - Resolved placeholder 'spring.profiles.active'
14:13:12.065 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'dsProperties'
14:13:12.065 [localhost-startStop-1] INFO o.s.b.f.config.PropertiesFactoryBean - Loading properties file from class path resource [properties/profile-a, profile-b.properties]
14:13:12.065 [localhost-startStop-1] WARN o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [properties/ profile-a, profile-b.properties.properties]: class path
Can this be done?
I am in process of upgrading a spring boot 1.3.3 project to 1.4.2.
After upgrading the project Spring boot will no longer use any application.properties file. It does not locate it. Even when passed as an startup argument.
The project is built with gradle and a shadowjar plugin to compile to a fat jar and start tomcat embedded from the jar.
The way the application is started is: java -jar app-all.jar. The directory containing the jar also contains the application.properties file. (and no other files)
There is no classpath set and the jar file does not contain any other application.properties files. (Tested with unzip -t app-all.jar |grep application.properties)
Starting the project under Spring Boot 1.3.3. The application starts correctly. Start of log file:
04:15:58.846 com.app.MaxApplication INFO [main] - Starting MaxApplication on test-ng with PID 30096 (/home/ubuntu/app-all.jar started by ubuntu in /home/ubuntu)
04:15:58.850 com.app.MaxApplication DEBUG [main] - Running with Spring Boot, Spring
04:15:58.850 com.app.MaxApplication INFO [main] - The following profiles are active: TEST
04:15:58.850 org.springframework.boot.SpringApplication DEBUG [main] - Loading source class com.app.MaxApplication
04:15:58.947 org.springframework.boot.context.config.ConfigFileApplicationListener DEBUG [main] - Activated profiles TEST
04:15:58.947 org.springframework.boot.context.config.ConfigFileApplicationListener DEBUG [main] - Loaded config file 'file:./application.properties'
Changing spring boot version to 1.4.2, cleaning gradle caches and rebuilding and running the application the same way Spring Boot does nto load the applciation.properties file and the application fails to start due to missing configuration settings provided by the file. Start of log file:
01:48:47.547 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [servletConfigInitParams] PropertySource with lowest search precedence
01:48:47.549 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [servletContextInitParams] PropertySource with lowest search precedence
01:48:47.551 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
01:48:47.552 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
01:48:47.552 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,systemProperties,systemEnvironment]
01:48:47.552 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source
01:48:47.552 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source
01:48:47.554 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'banner.image.location' in any property source
01:48:47.555 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'banner.location' in any property source
01:48:47.556 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'banner.charset' in any property source
01:48:47.557 [main] DEBUG org.springframework.core.env.MutablePropertySources - Adding [version] PropertySource with lowest search precedence
01:48:47.560 [main] DEBUG org.springframework.core.env.MutablePropertySources - Adding [ansi] PropertySource with highest search precedence
01:48:47.561 [main] DEBUG org.springframework.core.env.MutablePropertySources - Adding [title] PropertySource with highest search precedence
01:48:47.600 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [servletConfigInitParams] PropertySource with lowest search precedence
01:48:47.600 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [servletContextInitParams] PropertySource with lowest search precedence
01:48:47.600 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
01:48:47.600 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
01:48:47.601 [main] DEBUG org.springframework.web.context.support.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,systemProperties,systemEnvironment]
01:48:47.637 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
01:48:47.649 [main] INFO com.app.MaxApplication - Starting MaxApplication on test-ng (/home/ubuntu/app-all.jar started by ubuntu in /home/ubuntu)
01:48:47.649 [main] DEBUG com.app.max.MaxApplication - Running with Spring Boot, Spring
01:48:47.650 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source
01:48:47.650 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.default' in any property source
01:48:47.650 [main] INFO com.app.max.MaxApplication - No active profile set, falling back to default profiles: default
01:48:47.650 [main] DEBUG org.springframework.boot.SpringApplication - Loading source class com.app.MaxApplication
Only two files in the current directory are the application.properties file and the jar file. The externalizing configration documentation says the configuration should be read from there. It also works under Spring 1.3.3
I have defined a configuration class (this is working in 1.3)
#Component
#Configuration
#SpringBootConfiguration
public class MaxApplicationProperties {
#Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
I have tried:
Adding application.properties file to the class path.
Starting the application with --spring.config.location=application.properties (and with full path as well)
Setting config location environment variables.
Adding annotation #PropertySource("classpath:application.properties") to the MaxApplicationProperties class
Force deleting all downloaded libraries and having gradle re-download everything.
None of these options work to make Spring boot attempt to use the application.properties file the same was as Spring boot 1.3.
Anyone know what I am missing? Thanks.
27-Sep-2016 18:21:47.731 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
27-Sep-2016 18:21:47.733 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/apache-tomcat-8.0.37/webapps/ROOT has finished in 46 ms
27-Sep-2016 18:21:47.733 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/apache-tomcat-8.0.37/webapps/host-manager
27-Sep-2016 18:21:47.735 WARNING [localhost-startStop-1] org.apache.catalina.session.ManagerBase.setMaxInactiveInterval Manager.setMaxInactiveInterval() is deprecated and calls to this method are ignored. Session timeouts should be configured in web.xml or via Context.setSessionTimeout(int timeoutInMinutes)
27-Sep-2016 18:21:47.781 INFO [localhost-startStop-1] com.orangefunction.tomcat.redissessions.RedisSessionManager.startInternal Attached to RedisSessionHandlerValve
27-Sep-2016 18:21:47.782 INFO [localhost-startStop-1] com.orangefunction.tomcat.redissessions.RedisSessionManager.initializeSerializer Attempting to use serializer :com.orangefunction.tomcat.redissessions.JavaSerializer
27-Sep-2016 18:21:47.782 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal The session manager failed to start
org.apache.catalina.LifecycleException: Failed to start component [com.orangefunction.tomcat.redissessions.RedisSessionManager[/host-manager]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5331)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1834)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.apache.catalina.Container.getLoader()Lorg/apache/catalina/Loader;
at com.orangefunction.tomcat.redissessions.RedisSessionManager.initializeSerializer(RedisSessionManager.java:716)
at com.orangefunction.tomcat.redissessions.RedisSessionManager.startInternal(RedisSessionManager.java:295)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 12 more
27-Sep-2016 18:21:47.782 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/host-manager] startup failed due to previous errors
27-Sep-2016 18:21:47.785 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/apache-tomcat-8.0.37/webapps/host-manager has finished in 52 ms
27-Sep-2016 18:21:47.787 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
27-Sep-2016 18:21:47.791 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
27-Sep-2016 18:21:47.793 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 3490 ms
This is the output in terminal while running tomcat. I installed redis properly and it is running. I added jars to the lib of the tomcat folder and changed settings in the context.xml, there i written this
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
password="mypass"
database="0"
maxInactiveInterval="30" />