When asynchronous Rest calls are made, then some of them return 401 authrozation error. The workaround that i tried was to make authenticate(String username, String credentials) method in ControllerCustomRealm.java synchronized, which resolved to problem.
But this doesnt seem like a good way to resolve it. I want a solution that is asynchronous. Please help me with this.