Search code examples
restapache-tomee

Rest Web Service not working on TomEE web profile 1.7.2


I want to add a web service to an already existing web application. This application runs on a specific version of Apache TomEE (apache-tomee-web-profile-1.7.2) and an upgrade is not possible.

I'm trying to deploy this sample application on this TomEE, just to try it. I see no errors in the logs I manage to see the home page of the application : enter image description here

This is the code for the ressource :

@Path("/pojo")
public class SimpleRESTPojo {

  @GET
  public String pojo() {
     return "pojo ok @ " + new Date().toString();
  }
 }

And the code of the rest application :

@ApplicationPath("/rest-prefix")
public class ApplicationConfig extends Application {

 @Override
 public Set<Class<?>> getClasses() {
    return new HashSet<Class<?>>(Arrays.asList(SimpleRESTPojo.class, SimpleRESTEJB.class));
 }


}

So far I've tried : base/rest-prefix/pojo, base/rest-prefix/pojo/pojo, base/pojo all giving me 404 errors

base is the url where I manage to see the home page


Solution

  • I managed to find a solution which I'm quite happy with. Turns out what I wanted to do is pretty much impossible. As mentionned in this other stackoverflow post Web Profile is a subset of Java EE that usually does not contains the required libraries to create a REST WS.

    I ran the Rest Sample application on a TomEE jaxrs version and it works as expected. I then copied the few libs that are included in TomEE-jaxrs and not in TomEE-webprofile into my original server lib folder.