STS-3678: reduced the scope of the write lock while doing auto config scanning and moved the java search out of this scope to avoid deadlocks