0

I have an application with two different components. One is core (component A) and other has all file resources (component B). When I run application A runs and fetch files like xml, xslt, xsd from other component B. We have recently upgraded to latest version of spring 5 and open jdk 11. I am facing file not found exceptions after version upgrade while running junit tests of A. We are setting user.dir to switch current directory but still it is trying to check in A's folder structure.

Uses following

System.setProperty("user.dir", systemUserDir + "/../ComponentB/src/main/resources");

then we have this property mentioned properties file that we append to above

TEST.Test.XSLTFile=document/business/Test.xslt

So it should ideally search in ComponentB path but it tries searching file in Component A path.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Urvashi
  • 1
  • 1
  • Looking at https://stackoverflow.com/a/840229/5279383 it seems setting the `user.dir` system property is unreliable and will work for newly created `java.io.File` objects, but not for `FileInputStream`. Your question suggests it was working before. How is component A looking for files? – Cezary Butler Jul 31 '20 at 19:27
  • There is also a [bug](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8202127). The answer states you shouldn't change `user.dir` in a running VM. What Java version were you using previously? – Cezary Butler Jul 31 '20 at 19:36

1 Answers1

0

Looking at the https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8202127 I think you'll need another way of setting a directory where the resources should be found.

I might be able to help some more if you would share code which relies on the current directory set.

Cezary Butler
  • 807
  • 7
  • 21