Error 404 apache Tomcat

1

I'm new to web services, however lately I've gotten to develop my own, however I can not even do a hello world due to an error that Tomcat is returning me, it just does not find the URL, can you help me?

package Login;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;
import javax.ws.rs.core.MediaType;

/**
 * REST Web Service
 *
 * @author Matheus
 */
@Path("/Teste")
public class Teste {

    @Context
    private UriInfo context;

    /**
     * Creates a new instance of Teste
     */
    public Teste() {
    }

    /**
     * Retrieves representation of an instance of Login.Teste
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("text/plain")
    public String getText() {
        //TODO return proper representation object
        return "ola";
    }

    /**
     * PUT method for updating or creating an instance of Teste
     * @param content representation for the resource
     */
    @PUT
    @Consumes(MediaType.TEXT_PLAIN)
    public void putText(String content) {
    }
}

The home URL is link , this page is easily found, however when I go to the URL link which is to return a" hello "it simply returns a page 404 not found error.

    
asked by anonymous 28.02.2018 / 22:43

1 answer

1

You need to have a class that sets up the application.

Put the following code:

package login;

import javax.ws.rs.core.Application;

@javax.ws.rs.ApplicationPath("api")
public class ApplicationConfig extends Application {}

With this worked smoothly here on Glassfish.

The path to the page will be:

http://localhost:8080/Projeto/api/Teste

Another important thing, package names should start with a lowercase letter, so I switched to login .

    
01.03.2018 / 19:01