I have an application that use j_security for a form-based authentication. When the application is deployed for the first time (or the tomcat is restarted) user gets this exception when trying access a protected content directly (without login).
GRAVE: Servlet.service() for servlet [default] in context with path [/mycontext] threw exception [Could not initialize class javax.servlet.http.Cookie] with root cause java.lang.NoClassDefFoundError: Could not initialize class javax.servlet.http.Cookie at org.apache.catalina.core.ApplicationSessionCookieConfig.createSessionCookie(ApplicationSessionCookieConfig.java:127) at org.apache.catalina.connector.Request.doGetSession(Request.java:2875) at org.apache.catalina.connector.Request.getSession(Request.java:2307) at org.apache.catalina.connector.RequestFacade$GetSessionPrivilegedAction.run(RequestFacade.java:216) at org.apache.catalina.connector.RequestFacade$GetSessionPrivilegedAction.run(RequestFacade.java:205) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:894) at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:909) at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:238) at com.mycompany.myfilter.SaasComponentImpl.getTenantId(SaasComponentImpl.java:284) The excepted behaviour is to redirect the user to the login form and when the user logs in redirect him to the requested protected resource. But the weird thing is this works correctly if the first request send to the rebooted server ask for the login form!!! It seems that after this tomcat find and load correctly the cookie class and then all the request are handled as expected. Why tomcat cannot find the Cookie class that is for sure in the lib/servlet-api.jar? IMHO, no mmetter when this class is asked to be load for the first time ... it should be there for any valve, servlet, filter, etc ... I'm right? PS: This was working fine before the app was migrated from tomcat 6.