The fix is using system property as @FilMiOs said (I would have comment on his reply if had enough points).
Anyway, the root cause is thread classloader and normal classloader are pointing to different locations. As explained here: Difference between thread's context class loader and normal classloader
It happens to me in a tomcat instance where multiple applications share a common thread pool. The thread classloader is whichever app started the thread. But when the thread reused by another application, the thread classloader stay the same. Hence the difference.
To confirm, set a break point and watch the following two results, see if they are the same.
Thread.currentThread().getContextClassLoader()
this.getClass().getClassLoader()