0

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

Aurélien Leloup
  • 146
  • 1
  • 12
  • have you tried hitting `http://localhost:1234/rest-example-with-application-1.1.0-SNAPSHOT/rest-prefix/pojo/pojo` instead of `http://localhost:1234/rest-example-with-application-1.1.0-SNAPSHOT/rest-prefix/pojo/`? the last part of the url is the function name i think – MitchBroadhead Mar 21 '18 at 14:33
  • It does not work either. I've added details in my original post. – Aurélien Leloup Mar 21 '18 at 14:46
  • when the server starts the rest interfaces are listed in the log (catalina.log?) which should go to console in your IDE. look for the part where it starts deploying the webapp `-------> /rest-example-with-application-1.1.0-SNAPSHOT `. at the end of that section it lists the interfaces. that should tell you where it is `org.apache.openejb.server.cxf.rs.CxfRsHttpListener logEndpoints` – MitchBroadhead Mar 21 '18 at 15:11
  • The logs you're talking about didn't appear in my console. That's what makes me look into the web profile aspect in details. Thx – Aurélien Leloup Mar 21 '18 at 16:25

1 Answers1

0

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.

Aurélien Leloup
  • 146
  • 1
  • 12