Okay, well maybe it wasn’t as “suddenly” – changes had been made to the system. Big changes. The active Tomcat instance had ben upgraded from version 4.1.30 to 5.5.12 which apparently changes some runtime dependencies for Realms. One might have guessed since it’s a jump of two major versions (first 5.0.x and then 5.5.x).
The Realm I created extended org.apache.catalina.realm.RealmBase and used the protected debug variable to control debug information written to the (console) log. After spending a fair amount of time debugging the (more or less) cryptic error the solution to the error caused to be one of those “Doh!”-moments.
The error stacktrace in catalina.out was as follows:
Feb 7, 2006 4:32:35 PM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.lang.NoSuchFieldError: debug
at dk.acme.guide.login.LdapDbRealm.getConnection(LdapDbRealm.java:324)
at dk.acme.guide.login.LdapDbRealm.authenticate(LdapDbRealm.java:161)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:256)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:744)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:674)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:866)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
The Tomcat 5.5.12 source have moved to Jakarta commons logging for all the core classes and hence the debug variable of the org.apache.catalina.realm.RealmBase class had been removed from the source. Since I had not recompiled against the Tomcat 5.5.x source (which one could say is my fault) I hadn’t caught the problem. Changing my code to use commons logging (the log variable) and recompiling against the Tomcat 5.5.x source the problem was solved and i was happy campers once more.
Lessons learned:
- Beware of dependencies calculated at runtime.
- Always recompile custom code against the third-party source it depends on when doing major version upgrades.
- Think McFly, think!!
Note: As an aside the basic way to develop and deploy a Realm in Tomcat 5.5.x is still the same as in Tomcat 4.1.x.