Thursday 22 June 2017

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;

Problem :

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;


Solution :

getContextPath() was added with Servlet 2.5, does your version of Jetty supports that ? 


Might also want to check that you do not have some older or duplicate version of j2ee around.

Indicates that Jetty 6.1.x supports Servlet 2.5 , make sure you don't have a pre-2.5 servlet version around. If this gets loaded before the 2.5 version, the entire classpath sees only Servlet 2.0 API (the 2.5 doesn't even gets loaded).

so exclude it from the maven pom.xml


Exclusion entry
 <exclusion>
           <artifactId>servlet-api</artifactId>
           <groupId>javax.servlet</groupId>
  </exclusion>

No comments:

Post a Comment

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...