Ich habe einen Webservice mit Jersey in einem dynamischen Webprojekt erstellt. Jetzt möchte ich es bauen, ohne Maven zu benutzen (unser Professor wird uns Maven nicht benutzen lassen). Ich führe das Projekt auf einem Tomcat 9.0 Server. Es läuft perfekt, aber wenn ich auf localhost:8080/agendarest/contactos
zugreifen, bekomme ich einen 404 Fehler.Dynamisches Webprojekt ohne Maven erstellen
Service:
@Path("/contactos")
public class ContactoService {
private static final long serialVersionUID = 1L;
@GET
@Produces("application/json")
public Response getUsers() throws JSONException{
List<Contacto> contactos = new ArrayList<>();
contactos.add(new Contacto("pedro", 3434661825L));
return Response.status(200).entity(contactos.toString()).build();
}
}
web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>agendarest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Hat Ihr Professor auch Gradle nicht zulassen? – azurefrog
Ja, er sagte uns, dass wir es ohne irgendein Framework ausführen könnten, aber nicht wie ... –
funktioniert localhost: 8080/agendarest? läuft deine Web-App? ist die web.xml im Ordner WEB-INF? – Yussef