Note that there are some explanatory texts on larger screens.

plurals
  1. PORestful JAX-RS Server Error
    primarykey
    data
    text
    <p>I have problems using Restful Webservices using the Jersey implementation. In the documentation it is written that i should download this : <a href="https://jersey.java.net/download.html" rel="nofollow">Jersey JAX-RS 2.0 RI bundle</a>, unzip it and add the jars to my WEB-INF/lib folder. These jars are:</p> <ul> <li>jersey-client</li> <li>jersey-common</li> <li>jersey-container-servlet</li> <li>jersey-container-servlet-core</li> <li>jersey-server</li> </ul> <p>If i do so i always get the following exception:</p> <pre><code>java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer </code></pre> <p>After some researching i found out that i should add jersey-servlet-1.12.jar instead of adding the jars from the download source posted above. So I did it. I added this to my web.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;servlet&gt; &lt;servlet-name&gt;JAX-RS Servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;JAX-RS Servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/jaxrs/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>And i implemented a small test-class:</p> <pre class="lang-java prettyprint-override"><code>import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import de.hof.university.spj.model.Movie; @Path("/test") public class Test { @GET @Produces("application/json; charset=UTF-8") public List&lt;Movie&gt; getMovieList() { EntityManagerFactory factory = Persistence.createEntityManagerFactory("SPJUnit"); EntityManager em = factory.createEntityManager(); TypedQuery&lt;Movie&gt; query = em.createQuery("Select m FROM Movie m WHERE m.movieID = 4204", Movie.class); return query.getResultList(); } } </code></pre> <p>When i now call <code>http://localhost:8080/MyApp/jaxrs/test</code> i get this error:</p> <pre><code>HTTP Status 500 - Internal Server Error. The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. </code></pre> <p>I dont know how to do use the jersey implementation correctly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload