Halt spring boot application startup until spring cloud config server is up

I am trying to run my spring boot application with following properties set and I am expecting it to keep retrying to load properties from config server for 50 times with wait of 6 seconds between any two attempts and even after that it cannot connect to config server, it should either resume the startup or exit (I am indifferent on whatever spring boot is capable of doing after retries). But it doesn’t seem like its behaving as expected.

My startup command –

java -jar -Dspring.application.name=maas-gateway -Dspring.cloud.config.uri=http://localhost:8888 -Dspring.cloud.config.failFast=false -Dspring.cloud.config.retry.initialInterval=5000 -Dspring.cloud.config.retry.maxInterval=7000 -Dspring.cloud.config.retry.maxAttempts=50 maas-gateway-1.0-SNAPSHOT.jar

But I am getting following errors, as it resumes the startup after one try.

2017-10-06 09:55:05.881 INFO [] 3598 — [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@53e25b76: startup date [Fri Oct 06 09:55:05 EDT 2017]; root of context hierarchy
2017-10-06 09:55:06.136 INFO [] 3598 — [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject’ annotation found and supported for autowiring
2017-10-06 09:55:06.166 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘configurationPropertiesRebinderAutoConfiguration’ of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bbc9d7cf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
__ __ _____ _____ _
| / | / ____| / ____| | |
| / | __ _ __ | ( ______| | __ __ | | _____ ____ _ _ _
| |/| |/ _|/ _ |_ ______| | |_ |/ | __/ _ / / / _ | | | |
| | | | (
| | (_| |____) | | || | (_| | || __/ V V / (| | || |
|| ||__,|_,_|_____/ _____|__,|__
| _/_/ __,|_, |
/ |
|_
/
2017-10-06 09:55:06.494 INFO [] 3598 — [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2017-10-06 09:55:06.579 WARN [] 3598 — [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for “http://localhost:8888/maas-gateway/default“: Connection refused; nested exception is java.net.ConnectException: Connection refused
2017-10-06 09:55:06.580 INFO [] 3598 — [ main] com.solace.maas.Application : No active profile set, falling back to default profiles: default
2017-10-06 09:55:06.601 INFO [] 3598 — [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2ed94a8b: startup date [Fri Oct 06 09:55:06 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@53e25b76
2017-10-06 09:55:08.889 INFO [] 3598 — [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean ‘getManagerExecutorService’ with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gatewayServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/gateway/configuration/GatewayServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]]
2017-10-06 09:55:08.890 INFO [] 3598 — [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean ‘getMaasProperties’ with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gatewayServiceConfiguration; factoryMethodName=getMaasProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/gateway/configuration/GatewayServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getMaasProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]]
2017-10-06 09:55:08.898 INFO [] 3598 — [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean ‘getManagerExecutorService’ with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=iamServiceConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/iam/configuration/IamServiceConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=signupManagerConfiguration; factoryMethodName=getManagerExecutorService; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/solace/maas/signupManager/configuration/SignupManagerConfiguration.class]]
2017-10-06 09:55:09.126 INFO [] 3598 — [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean ‘managementServletContext’ with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]]
2017-10-06 09:55:09.750 WARN [] 3598 — [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition ‘refreshScope’ since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as ‘static’.
2017-10-06 09:55:09.992 INFO [] 3598 — [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=27bcc9d7-c3a9-3801-b696-3f3650ee7946
2017-10-06 09:55:10.038 INFO [] 3598 — [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 ‘javax.inject.Inject’ annotation found and supported for autowiring
2017-10-06 09:55:10.137 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration$DefaultAsyncConfigurerSupport’ of type [class org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration$DefaultAsyncConfigurerSupport$$EnhancerBySpringCGLIB$$dcf17295] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.237 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration’ of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$9fafd4d2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.467 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration’ of type [class org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$385d9d0c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.486 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘objectPostProcessor’ of type [class org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.494 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@736d6a5c’ of type [class org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.506 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration’ of type [class org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$5d323fbe] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.571 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘methodSecurityMetadataSource’ of type [class org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.606 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration’ of type [class org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration$$EnhancerBySpringCGLIB$$d1dc7b13] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:10.659 INFO [] 3598 — [ main] trationDelegate$BeanPostProcessorChecker : Bean ‘org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration’ of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bbc9d7cf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-06 09:55:11.342 INFO [] 3598 — [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-10-06 09:55:11.353 INFO [] 3598 — [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-10-06 09:55:11.354 INFO [] 3598 — [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-10-06 09:55:11.429 INFO [] 3598 — [ocalhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-10-06 09:55:11.429 INFO [] 3598 — [ocalhost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4828 ms
2017-10-06 09:55:12.903 ERROR [] 3598 — [ocalhost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name ‘iamServiceConfiguration’: Unsatisfied dependency expressed through method ‘setContentNegotationStrategy’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration’: Unsatisfied dependency expressed through method ‘setConfigurers’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter’: Unsatisfied dependency expressed through constructor parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration’: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$$EnhancerBySpringCGLIB$$3067f332]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jacksonHttpMessageConverter’ defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter]: Factory method ‘jacksonHttpMessageConverter’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘config’ defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.rest.core.config.RepositoryRestConfiguration]: Factory method ‘config’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘repositories’ defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method ‘repositories’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAttributeDAO’: Cannot create inner bean ‘(inner bean)#60b53b0c’ of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property ‘entityManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘(inner bean)#60b53b0c’: Cannot resolve reference to bean ‘entityManagerFactory’ while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration’: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method ‘dataSource’ threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2017-10-06 09:55:12.932 WARN [] 3598 — [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization – cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-10-06 09:55:12.940 ERROR [] 3598 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

how can i navigate to the next page in a for loop without failing the loop?i m trying to download all the pdfs

This is my code , I’m trying to download all the Pdf’s from the webpage https://iaeme.com/ijmet/index.asp . The page has different links , inside each link there are multiple downloads and more pages , i m trying to navigate the next page and continue the loop . pls help !
package flow;

        import java.io.File;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import java.net.URL;
        import java.nio.file.Files;
        import java.nio.file.Path;
        import java.nio.file.StandardCopyOption;
        import java.util.List;
        import java.util.NoSuchElementException;

        import org.apache.poi.ss.usermodel.Cell;
        import org.apache.poi.ss.usermodel.Row;
        import org.apache.poi.xssf.usermodel.XSSFSheet;
        import org.apache.poi.xssf.usermodel.XSSFWorkbook;
        import org.apache.tools.ant.taskdefs.Java;
        import org.apache.tools.ant.types.FileList.FileName;
        import org.openqa.selenium.By;
        import org.openqa.selenium.JavascriptExecutor;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.WebDriver.Navigation;
        import org.openqa.selenium.WebElement;
        import org.openqa.selenium.chrome.ChromeDriver;
        import org.w3c.dom.Text;

  import jxl.common.Assert;
  //kindly ignore the imports 


 public class excel {


 public static void main(String[] args) throws IOException, Exception {

 System.setProperty("webdriver.chrome.driver", 
"C:\Users\User_2\Downloads\chromedriver_win32\chromedriver.exe");
   WebDriver d=new ChromeDriver();
  d.manage().window().maximize();
  d.get("https://iaeme.com/ijmet/index.asp");

 java.util.List<WebElement> catvalues=d.findElements(By.className("issue"));
 for(int i=0;i<=catvalues.size();i++){  
 catvalues.get(i).click();

 java.util.List<WebElement> 
downcount=d.findElements(By.linkText("Download"));
  System.out.println(downcount.size());

  for(int k=1;k<=downcount.size();k++){  
  downcount.get(k).click();

  Thread.sleep(5000);   

  }

  d.navigate().back();
  catvalues = d.findElements(By.className("issue"));
}
}  
}

I tried different moethods which failed , kindly help

Why cant my main and method see my Scanner even though called at calls level [duplicate]

I wrote the following code but it will not compile as my scanner call at class level cannot be seen by the main and method as described and I have no idea why.. Please advise this noob were he is going wrong please?!

import java.util.*;  // import util library for shorter Scanner call
public class test {

Scanner scanner = new Scanner(System.in);  // scanner created at class level
    public static void main(String[] args) {
    // new shorter scanner call

    float temp;
    String scale;

    for ( int count =1; count <= 5; count = count + 1) {

        System.out.print("please enter a temperature to convert: ");
        temp = scanner.nextInt();  // this cannot see scanner

        System.out.print("Please enter the scale - F or C: ");
        scale = scanner.next();  // this cannot see scanner

        if (scale.equals("F") || scale.equals("f")) {
            calcCel(temp);
        }
        else if (scale.equals("C") || scale.equals("c")) {
            calcFah(temp);
        }
        else {
            System.err.print("You must enter either F or C for Fahrenheit and Celsius ! ");
            System.exit(0);
        }
    } // End for loop
} // End of main

private static void calcCel(float temp) {
    float calc = (temp - 32) / 1.8F;
    System.out.println(temp + " degrees Fahrenheit = " + calc + " degrees Celsius ");
    float pfft = scanner.nextInt();  // this cannot see scanner
} // End calcCel method

private static void calcFah(float temp) {
    float calc = (temp * 1.8F) + 32;
    System.out.println(temp + " degrees Celsius = " + calc + " degrees Fahrenheit ");

 } // End calcFah method
} // End class

Returned errors on compiling

test.java:15: error: non-static variable scanner cannot be referenced
from a static context
temp = scanner.nextInt();
^ test.java:18: error: non-static variable scanner cannot be referenced from a static context
scale = scanner.next();

I’ve been watching vids doing this and it works for them so no idea what I’m doing wrong. Thanks in advance for your help.

~Java noob trying to learn

Error: A JNI error has occurred while executing jar file

I’m getting the below exception when i’m trying to run my jar file though powershell using the command java -jar restcall.jar:

Error: A JNI error has occurred, please check your installation and
try again Exception in thread “main” java.lang.NoClassDefFoundError:
org/apache/http/client/ClientProtocolException

It complies and runs perfectly in eclipse. Kindly help.

How to check certain words on a string?

    if (c.getQuery().contains("update") || c.getQuery().contains("delete") || c.getQuery().contains("truncate")
            || c.getQuery().contains("drop")) {
        throw new MensagemException(Mensagens.getMensagem("Only select is allowed"));

I have this simple code, that checks the string query. But it only checks lower case, what can I do to make it also verify any upper case without writing this over and over?

Eclipse Neon Javadoc help does not work

I have an issue with Eclipse Neon where the Javadoc has suddenly stopped working.
Running Lubuntu OS, w Eclipse Neon.3,
I get the following stacktrace in the the error log when I hit the F2 button:
I have uninstalled the plugins I installed before it worked fine, pydev, xtext, ,xtend and JHipster plugin, still same issue.

org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1605)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1339)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1366)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1349)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1378)
    at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:764)
    at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3465)
    at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:801)
    at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2000)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:5827)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5498)
    at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
    at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9545)
    at org.eclipse.swt.widgets.Display.eventProc(Display.java:1275)
    at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
    at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2495)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4149)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:123)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    ... 53 more
Caused by: java.lang.NullPointerException
    at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getStyleSheet(JavadocHover.java:943)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:747)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:635)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:627)
    at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:164)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavaInformationProvider.getInformation2(JavaInformationProvider.java:71)
    at org.eclipse.jface.text.information.InformationPresenter.computeInformation(InformationPresenter.java:310)
    at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:1144)
    at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:1134)
    at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:950)
    at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1461)
    at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:196)
    at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:201)
    at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:130)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:127)
    at org.eclipse.ui.texteditor.AbstractTextEditor$InformationDispatchAction.run(AbstractTextEditor.java:1816)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:118)
    ... 59 more

