Ich versuche, einen einfachen JAX-RS-Dienst auf Glassfish 4.0 zu implementieren und zu halten, die folgende Störung erhalten:REST-Servicefehler mit: Ressource ist nicht verfügbar, Glassfish 4.0 JAX-RS 2.0
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.0
Ist Datei setzt Fein Im Glassfish-Server scheint es jedoch so zu sein, dass der Klassenlader seine Aufgabe nicht erfüllt und den Restdienst entsprechend offenlegt. Ich versuche herauszufinden, warum die Klasse nicht richtig lädt. Ich weiß, dass es wahrscheinlich eine einfache Konfigurationsänderung ist, aber ich konnte es nicht finden.
Konfiguration: Glassfish-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!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">
<glassfish-web-app error-url="">
<context-root>/reports</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
REST-Servicecode:
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) {
}
}
Der Krieg mit der eingesetzt wird Root-Kontext von/reports und die URL, die ich verwende, ist :
http://localhost:8080/reports/rest/weeklyStatusReport/run/123
Haben Sie die Web-Service-Klassen nicht irgendwo registriert? Hat der Code auf GlassFish 3 funktioniert? – perissf