Thank you for your responses, however I have solved this error after looking around.
The exception is generated because spring is unable to read jvm's environment properties which is not directly visible in this exception. But once you add the following permission:
permission java.lang.RuntimePermission "getenv.*";
It will fix the above error.