tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Tomcat 7 - java.lang.NoClassDefFoundError: Could not initialize class javax.servlet.http.Cookie
Date Fri, 20 Jan 2012 12:06:26 GMT
2012/1/20 Guillermo GARCIA OCHOA <guillermo.garcia-ochoa@inova-software.com>:
> 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.
>

1. Your exact version of Tomcat x.y.z =?
2. Your OS = ?
3. Do you think that you are running with Java's SecurityManager enabled? [1]

4. Is there anything else in the logs?

I thing that the "Could not initialize class" message means that the
class is found, but its initialization failed.

I wonder though why it is not an instance of ExceptionInInitializerError.


[1] http://tomcat.apache.org/tomcat-7.0-doc/security-manager-howto.html

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message