Note that there are some explanatory texts on larger screens.

plurals
  1. POREST Service errors with: resource is not available Glassfish 4.0 JAX-RS 2.0
    primarykey
    data
    text
    <p>I am trying to deploy a simple JAX-RS service on Glassfish 4.0 and keep getting the following error:</p> <pre><code>HTTP Status 404 - Not Found type Status report messageNot Found descriptionThe requested resource is not available. GlassFish Server Open Source Edition 4.0 </code></pre> <p>War file deploys fine in Glassfish server however it appears the class loader is not doing its job and exposing the rest service appropriately. I am trying to figure out why class is not loading appropriately. I know it is probably a simple configuration change however I have not been able to find it.</p> <p><strong>Configuration:</strong> glassfish-web.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"&gt; &lt;glassfish-web-app error-url=""&gt; &lt;context-root&gt;/reports&lt;/context-root&gt; &lt;class-loader delegate="true"/&gt; &lt;jsp-config&gt; &lt;property name="keepgenerated" value="true"&gt; &lt;description&gt;Keep a copy of the generated servlet class' java code.&lt;/description&gt; &lt;/property&gt; &lt;/jsp-config&gt; &lt;/glassfish-web-app&gt; </code></pre> <p>web.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="3.0" 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_3_0.xsd"&gt; &lt;servlet&gt; &lt;servlet-name&gt;Jersey&lt;/servlet-name&gt; &lt;servlet-class&gt;org.glassfish.jersey.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;Jersey&lt;/servlet-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;session-config&gt; &lt;session-timeout&gt;30&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;/web-app&gt; </code></pre> <p>REST Service code:</p> <pre><code>package com.esa.report.rest.service; import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; import javax.ws.rs.PathParam; import javax.ws.rs.Consumes; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.enterprise.context.RequestScoped; import javax.ws.rs.core.MediaType; @Path("weeklyStatusReport") @RequestScoped public class WeeklyStatusReportService { @Context private UriInfo context; public WeeklyStatusReportService() { } @GET @Path("run/{esaId}") @Produces({MediaType.APPLICATION_XHTML_XML}) public String runReport(@PathParam("esaId") String esaId){ return("Hello esaId: "+esaId); } @GET @Produces("text/html") public String getHtml() { return("hello this is the weekly status report"); } @PUT @Consumes("text/html") public void putHtml(String content) { } } </code></pre> <p>The war is deployed with the root context of /reports and the url I am using is:</p> <pre><code>http://localhost:8080/reports/rest/weeklyStatusReport/run/123 </code></pre>
    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.
 

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