2

I have made a rest service, and now I am trying to call the same from the client end. For that I have made different dynamic web project and add all jersey jars to the WEB-INF/lib folder. I am using Jearsy(jaxrs-ri-2.23.2) version.

Now when I run my application it give me the below error as the main root cause.

Servlet.service() for servlet [controller.DemoServlet] in context with path [/TestingRestClient] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties

Also after scrolling upward the console I found below error too:

Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/glassfish/jersey/client/ClientConfig

I have searched both the errors, for the first error I have applied changes to my web.xml file. Below are the changes:

<servlet>
<servlet-name>DemoServlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
     <param-name>jersey.config.server.provider.packages</param-name>
     <param-value>controller</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>

<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>DemoServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

"controller" is my package where DemoServlet class is present.And I am using the same url pattern. Is the above web.xml should be used in server end only, I have used in both ends but give same result. And for the second error, I found there must be Class which compiler or server is not able to find. So I check again all jar files in my lib folder, they all present ; then I add all the jar files to class build path. But still I am getting the same error. I need help. I don't know what should I do next.

Neha
  • 91
  • 1
  • 2
  • 12
  • http://stackoverflow.com/questions/23521647/java-lang-noclassdeffounderror-error-when-running-my-project – Alex Punnen Oct 27 '16 at 04:49
  • Hey thanks, I think I am also doing the same. I think I am going to take some classes to learn making webservices. :) – Neha Nov 07 '16 at 20:27
  • Possible duplicate of [java.lang.NoClassDefFoundError error when running my project](https://stackoverflow.com/questions/23521647/java-lang-noclassdeffounderror-error-when-running-my-project) – rogerdpack Oct 12 '17 at 16:10

0 Answers0