Problem
Normally you set the CATALINA_OPTS with the system properties. But this means you need to change the start script to the server.
SET CATALINA_OPTS=-Djava.security.auth.login.config=C:/programs/Tomcat-6.0.16/webapps/MyApp/WEB-INF/myapp.login -Djava.security.auth.policy=D:/programs/Tomcat-6.0.16/webapps/MyApp/WEB-INF/myapp.policy
Solution:
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
System.setProperty(“java.security.auth.login.config”, servletContext.getRealPath(“/WEB-INF/myapp.login”));
System.setProperty(“java.security.auth.policy”, servletContext.getRealPath(“/WEB-INF/myapp.policy”));
Beware:
The getRealPath method returns NULL if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).