1

I try to deploy a REST web service on my tomee. i use apache-tomee-plus-8.0.6 with JDK 15

I create a web application called test I create a class like this:

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/test")
public class WebServiceApplication extends Application {
        @Override
        public Set<Class<?>> getClasses() {
                return new HashSet<Class<?>>(Arrays.asList(QueueContentWebService.class));
        }
}

And another like this:

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/queuecontent")
public class QueueContentWebService {
       
    @POST
    public Response getContent() {
    return Response.status(200).entity("getContent is called").build();
    }
}

Then i try this URL, with a browser and with postman in POST: http://localhost:8080/test/test/queuecontent/

I only get 404 response... It seems that my web service is not deployed. Anybody can help me by saying what is missing?

Ignolito
  • 11
  • 1
  • Do you deploy at all? Whats the process? I would expect you package your application in a war file which then gets deployed into your TomEE application server (which also needs to run). – Kekzpanda Sep 16 '21 at 12:41
  • I didn't use a war. I just put the 2 compiled class in the folder /webapps/test/WEB-INF/classes, and start the tomee. – Ignolito Sep 17 '21 at 13:08
  • SFLR. Although you do no need a war-file, and manually deploying an application is possible, it is absolutely not recommended to do so. There are a lot of peculiarities of Tomcat (https://tomcat.apache.org/tomcat-3.3-doc/appdev/deployment.html) and TomEE (https://tomee.apache.org/deploying-in-tomee.html) that need to be considered before your application will run. A war file creation and deployment process will fix all of that for you. TBH I am not familiar with deploying class files directly in Tomcat. – Kekzpanda Oct 07 '21 at 15:18

0 Answers0