tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillermo GARCIA OCHOA <>
Subject Tomcat 7 - java.lang.NoClassDefFoundError: Could not initialize class javax.servlet.http.Cookie
Date Fri, 20 Jan 2012 11:54:49 GMT
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(

    at org.apache.catalina.connector.Request.doGetSession(

    at org.apache.catalina.connector.Request.getSession(

    at org.apache.catalina.connector.RequestFacade$

    at org.apache.catalina.connector.RequestFacade$

    at Method)

    at org.apache.catalina.connector.RequestFacade.getSession(

    at org.apache.catalina.connector.RequestFacade.getSession(

    at javax.servlet.http.HttpServletRequestWrapper.getSession(

    at com.mycompany.myfilter.SaasComponentImpl.getTenantId(

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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message