Jetty require servlet-api 2.5 to fix "java.lang.NoSuchMethodError
2013-12-26
Jetty require servlet-api 2.5 to fix “java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String”, don’t add “org.mortbay.jetty servlet-api”, you need :
<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency>
[INFO] [03:08:44,408] [TestSpringJetty.java:33] Starting jetty on port 8081 [INFO] [03:08:44,964] [TestSpringJetty.java:54] http://192.168.1.103:8081/monitor [main] INFO org.eclipse.jetty.server.Server - jetty-9.1.0.RC0 [main] INFO /monitor - Set web app root system property: 'webapp.root' = [/Users/peter/Desktop/workspace/titan-monitor/target/titan-monitor] [main] INFO /monitor - Initializing log4j from [classpath:log4j.properties] [main] INFO /monitor - Initializing Spring root WebApplicationContext [INFO] [2013-12-26 03:08:45] - Root WebApplicationContext: initialization started [ERROR] [2013-12-26 03:08:45] - Context initialization failed java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String; at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:367) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:799) at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:435) at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:285) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1324) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:743) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)