title: How to integrate jersey rest api along with springs mvc
body: <p>Iam new to jersey rest services, i tried adding jersey jax-rs related dependencies in maven pom.xml and also servlet configuration in web.xml.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;!-- rest service mapping --&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
        &lt;param-value&gt;com.skoruz.rest&lt;/param-value&gt;
      &lt;/init-param&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>pom.xml dependencies are :</p>
  
  <pre><code>&lt;!-- jax-rs(jersey) --&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
   &lt;/dependency&gt;
  </code></pre>
  
  <p>i have a simple java class with @path annotated.</p>
  
  <pre><code>package com.skoruz.rest;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("/hello")
  public class DemoRest {
  
        @GET
        @Path("/getWelcomeText")
        @Produces(MediaType.TEXT_PLAIN)
        public String sayPlainTextHello(){
            return "Hello Welcome back";
        }
  
  }
  </code></pre>
  
  <p>And when i deploy this jar to glassfish and access the url its throwing me this exception</p>
  
  <pre><code>http://localhost:8080/SpringMVCHibernate/rest/hello/getWelcomeText
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/MnWHC.jpg" alt="enter image description here"></p>
  
  <p>It would be great if someone help me out in this, stuck in this from long time.</p>