0

I am creating an SpringBoot REST application (using Gradle). It works fine from my Eclipse. When I take the build and run the JAR I'm getting the following error:

java.lang.NoSuchMethodError:
javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
        at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:626)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
~[spring-webmvc-3.2.0.RELEASE.jar!/:3.2.0.RELEASE]

Using jetty server, servlet-api2.5 and jdk1.7

Can anyone please help me resolve this?

8
  • Do you have any other (older) versions of servlet.jar included somehow? Commented Oct 7, 2015 at 10:39
  • Review all your classpath in your eclipse project. Also use eclipse tools to search if there is more than one "ServletContext" class Commented Oct 7, 2015 at 10:49
  • @Thilo - Nope. I cheked that one. Commented Oct 7, 2015 at 11:04
  • I ran into the same error the last days, it turned out that I had the wrong (or an older version of a) jar in the lib folder of my application server then I had in the build path of my project. It was not a Spring project but maybe that helps you. Commented Oct 7, 2015 at 11:40
  • I found that, a third party JAR causing this problem. If I remove that JAR, its running properly. But I need that JAR too. How to get rid of this? Commented Oct 7, 2015 at 12:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.