0

In a JEE app deployed in Wildfly 18.0.1.Final with OpenJDK 64-Bit Server VM 11.0.15+9-LTS, I run into a ClassNotFoundException on java.net.http.HttpResponse (actually, one of the dependency is using it, and fails on java.net.http.HttpResponse$BodyHandler but I tried using java.net.http.HttpResponse directly in my code and ran into the same issue).

I tried to add the java.net.http module in WEB-INF/jboss-deployment-structure.xml in the WAR but it does not change a thing.

<jboss-deployment-structure>
  <module name="deployment.java.net.http" />
</jboss-deployment-structure>

The stacktrace ends with:

Caused by: java.lang.NoClassDefFoundError: java/net/http/HttpResponse$BodyHandler        at deployment.orbis-events-4u.war//io.apicurio.registry.rest.client.impl.RegistryClientImpl.<init>(RegistryClientImpl.java:67)
        at deployment.orbis-events-4u.war//io.apicurio.registry.rest.client.impl.RegistryClientImpl.<init>(RegistryClientImpl.java:63)
        at deployment.orbis-events-4u.war//io.apicurio.registry.rest.client.RegistryClientFactory.create(RegistryClientFactory.java:34)
        at deployment.orbis-events-4u.war//io.apicurio.registry.serde.AbstractSchemaResolver.configure(AbstractSchemaResolver.java:84)
        at deployment.orbis-events-4u.war//io.apicurio.registry.serde.DefaultSchemaResolver.configure(DefaultSchemaResolver.java:59)
        at deployment.orbis-events-4u.war//io.apicurio.registry.serde.SchemaResolverConfigurer.configure(SchemaResolverConfigurer.java:75)
        at deployment.orbis-events-4u.war//io.apicurio.registry.serde.AbstractKafkaSerDe.configure(AbstractKafkaSerDe.java:68)
        at deployment.orbis-events-4u.war//io.apicurio.registry.serde.avro.AvroKafkaSerializer.configure(AvroKafkaSerializer.java:81)
        at deployment.orbis-events-4u.war//org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:375)
        ... 62 more
Caused by: java.lang.ClassNotFoundException: java.net.http.HttpResponse$BodyHandler from [Module "deployment.orbis-events-4u.war" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
        ... 71 more

I'm very surprised that access to java.net.http module is not available out of the box. Is there something I can do in the configuration of my app? Is it a known WF issue?

Progman
  • 16,827
  • 6
  • 33
  • 48
zapho
  • 85
  • 9
  • 2
    This seem to be the issue with the `java.se` modules not correctly getting all components it requires ([WFLY-12290](https://issues.redhat.com/browse/WFLY-12290)), which was fixed in WildFly 19 and jboss-modules 1.9.2/1.8.10 ([MODULES-392](https://issues.redhat.com/browse/MODULES-392)). – cam-rod Oct 21 '22 at 15:51
  • 1
    It should be possible to add a module dependency on `java.net.http` explicitly through `jboss-deployment-structure.xml`, I think. (Didn't try though :-) ) – Ladicek Oct 27 '22 at 07:24
  • Thanks @Ladicek. I tried this but it did not work. – zapho Nov 15 '22 at 13:51
  • Well actually, I got the `jboss-deployment-structure.xml` content wrong. Thanks @Ladicek for getting me back on the right track. I will post a response this issue. – zapho Nov 15 '22 at 15:06

1 Answers1

0

The content of jboss-deployment-structure.xml I was using is incorrect.

Issue is solved with the following content:

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="java.net.http"/>
    </dependencies>
</deployment>
zapho
  • 85
  • 9