There is a class that pulls configurations from the .properties file in the initPaths() method marked with @PostConstruct . Development is conducted under Mac OS and everything is stable here. But when I started to deploy the application on Windows Server 2012 it turned out that in knocking with Windiws the initPaths() method is not called at all.

 @Value("${traned.data}") private String tranedData; @PostConstruct void initPaths() { log.debug("Init Path Call"); isWindows = System.getProperty("os.name").toLowerCase().indexOf("win") > 0; root = new File(".").getAbsolutePath(); ...дальше просто преобразования со строками... } 

How it happens: I take the same jar archive, run it on a Mac, everything works and Init Path Call written to the log, and on Windows, the log is not there, and the program crashes without this data.

  • The Java program does not run in any operating system, but in the JVM. JVM is the same for all operating systems and strictly follows the specification. I think you yourself are trying to get out of the JVM, and this ruin the program. For example, why are the isWindows and root variables calculated? - Sergey Gornostaev
  • @Sergey Gornostaev is the OS switch to run the code with different paths to the necessary files on my local machine and server. But maybe the fact is that I have Java (TM) SE Runtime Enviroment (build 9.0.1 + 11) Java HotSpot (TM) 64-Bit Server VM on Windows (build 9.0.1 + 11, mixed mode)? - Pavel
  • This switch is not needed. It is necessary to abstract as much as possible from the peculiarities of the environment. - Sergey Gornostaev
  • @Sergey Gornostaev, yes, I understand, but I don’t know how to do it, besides, this is the first test bench ... I’ll then alter it normally. I have a problem with @PostConstruct why java 9.0.1 + 11 does not pick it up ((((
  • @PostConstruct can not be called only in one case - if the bin has not been instantiated. And this, if we exclude lazy initialization, can only be the case - the program has fallen before. - Sergey Gornostaev

0