Config value not auto changed in spring cloud consul - spring-cloud

I have a very simple spring cloud app as follows:
#SpringBootApplication
#EnableDiscoveryClient
#RestController
#EnableAutoConfiguration
public class SpringCloudConsulDemoApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SpringCloudConsulDemoApplication.class).web(true).run(args);
}
#Value("${my.message}")
private String message;
#RequestMapping("/")
public String home() {
return message;
}
#RequestMapping("/health")
public String health() {
return "Hello world";
}
}
I config the "my.message" in consul under /config/SpringCloudConsulDemo,dev/. When I changed the value of "my.message", I got some output in spring cloud app:
2016-06-26 12:41:18.621 INFO 1187 --- [pool-1-thread-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#601c9895: startup date [Sun Jun 26 12:41:18 CST 2016]; root of context hierarchy
2016-06-26 12:41:18.631 INFO 1187 --- [pool-1-thread-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-06-26 12:41:18.632 INFO 1187 --- [pool-1-thread-1] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7facc2d7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-26 12:41:18.687 INFO 1187 --- [pool-1-thread-1] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='consul', propertySources=[ConsulPropertySource#1251328325 [name='config/SpringCloudConsulDemo,dev/', properties=com.ecwid.consul.v1.ConsulClient#58b50524], ConsulPropertySource#119653652 [name='config/SpringCloudConsulDemo/', properties=com.ecwid.consul.v1.ConsulClient#58b50524], ConsulPropertySource#2105869565 [name='config/application,dev/', properties=com.ecwid.consul.v1.ConsulClient#58b50524], ConsulPropertySource#427716065 [name='config/application/', properties=com.ecwid.consul.v1.ConsulClient#58b50524]]]
2016-06-26 12:41:18.691 INFO 1187 --- [pool-1-thread-1] o.s.boot.SpringApplication : The following profiles are active: dev
2016-06-26 12:41:18.692 INFO 1187 --- [pool-1-thread-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#e4a3026: startup date [Sun Jun 26 12:41:18 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#601c9895
2016-06-26 12:41:18.693 INFO 1187 --- [pool-1-thread-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-06-26 12:41:18.699 INFO 1187 --- [pool-1-thread-1] o.s.boot.SpringApplication : Started application in 0.123 seconds (JVM running for 1113.16)
2016-06-26 12:41:18.699 INFO 1187 --- [pool-1-thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#e4a3026: startup date [Sun Jun 26 12:41:18 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#601c9895
2016-06-26 12:41:18.699 INFO 1187 --- [pool-1-thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#601c9895: startup date [Sun Jun 26 12:41:18 CST 2016]; root of context hierarchy
2016-06-26 12:41:18.758 DEBUG 1187 --- [pool-1-thread-1] o.s.c.c.discovery.HeartbeatProperties : Computed heartbeatInterval: PT20S
2016-06-26 12:41:18.808 INFO 1187 --- [pool-1-thread-1] o.s.c.e.event.RefreshEventListener : Refresh keys changed: [spring.cloud.client.hostname, my.message]
I just also call the POST method of /refresh and get some output:
2016-06-26 12:44:12.962 INFO 1187 --- [nio-8093-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#2757ca3e: startup date [Sun Jun 26 12:44:12 CST 2016]; root of context hierarchy
2016-06-26 12:44:12.974 INFO 1187 --- [nio-8093-exec-3] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-06-26 12:44:12.978 INFO 1187 --- [nio-8093-exec-3] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7facc2d7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-26 12:44:13.056 INFO 1187 --- [nio-8093-exec-3] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='consul', propertySources=[ConsulPropertySource#1023386348 [name='config/SpringCloudConsulDemo,dev/', properties=com.ecwid.consul.v1.ConsulClient#2fc3016a], ConsulPropertySource#1663976669 [name='config/SpringCloudConsulDemo/', properties=com.ecwid.consul.v1.ConsulClient#2fc3016a], ConsulPropertySource#1066555341 [name='config/application,dev/', properties=com.ecwid.consul.v1.ConsulClient#2fc3016a], ConsulPropertySource#2117822993 [name='config/application/', properties=com.ecwid.consul.v1.ConsulClient#2fc3016a]]]
2016-06-26 12:44:13.060 INFO 1187 --- [nio-8093-exec-3] o.s.boot.SpringApplication : The following profiles are active: dev
2016-06-26 12:44:13.060 INFO 1187 --- [nio-8093-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#f738b82: startup date [Sun Jun 26 12:44:13 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#2757ca3e
2016-06-26 12:44:13.061 INFO 1187 --- [nio-8093-exec-3] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2016-06-26 12:44:13.066 INFO 1187 --- [nio-8093-exec-3] o.s.boot.SpringApplication : Started application in 0.534 seconds (JVM running for 1287.532)
2016-06-26 12:44:13.066 INFO 1187 --- [nio-8093-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#f738b82: startup date [Sun Jun 26 12:44:13 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#2757ca3e
2016-06-26 12:44:13.066 INFO 1187 --- [nio-8093-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#2757ca3e: startup date [Sun Jun 26 12:44:12 CST 2016]; root of context hierarchy
2016-06-26 12:44:13.103 DEBUG 1187 --- [nio-8093-exec-3] o.s.c.c.discovery.HeartbeatProperties : Computed heartbeatInterval: PT20S
But after all the operations, the value of "message" has not been changed accordingly. Could anyone help for the case, please?

The Config values need to be in a #ConfigurationProperties object or your class need to be annotated with #RefreshScope.

Related

SpringBoot cannot find handler method to register mongdb requests

I have a spring boot app which is trying to connect to Mongo DB, however none of my requests seem to get mapped.
My console log looks like this.
2020-03-03 16:48:57.866 INFO 2100 --- [ main] com.ebay.queens.demo.SpringBootMain : Starting SpringBootMain on DESKTOP-BJ4TA7J with PID 2100 (started by user in C:\Users\user\Documents\Beng Software Engineering\CSC3032-Software Engineering Project\backend)
2020-03-03 16:48:57.872 INFO 2100 --- [ main] com.ebay.queens.demo.SpringBootMain : No active profile set, falling back to default profiles: default
2020-03-03 16:48:59.428 INFO 2100 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-03-03 16:48:59.488 INFO 2100 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 49ms. Found 0 repository interfaces.
2020-03-03 16:49:02.977 INFO 2100 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9000 (http)
2020-03-03 16:49:03.094 INFO 2100 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-03 16:49:03.095 INFO 2100 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.26]
2020-03-03 16:49:03.468 INFO 2100 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-03 16:49:03.468 INFO 2100 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5447 ms
2020-03-03 16:49:03.494 INFO 2100 --- [ main] com.ebay.queens.demo.TokenUtilityClass : Token Utility Class
PRD-38907625e4e8-b6b8-4c83-b069-68ac
2020-03-03 16:49:03.577 INFO 2100 --- [ Timer] com.ebay.queens.demo.TokenUtilityClass : Authentication Token
2020-03-03 16:49:04.369 INFO 2100 --- [ main] com.ebay.queens.demo.Login : Login
2020-03-03 16:49:04.371 INFO 2100 --- [ main] com.ebay.queens.demo.SignUp : SignUp
2020-03-03 16:49:05.453 INFO 2100 --- [ Timer] com.ebay.queens.demo.TokenUtilityClass : A21AAEEVZG6qL6IdhIDPRgFdjGFi00knDwdZsJUdkPsKV9g9sI8Q7R0tv4PKtwV53KkUlagV6QsDI5T53RPb4bhJwUkIwb8Cg
2020-03-03 16:49:05.613 INFO 2100 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2020-03-03 16:49:05.613 INFO 2100 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:27017 to client view of cluster
2020-03-03 16:49:05.754 INFO 2100 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:17}] to localhost:27017
2020-03-03 16:49:05.762 INFO 2100 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 3]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=5458000}
2020-03-03 16:49:05.764 INFO 2100 --- [localhost:27017] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE
2020-03-03 16:49:05.844 WARN 2100 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2020-03-03 16:49:05.845 WARN 2100 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2020-03-03 16:49:06.059 WARN 2100 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2020-03-03 16:49:06.059 WARN 2100 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
2020-03-03 16:49:06.642 INFO 2100 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9000 (http) with context path ''
2020-03-03 16:49:06.646 INFO 2100 --- [ main] com.ebay.queens.demo.SpringBootMain : Started SpringBootMain in 9.677 seconds (JVM running for 10.521)
2020-03-03 16:49:06.648 INFO 2100 --- [ main] com.ebay.queens.demo.TokenUtilityClass : Token Utility Class
2020-03-03 16:49:06.648 INFO 2100 --- [ main] com.ebay.queens.demo.Paypal : Paypal Class
2020-03-03 16:49:06.653 INFO 2100 --- [ main] com.ebay.queens.demo.Version1Api : Version 1 API
and and my controller class looks like this
package com.ebay.queens.demo.resource;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ebay.queens.demo.User;
import com.ebay.queens.repository.UserRepository;
#RestController
public class UserController {
#Autowired
private UserRepository userRepository;
#PostMapping("/AddUser")
public String saveUser(#RequestBody User user) {
userRepository.save(user);
return "Added user with id: " + user.getId();
}
#GetMapping("/all")
public List<User> getAll(){
List<User> users = this.userRepository.findAll();
return users;
}
}
I have tried reshuffling the packages around but not getting any luck.
Would anyone have any suggestions?

Failed steps are not recorded in DB

I'm simulating the error handling behavior of composed task, the failedTask composed task definition looks like this :
<f1: sampleTask --fail=true --custom-argument=someMessage || f2: sampleTask>
The sampleTask class runner :
public class SampleTask implements ApplicationRunner {
#Autowired
SampleTaskProperties taskProperties;
#Override
public void run(ApplicationArguments p) throws Exception {
if(taskProperties.isFail()){
throw new Exception(taskProperties.getCustomArgument());
}
}
}
dependencies :
ext {
springCloudTaskVersion = '1.2.2.RELEASE'
springCloudVersion = 'Edgware.RC1'
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-task')
compile('org.springframework.cloud:spring-cloud-stream-binder-rabbit')
compile('org.springframework.cloud:spring-cloud-task-stream')
compile 'org.postgresql:postgresql:42.1.4'
runtime 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'org.springframework.boot:spring-boot-starter'
compileOnly("org.springframework.boot:spring-boot-configuration-processor");
testCompile('org.springframework.boot:spring-boot-starter-test')
}
The problem is that the end time of f1 is not recorder in DB and failedTask status is shown as STARTED in dashboard UI, end_time of failedTask and failedTask-f1 are both empty in task_executions table.
Below are the logs of the f1 execution :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-20 12:09:06.869 WARN 28244 --- [ main] o.s.boot.SpringApplication : Error handling failed (failed to convert object to Message; nested exception is org.springframework.messaging.MessagingException: At most one parameter (or expression via method-level #Payload) may be mapped to the payload or Message. Found more than one on method [public abstract void org.springframework.cloud.task.listener.TaskExecutionListener.onTaskFailed(org.springframework.cloud.task.repository.TaskExecution,java.lang.Throwable)])
2017-11-20 12:09:06.895 ERROR 28244 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:726) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:713) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at com.philips.asp.flow.task.SampleTaskApplication.main(SampleTaskApplication.java:31) [classes!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [sample-task-0.1.11-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [sample-task-0.1.11-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [sample-task-0.1.11-SNAPSHOT.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [sample-task-0.1.11-SNAPSHOT.jar:na]
Caused by: java.lang.Exception: sdfsdf
at com.philips.asp.flow.task.SampleTaskConfiguration$SampleTask.run(SampleTaskConfiguration.java:53) ~[classes!/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:723) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
... 14 common frames omitted
2017-11-20 12:09:06.898 INFO 28244 --- [ main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#2d363fb3: startup date [Mon Nov 20 12:08:54 IST 2017]; root of context hierarchy
2017-11-20 12:09:06.899 INFO 28244 --- [ main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#6a55299e: startup date [Mon Nov 20 12:09:05 IST 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#2d363fb3
2017-11-20 12:09:06.915 INFO 28244 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483647
2017-11-20 12:09:06.916 INFO 28244 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147482647
2017-11-20 12:09:06.917 INFO 28244 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2017-11-20 12:09:06.917 INFO 28244 --- [ main] ProxyFactoryBean$MethodInvocationGateway : stopped taskEventListener
2017-11-20 12:09:06.917 INFO 28244 --- [ main] ProxyFactoryBean$MethodInvocationGateway : stopped taskEventListener
2017-11-20 12:09:06.917 INFO 28244 --- [ main] ProxyFactoryBean$MethodInvocationGateway : stopped taskEventListener
2017-11-20 12:09:06.917 INFO 28244 --- [ main] o.s.i.gateway.GatewayProxyFactoryBean : stopped taskEventListener
2017-11-20 12:09:06.918 INFO 28244 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2017-11-20 12:09:06.918 INFO 28244 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'sampleTask:12890.errorChannel' has 0 subscriber(s).
2017-11-20 12:09:06.918 INFO 28244 --- [ main] o.s.i.endpoint.EventDrivenConsumer : stopped _org.springframework.integration.errorLogger
2017-11-20 12:09:06.918 INFO 28244 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase -2147482648
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Unregistering JMX-exposed beans
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: task-events
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: errorChannel
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: nullChannel
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: _org.springframework.integration.errorLogger.handler
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-11-20 12:09:06.919 INFO 28244 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2017-11-20 12:09:06.920 WARN 28244 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'taskLifecycleListener': org.springframework.messaging.converter.MessageConversionException: failed to convert object to Message; nested exception is org.springframework.messaging.MessagingException: At most one parameter (or expression via method-level #Payload) may be mapped to the payload or Message. Found more than one on method [public abstract void org.springframework.cloud.task.listener.TaskExecutionListener.onTaskFailed(org.springframework.cloud.task.repository.TaskExecution,java.lang.Throwable)]
2017-11-20 12:09:06.920 INFO 28244 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
If I remove the
compile('org.springframework.cloud:spring-cloud-stream-binder-rabbit)`
compile('org.springframework.cloud:spring-cloud-task-stream')
dependencies - the below warning log message disappears and everything works as expected.
2017-11-20 12:09:06.920 WARN 28244 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'taskLifecycleListener': org.springframework.messaging.converter.MessageConversionException: failed to convert object to Message; nested exception is org.springframework.messaging.MessagingException: At most one parameter (or expression via method-level #Payload) may be mapped to the payload or Message. Found more than one on method [public abstract void org.springframework.cloud.task.listener.TaskExecutionListener.onTaskFailed(org.springframework.cloud.task.repository.TaskExecution,java.lang.Throwable)]
Please advice.
Furer,
Thanks for detailed explanation of the issue. After researching the issue you have discussed in the issue above, it has been identified as the same issue issue as https://github.com/spring-cloud/spring-cloud-task/issues/341. And has been addressed in this PR: https://github.com/spring-cloud/spring-cloud-task/pull/344

Spring JPA cannot connect to Postgresql

I am trying to write a Spring Data JPA application with Postgres.
I am getting an error: FATAL: password authentication failed for user
I tried the same thing writing the connection using regular JDBC, and all worked fine, same username/password/database/hostname.
The property file I'm using for Spring Data JPA contains the following:
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/testdb
spring.datasource.username=test_java
spring.datasource.password=easy_password
server.port=8080
As compared to the property file I'm using for the java jdbc test:
db.url=jdbc:postgresql://localhost:5432/testdb
db.user=test_java
db.passwd=easy_password
The Java code looks like this:
public void testSelectWithPropertyFile() {
Logger lgr = Logger.getLogger(getClass().getName());
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
Properties props = new Properties();
FileInputStream in = null;
try {
in = new FileInputStream("target/classes/properties/database.properties");
props.load(in);
} catch (IOException ex) {
lgr.log(Level.SEVERE, ex.getMessage(), ex);
return;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
lgr.log(Level.SEVERE, ex.getMessage(), ex);
}
}
String url = props.getProperty("db.url");
String user = props.getProperty("db.user");
String passwd = props.getProperty("db.passwd");
try {
con = DriverManager.getConnection(url, user, passwd);
pst = con.prepareStatement("SELECT * FROM Authors");
rs = pst.executeQuery();
while (rs.next()) {
System.out.print(rs.getInt(1));
System.out.print(": ");
System.out.println(rs.getString(2));
}
} catch (Exception ex) {
lgr.log(Level.SEVERE, ex.getMessage(), ex);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pst != null) {
pst.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex) {
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
}
}
Here's the error log I get in Spring Boot JPA:
2016-10-14 11:09:21.593 INFO 6948 --- [ main] com.example.JpaPostgresApplication : Starting JpaPostgresApplication on DESKTOP-53J32BH with PID 6948 (C:\Users\charb\workspace\JPA_POSTGRES\target\classes started by charb in C:\Users\charb\workspace\JPA_POSTGRES)
2016-10-14 11:09:21.595 INFO 6948 --- [ main] com.example.JpaPostgresApplication : No active profile set, falling back to default profiles: default
2016-10-14 11:09:21.679 INFO 6948 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#72f926e6: startup date [Fri Oct 14 11:09:21 BST 2016]; root of context hierarchy
2016-10-14 11:09:23.402 INFO 6948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$72d9bd3b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-14 11:09:23.922 INFO 6948 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-10-14 11:09:23.933 INFO 6948 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-10-14 11:09:23.934 INFO 6948 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2016-10-14 11:09:24.062 INFO 6948 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-10-14 11:09:24.062 INFO 6948 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2387 ms
2016-10-14 11:09:24.230 INFO 6948 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-14 11:09:24.234 INFO 6948 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-14 11:09:24.235 INFO 6948 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-14 11:09:24.235 INFO 6948 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-14 11:09:24.235 INFO 6948 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-14 11:09:24.478 INFO 6948 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-10-14 11:09:24.492 INFO 6948 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-10-14 11:09:24.554 INFO 6948 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2016-10-14 11:09:24.555 INFO 6948 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-10-14 11:09:24.557 INFO 6948 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-10-14 11:09:24.602 INFO 6948 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2016-10-14 11:09:24.828 ERROR 6948 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "test_java "
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:446) ~[postgresql-9.4.1211.jre7.jar:9.4.1211.jre7]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:220) ~[postgresql-9.4.1211.jre7.jar:9.4.1211.jre7]
I can't understand how come Spring Data JPA can't authenticate while normal java JDBC is working ok.
Replace spring.database.driverClassName=org.postgresql.Driver with
spring.datasource.driverClassName=org.postgresql.Driver
Your problem is authentication,
Se message
password authentication failed for user "test_java "
Are sure correct this information connection? because that is your problem
if is correct then make a test, connect same other client in your base, with local.
If ok. the problem it's not ability connection remote.
For ability connect remote access pg_hba.config then ability remote connect (or other file that configuration, your database)
See: that part of my file configuration:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.2.0/24 md5
the permit connection local and network 192.168.2.0, has many way configure that

Spring Boot JUnit in Eclipse resulting in NoSuchMethodError: javax.servlet.ServletContext.addFilter

I'm unable to figure out what's wrong with my eclipse project here. I can run this JUnit Test case just fine using the mvn install command but when I try to run the JUnit Test case within eclipse (eclipse-java-mars-1-linux-gtk-x86_64 or spring-tool-suite-3.7.1.RELEASE-e4.5.1-linux-gtk-x86_64) it fails with the below errors. I tried a fresh checkout but the issue persists. Has anyone else hit this issue?
19:33:15.907 [main] DEBUG o.s.t.c.j.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class FilterTest]
19:33:15.925 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
19:33:15.935 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
19:33:15.948 [main] DEBUG o.s.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [FilterTest] from class [org.springframework.test.context.web.WebTestContextBootstrapper]
19:33:15.968 [main] DEBUG o.s.t.c.w.WebTestContextBootstrapper - Found explicit ContextLoader class [org.springframework.boot.test.SpringApplicationContextLoader] for context configuration attributes [ContextConfigurationAttributes#6e6c3152 declaringClass = 'FilterTest', classes = '{class com.myapp.spring.Application}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.boot.test.SpringApplicationContextLoader']
19:33:15.974 [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 [FilterTest]
19:33:15.992 [main] INFO o.s.t.c.w.WebTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.boot.test.IntegrationTestPropertiesListener#78e67e0a, org.springframework.test.context.support.DependencyInjectionTestExecutionListener#bd8db5a, org.springframework.test.context.support.DirtiesContextTestExecutionListener#2f943d71, org.springframework.test.context.transaction.TransactionalTestExecutionListener#80503, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#4b553d26]
19:33:15.995 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [FilterTest]
19:33:15.995 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [FilterTest]
19:33:16.021 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [FilterTest]
19:33:16.021 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [FilterTest]
19:33:16.023 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [FilterTest]
19:33:16.023 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [FilterTest]
19:33:16.024 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [FilterTest]
19:33:16.025 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [FilterTest]
19:33:16.029 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved #ProfileValueSourceConfiguration [null] for test class [FilterTest]
19:33:16.030 [main] DEBUG o.s.t.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [FilterTest]
19:33:16.033 [main] DEBUG o.s.test.util.ReflectionTestUtils - Getting field 'mergedContextConfiguration' from target object [[DefaultTestContext#cb51256 testClass = FilterTest, testInstance = FilterTest#59906517, testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration#5bfbf16f testClass = FilterTest, locations = '{}', classes = '{class com.myapp.spring.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.SpringApplicationContextLoader', parent = [null]]]] or target class [class org.springframework.test.context.support.DefaultTestContext]
19:33:16.035 [main] DEBUG o.s.test.util.ReflectionTestUtils - Setting field 'propertySourceProperties' of type [null] on target object [[WebMergedContextConfiguration#5bfbf16f testClass = FilterTest, locations = '{}', classes = '{class com.myapp.spring.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.SpringApplicationContextLoader', parent = [null]]] or target class [class org.springframework.test.context.web.WebMergedContextConfiguration] to value [[Ljava.lang.String;#27f723]
19:33:16.035 [main] DEBUG o.s.t.c.s.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext#cb51256 testClass = FilterTest, testInstance = FilterTest#59906517, testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration#5bfbf16f testClass = FilterTest, locations = '{}', classes = '{class com.myapp.spring.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{server.port=0, org.springframework.boot.test.IntegrationTest=true}', resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.SpringApplicationContextLoader', parent = [null]]]].
19:33:16.121 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
19:33:16.123 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
19:33:16.123 [main] DEBUG o.s.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
19:33:16.124 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [integrationTest] PropertySource with search precedence immediately lower than [systemEnvironment]
2015-10-21 19:33:16.329 INFO 18277 --- [ main] o.e.j.i.junit.runner.RemoteTestRunner : Starting RemoteTestRunner on cdebergh-ThinkPad-T450s with PID 18277 (/opt/bin/eclipse/eclipse-java-mars-1-linux-gtk-x86_64/configuration/org.eclipse.osgi/213/0/.cp started by cdebergh in /opt/source/sdk2/myapp-spring-microservice)
2015-10-21 19:33:16.356 INFO 18277 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#206a70ef: startup date [Wed Oct 21 19:33:16 PDT 2015]; root of context hierarchy
2015-10-21 19:33:16.562 INFO 18277 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-10-21 19:33:16.792 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'encrypt.CONFIGURATION_PROPERTIES' of type [class org.springframework.cloud.bootstrap.encrypt.KeyProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:16.792 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'encryptionBootstrapConfiguration' of type [class org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfiguration$$EnhancerBySpringCGLIB$$7b0d273a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:16.999 INFO 18277 --- [ main] o.e.j.i.junit.runner.RemoteTestRunner : Started RemoteTestRunner in 0.822 seconds (JVM running for 1.757)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.5.RELEASE)
2015-10-21 19:33:17.467 ERROR 18277 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/bootstrap/default":Connection refused; nested exception is java.net.ConnectException: Connection refused
2015-10-21 19:33:17.481 INFO 18277 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#53de625d: startup date [Wed Oct 21 19:33:17 PDT 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#206a70ef
2015-10-21 19:33:18.370 INFO 18277 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-10-21 19:33:18.632 INFO 18277 --- [ main] o.s.b.f.config.PropertiesFactoryBean : Loading properties file from URL [jar:file:/home/cdebergh/.m2/repository/org/springframework/integration/spring-integration-core/4.1.4.RELEASE/spring-integration-core-4.1.4.RELEASE.jar!/META-INF/spring.integration.default.properties]
2015-10-21 19:33:18.636 INFO 18277 --- [ main] o.s.i.config.IntegrationRegistrar : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2015-10-21 19:33:18.662 INFO 18277 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'infoEndpoint': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; factoryMethodName=infoEndpoint; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$InfoEndpointRebinderConfiguration; factoryMethodName=infoEndpoint; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class]]
2015-10-21 19:33:18.909 INFO 18277 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2015-10-21 19:33:18.913 INFO 18277 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2015-10-21 19:33:18.923 INFO 18277 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=79168ac5-64ab-30e8-9544-e354fcb6d8c2
2015-10-21 19:33:18.932 INFO 18277 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-10-21 19:33:19.060 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ba40fd01] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.071 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.080 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.088 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.128 INFO 18277 --- [ main] o.s.b.f.config.PropertiesFactoryBean : Loading properties file from URL [jar:file:/home/cdebergh/.m2/repository/org/springframework/integration/spring-integration-core/4.1.4.RELEASE/spring-integration-core-4.1.4.RELEASE.jar!/META-INF/spring.integration.default.properties]
2015-10-21 19:33:19.129 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [class org.springframework.beans.factory.config.PropertiesFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.129 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [class java.util.Properties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.135 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'messageBuilderFactory' of type [class org.springframework.integration.support.DefaultMessageBuilderFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.183 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#1c758545' of type [class org.springframework.integration.channel.MessagePublishingErrorHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.184 INFO 18277 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2015-10-21 19:33:19.185 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'taskScheduler' of type [class org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.189 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationHeaderChannelRegistry' of type [class org.springframework.integration.channel.DefaultHeaderChannelRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.219 INFO 18277 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$ConfigurationPropertiesRebinderConfiguration' of type [class org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$ConfigurationPropertiesRebinderConfiguration$$EnhancerBySpringCGLIB$$ab43ea17] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-10-21 19:33:19.602 INFO 18277 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 0 (http)
2015-10-21 19:33:19.927 INFO 18277 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-10-21 19:33:19.928 INFO 18277 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-10-21 19:33:20.038 INFO 18277 --- [ost-startStop-1] .C.[.[.[/myapp/spring/service/v2] : Initializing Spring embedded WebApplicationContext
2015-10-21 19:33:20.040 INFO 18277 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2559 ms
2015-10-21 19:33:20.348 INFO 18277 --- [ost-startStop-1] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'metricsExecutor'
2015-10-21 19:33:20.687 ERROR 18277 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/myapp/spring/service/v2]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/myapp/spring/service/v2]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.addFilter(Ljava/lang/String;Ljavax/servlet/Filter;)Ljavax/servlet/FilterRegistration$Dynamic;
at org.springframework.boot.context.embedded.FilterRegistrationBean.onStartup(FilterRegistrationBean.java:257)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:222)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:206)
at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 common frames omitted
...

Spring Batch - the batch works in Eclipse but not as a JAR - without explicit DEBUG log

I am new to Spring. My batch works in Eclipse using Spring Boot.
public class Main {
public static void main(String [] args) {
System.exit(SpringApplication.exit(SpringApplication.run(BatchConfiguration.class, args)));
}
}
Here are the Eclipse's logs.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.1.4.RELEASE)
2014-08-08 12:01:09.714 INFO 292 --- [ main] f.i.a.fczeuj.springbatch.Main : Starting Main on W100023928 with PID 292 (started by Me in D:\Eclipse_workspace\SpringBatchJavaConfig)
2014-08-08 12:01:09.776 INFO 292 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#714ae2c1: startup date [Fri Aug 08 12:01:09 CEST 2014]; root of context hierarchy
2014-08-08 12:01:10.494 INFO 292 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'org.springframework.boot.autoconfigure.AutoConfigurationPackages': replacing [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-08-08 12:01:10.979 WARN 292 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.stepScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean Javadoc for complete details
2014-08-08 12:01:10.994 WARN 292 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.jobScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean Javadoc for complete details
2014-08-08 12:01:11.166 INFO 292 --- [ main] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.postgresql.Driver
sql=insert into schema_batch_01.table_batch_donnees_massives values (:num_ligne,(((extract('epoch' from statement_timestamp())*1000)::bigint)-1407492071384)/1000,:prenom, :nom, :rue, :ville, :etat)
2014-08-08 12:01:11.618 INFO 292 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [org/springframework/batch/core/schema-postgresql.sql]
2014-08-08 12:01:11.619 INFO 292 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [org/springframework/batch/core/schema-postgresql.sql] in 1 ms.
2014-08-08 12:01:11.822 INFO 292 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2014-08-08 12:01:11.838 INFO 292 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: []
2014-08-08 12:01:11.884 INFO 292 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: POSTGRES
2014-08-08 12:01:12.025 INFO 292 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2014-08-08 12:01:12.493 INFO 292 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=job1]] launched with the following parameters: [{run.id=28}]
2014-08-08 12:01:12.664 INFO 292 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [taskletTruncate]
truncateDonnees DataSource=
org.springframework.jdbc.datasource.DriverManagerDataSource#7e913c56
Username=
role_cnx_batch_seminaire_dev
2014-08-08 12:01:13.102 INFO 292 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [stepInserts]
2014-08-08 12:01:18.079 INFO 292 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=job1]] completed with the following parameters: [{run.id=28}] and the following status: [COMPLETED]
2014-08-08 12:01:18.079 INFO 292 --- [ main] f.i.a.fczeuj.springbatch.Main : Started Main in 8.677 seconds (JVM running for 9.239)
2014-08-08 12:01:18.079 INFO 292 --- [ main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#714ae2c1: startup date [Fri Aug 08 12:01:09 CEST 2014]; root of context hierarchy
2014-08-08 12:01:18.079 INFO 292 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
So I have built a JAR with maven dependencies and main class in the MANIFEST and run the JAR
java -jar myArchive.jar
But the JAR does nothing, without ERRORS in the DOS logs.
2014-08-08 12:10:47.125 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'batchConfiguration'
sql=insert into schema_batch_01.table_batch_donnees_massives values (:num_ligne,(((extract('epoch' from statement_timestamp())*1000)::bigint)-1407492647125)/1000,:prenom, :nom
, :rue, :ville, :etat)
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Eagerly caching bean 'writer' to allow for resolving potential circular refere
nces
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Invoking afterPropertiesSet() on bean with name 'writer'
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Finished creating instance of bean 'writer'
2014-08-08 12:10:47.141 DEBUG --- [ main] s.c.a.AnnotationConfigApplicationContext : Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using defa
ult [org.springframework.context.support.DefaultLifecycleProcessor#4dc1c92b]
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'lifecycleProcessor'
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [class path resource [
spring.batch.context.properties]]
2014-08-08 12:10:47.141 DEBUG --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.liveBeansView.mbeanDomain' in any property source.
Returning [null]
2014-08-08 12:10:47.157 INFO --- [ main] f.i.a.fczeuj.springbatch.Main : Started Main in 0.952 seconds (JVM running for 1.264)
2014-08-08 12:10:47.157 INFO --- [ main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationCont
ext#356f144c: startup date [Fri Aug 08 12:10:46 CEST 2014]; root of context hierarchy
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'lifecycleProcessor'
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Destroying singletons in org.springframework.beans.factory.support.DefaultList
ableBeanFactory#11e7c5cb: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowi
redAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,batc
hConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcess
or.enhancedConfigurationProcessor,org.springframework.batch.core.configuration.annotation.ScopeConfiguration,stepScope,jobScope,org.springframework.batch.core.configuration.an
notation.SimpleBatchConfiguration,jobRepository,jobLauncher,jobRegistry,jobExplorer,transactionManager,jobBuilders,stepBuilders,fr.insee.architecture.fczeuj.springbatch.Contex
tWithProperties,dataSource,nbIteration,org.springframework.boot.autoconfigure.AutoConfigurationPackages,taskletTruncate,reader,processor,writer,job,stepInserts]; root of facto
ry hierarchy
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'batchConfiguration'
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'org.springframework.batch.core.configura
tion.annotation.SimpleBatchConfiguration'
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'fr.architecture.springbatch
.ContextWithProperties'
2014-08-08 12:10:47.157 DEBUG --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'org.springframework.batch.core.configura
tion.annotation.ScopeConfiguration'
the missing logs between the JAR and Eclipse is just after the log line :
sql=insert into schema_batch_01.table_batch_donnees_massives values (:num_ligne,(((extract('epoch' from statement_timestamp())*1000)::bigint)-1407492647125)/1000,:prenom, :nom
, :rue, :ville, :etat)
Do you have an idea why my JAR aborts without running the Job ? Thank you.
Are you building with maven? If so, using the maven-assembly-plugin does not result in a jar file that runs the batch job, you'll need to use the spring-boot-maven-plugin like this:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.1.4.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>your.MainClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
You can then use the standard "mvn clean package" command to get an executable jar that contains all necessary dependencies and the correct manifest file.