The problem is that the class uses static variables to store dependencies injected via @Autowired, but Spring does not support autowiring static fields. The solution is to remove static from the variables and pass dependencies through constructor injection. This allows Spring to properly manage dependencies and eliminates the null issue. Additionally, the determineEncryptionKey method should use non-static fields to access injected dependencies. As a result, the code will become cleaner, safer, and will no longer trigger Sonar warnings. Furthermore, constructor injection makes dependencies explicit, simplifying testing and code maintenance.