简体   繁体   中英

Getting a 404 not found when trying to call url with postman

I was working on my old project with maven, trying to implement a rest project, everything worked perfectly, and suddenly, when I tried to recall the url in postman, I keep getting "404 not found". I don't know what really happened, because everything worked perfectly !!

what I did, is in EJB folder I created three packages one for entities one for the interface and the other for the service then in the webproject I created a package that contains two files, one for the webservice and the other for the rest activator !

this is the webservice file:

package crm.webservices;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import crm.entities.Product;
import crm.impl.ProductImpl;




@Path("products")


public class ProductWs   {

    @EJB
    ProductImpl productImpl;
      private final String status = "{\"status\":\"ok\"}";


    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("allproducts")
    public List<Product> getProducts()
    {
        return productImpl.allProducts();
    }
}

the second file:

package crm.webservices;

import javax.ejb.Stateless;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("api")
@Stateless
public class RestActivator extends Application {

}

I'm new with Maven, and I have no idea what really happened because as I mentioned, eveything was okey. anyone can help me, I'm stuck here for about 3 hours !!

You have your application path defined as:

@ApplicationPath("api")

And you're not using it on your cURL, it should be:

http://localhost:9080/projetcrm-web/api/products/allproducts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM