Project: bamboo
Issue BAM-6551: Servlet api 2.5 broken
NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String when installing the JavaMelody plugin. This issue is based on the initial issue submitted at http://code.google.com/p/javamelody/issues/detail?id=37 Steps to reproduce: 1. Download the JavaMelody plugin from https://plugins.atlassian.com/plugin/details/20909 2. Copy the jar into the webapp/WEB-INF/lib folder 3. Start Bamboo (2.6.1) 4. Tail the bamboo log file The Bamboo logs show this stack trace when JavaMelody is installed in Bamboo 2.6.1: 2010-07-16 14:40:46,712 ERROR [796347291@qtp-745957924-0] [DefaultServletModuleManager] Unable to create filter com.atlassian.plugin.servlet.util.LazyLoadedReference$InitializationException: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String; at com.atlassian.plugin.servlet.util.LazyLoadedReference.get(LazyLoadedReference.java:94) at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilter(DefaultServletModuleManager.java:321) at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilters(DefaultServletModuleManager.java:188) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:53) at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:41) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520) Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String; at net.bull.javamelody.Parameters.getContextPath(Parameters.java:328) at net.bull.javamelody.MonitoringFilter.init(MonitoringFilter.java:94) at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.init(DelegatingPluginFilter.java:43) at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedFilterReference.create(DefaultServletModuleManager.java:371) at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedFilterReference.create(DefaultServletModuleManager.java:356) at com.atlassian.plugin.servlet.util.LazyLoadedReference$1.call(LazyLoadedReference.java:62) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at com.atlassian.plugin.servlet.util.LazyLoadedReference.get(LazyLoadedReference.java:74) My analysis: This ServletContext.getContextPath() method is called by the javamelody plugin only if the servlet api version is 2.5 or more. So the fact that the method is called in Bamboo v2.6.1 Build 1902 / jetty v6.1.15 implies that ServletContext.getMajorVersion() has returned 2 and that ServletContext.getMinorVersion() has returned 5. But the method call in the plugin throws "java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;", even if this method is supposed to exists in the servlet api 2.5. This issue implies that in this setup (in a plugin with bamboo 2.6.1 Build 1902 and jetty v6.1.15), the servlet api 2.5 was broken somehow: the method must exists. This is probably related to the fact that there are both servlet-api-2.4.jar and servlet-api-2.5.jar in "Bamboo/webapp/WEB-INF/lib/". Workaround: The following workaround was tested with success: 1. stop the bamboo server 2. backup and delete the file "Bamboo/webapp/WEB-INF/lib/servlet-api-2.4.jar" from your bamboo setup (but keep the servlet-api-2.5.jar) 3. restart the bamboo server 4. install the javamelody plugin Thanks anyway for a great plugin architecture. PS: The JavaMelody plugin goal is to monitor JIRA, Confluence and Bamboo servers.
Story points: 1