NullpointerException in REST / RESTEasy client within Wildfly 26

135 views Asked by At

I have a REST client using RESTEasy 4.7.7 running in Wildfly 26.1.3.Final (using Java 17), that fails due to a NullpointerException. Outside of Wildfly everything works fine.

The client looks like this:

Client restClient = javax.ws.rs.client.ClientBuilder.newClient();
WebTarget webTarget = restClient.target(baseUri + "/api/Login");

String jsonQuery = "<some-real-json>";

String token = null;
try {
    Response response = webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).accept(MIMETYPE_JSON).post(javax.ws.rs.client.Entity.entity(jsonQuery, javax.ws.rs.core.MediaType.APPLICATION_JSON));
    String returnValue = response.readEntity(String.class);
    if (response.getStatus() != 200) {
        log.error("Could not authenticate with ePost API: " + returnValue + " [" + response.getStatus() + "]");
        throw new EpostException("Could not authenticate with ePost API: " + returnValue + " [" + response.getStatus() + "]");
    }

    Object jsonOutput = Jsoner.deserialize(returnValue);
    // output processing

} catch (Exception ex) {
    log.error("Could not authenticate with ePost API", ex);
    throw new EpostException(ex.getMessage(), ex);
} finally {
    restClient.close();
}
return token;

Here's the stacktrace I am getting:

Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Constructor.getParameterTypes()" because "constructor" is null
    at [email protected]//org.jboss.resteasy.core.ConstructorInjectorImpl.<init>(ConstructorInjectorImpl.java:55)
    at [email protected]//org.jboss.resteasy.core.InjectorFactoryImpl.createConstructor(InjectorFactoryImpl.java:61)
    at [email protected]//org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.injectedInstance(ResteasyProviderFactoryImpl.java:1398)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistryImpl.java:150)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistryImpl.java:168)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistryImpl.java:183)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistryImpl.java:193)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistryImpl.java:138)
    at [email protected]//org.jboss.resteasy.core.interception.jaxrs.JaxrsInterceptorRegistryImpl.postMatch(JaxrsInterceptorRegistryImpl.java:288)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration.getRequestFilters(ClientConfiguration.java:120)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.getRequestFilters(ClientInvocation.java:460)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.filterRequest(ClientInvocation.java:759)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:491)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:69)
    at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:226)
    at deployment.j-lawyer-server.ear//com.jdimension.jlawyer.epost.EpostAPI.login(EpostAPI.java:782)

Any ideas what could be wrong here? It happens when calling the "post" method. I have a feeling it has something to do with instantiating RESTEasy, but as I am not directly instantiating it myself, I do not know how to tackle this.

Thanks!

0

There are 0 answers