NOT FOUND in the webservice paths

Asked

Viewed 27 times

1

I have a big problem with my webservice. I created CRUD and it worked normally, but new paths with path are not working, I don’t know if when I exported the project when crud was running .war. I tried several types of paths and returns and nothing works, neither in Browser nor in ARC, the only return they give is not found. only what I had implemented before export. Password below the web service class with the commented paths whether they work or not.

package ws;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

import com.google.gson.Gson;

import dao.EventoDAO;
import generator.ReportGenerator;
import modelo.Evento;
import modelo.ReportParam;
import java.sql.SQLException;
import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.PUT;
import javax.ws.rs.core.MediaType;


@Path("Evento")
public class EventoWS {

@Context
private UriInfo context;

public EventoWS(){

}

//Funciona
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getJson(){
    //throw new UnsupportedOperationException();
    return "Web Service da classe evento subido no servidor com sucesso!";
}

//Funciona
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void putJson(String content){
}

//Funciona
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("getEventos")
public String getEventos() throws ClassNotFoundException, SQLException{
    System.out.println("Pediu para gerar a lista");
    Gson gson = new Gson();
    EventoDAO dao = new EventoDAO();
    List<Evento> listaEvento = dao.getEventos();

    return gson.toJson(listaEvento);
}

//funciona
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("insert")
public String inserirEvento(String content){
    Gson gson = new Gson();
    String retorno;
    Evento evento = (Evento) gson.fromJson(content, Evento.class);
    EventoDAO dao = new EventoDAO();
    if (dao.inserirEvento(evento)){
        retorno = "true";
    }
    else{
        retorno = "false";
    }
    return retorno;
}

//não funciona :(
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/RelatorioEventos")
public String getReport(){
    String retorno;
    ReportGenerator generator = new ReportGenerator();
    try {
        generator.reportBuilder();
        retorno = "true";
    } catch (Exception e) {
        retorno = "false";
        e.printStackTrace();
    }
    return retorno; 
}

//funciona
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("update")
public String atualizarEvento(String content){
    Gson gson = new Gson();
    String retorno;
    Evento evento = (Evento) gson.fromJson(content, Evento.class);
    EventoDAO dao = new EventoDAO();
    if (dao.updateEvento(evento)){
        retorno = "true";
    }
    else{
        retorno = "false";
    }
    return retorno;
}

//funciona
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("delete/{id}")
public String deletarEvento(@PathParam("id")int id){
    Gson gson = new Gson();
    String retorno;
    EventoDAO dao = new EventoDAO();
    if (dao.deletarEvento(id)){
        retorno = "true";
    }
    else{
        retorno = "false";
    }
    return gson.toJson(retorno);
}

//funciona
@GET
@Path("Teste")
@Produces(MediaType.TEXT_PLAIN)
public String hello(){
    return "Caminho teste funcionando corretamente";
}

//não funciona
@GET
@Path("Teste2")
@Produces(MediaType.TEXT_PLAIN)
public String hello2(){
    return "Caminho Auth funcionando corretamente";
}
}

I don’t know what to do.

Settings used in the project: Dynamic Web Project, Eclipse neon, Maven, MVC, Connection Localhost, Server wildfly 10.0

if I haven’t made myself clear on something let me know

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.