0 Replies Latest reply on Sep 16, 2018 5:48 PM by Ralph Soika

    javax.ws.rs.client.ClientBuilder not working from a EJB Timer Service?

    Ralph Soika Apprentice

      Hi,

       

      today I asked a question in the Wildfly forum concerning a RestEasy Jax-rs Client problem.

      See: https://developer.jboss.org/thread/278754

      I am not sure if this place is the better/right place to ask the question? So I will try to describe the problem:

       

      I am running a EJB timer service in Wildfly 13. In this EJB I want to connect to a Rest Service via a  javax.ws.rs.client.Client. So the implementation is RestEasy. But when I try to get a new Client during the @timout method:

       

       

      @Timeout
      void onTimeout(javax.ejb.Timer timer) throws Exception {
      ...
      Client client = ClientBuilder.newClient();  
      ...

       

       

      I got the  exception:

       

      org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.servlet.ServletContext  

       

      In the same stateless EJB this works fine in a method annotated with @Path:

       

      @GET
      @Path("/")
      public String ping() {
      Client client = ClientBuilder.newClient();
      ....
      }

       

      How can I solve the missing javax.servlet.ServletContext? Why is a java ServletContext necessary to build a Jax-rs client? The Jersey Implementation does not show this behavior.

       

      Thanks for any help

       

      ===

      Ralph