Formatting timestamp using DateTimeFormatter for “early” dates

I’m implementing functionality for formatting timestamps inserted in a database.
An existing solution uses SimpleDateFormat for this task. As SimpleDateFormat is not thread safe I’m converting the implementation to the use of java.time.

In this process I have bumped into some strange behavior where formating renders different results.
The example below shows how a Timestamp is formatted as “1500-01-10 00:12:12” when using java.time and 1500-01-01 00:00:00 when using SimpleDateFormat.
I can not undertand why we are 9 day off when using java.time. Also where does the 12:12 come from.
The data is inserted into the database using ‘1500-01-01 00:00:00’. Using the database formatting function DATE_FORMAT renders the
expected output.

public static void main(String[] args) {
   // The following ts value is obtained by debugging the Timestamp
   // instance when reading data from MYSQL. 
   long ts = -14830995600000l;
   String TSPATTERN = "yyyy-MM-dd HH:mm:ss";
   Timestamp timestamp = new Timestamp(ts);
   System.out.println("                            ZoneId: " + ZoneId.systemDefault());
   System.out.println("timestamp.toString() " + timestamp);

   // java.time
   DateTimeFormatter f = DateTimeFormatter.ofPattern(TSPATTERN).withZone(ZoneId.systemDefault());
   String withJavaTime = f.format(timestamp.toInstant());

   // Using SimpleDate format
   SimpleDateFormat fdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance();
   fdf.applyPattern(TSPATTERN);
   String withSDF = fdf.format(ts);
   System.out.println("       With java.time: " + withJavaTime);
   System.out.println("With SimpleDateFormat: " + withSDF);

   // Running the above will print the following output
   // Where does the 12:12 come from? and the 9 days?
   // With java.time: 1500-01-10 00:12:12
   // With SimpleDateFormat: 1500-01-01 00:00:00
}