Caused by: org.jboss.weld.exceptions.IllegalStateException:
WELD-000713: Unable to inject ServletContext. None is associated with ModuleClassLoader for Module
The problem is the interaction between these two:
Those are delivered with Wildfly 15 out of the box in:
I have an EAR with a EJB jar, WAR and a common JAR library.
To reproduce the issue I created a Stateless EJB in the EJB jar and then I injected a Traced ApplicationScoped bean from the JAR library in the Stateless EJB.
SmallRyeTracingCDIInterceptor triggers and it requires an Injected Tracer.
TracerProducer triggers and it has no active ServletContext and this leads to the error above.
I don't think the ServletContext is a really good place to store the Tracer.
I think that the Tracer created by Wildfly should be registered into the GlobalTracer.
If you don't want Wildfly to register automatically its Tracer in the GlobalTracer, this behavior could be disabled in the subsystem.
Also please be aware that SmallRyeTracingCDIInterceptor is dismissed in the last versions of the library and SmallRye states (https://github.com/smallrye/smallrye-opentracing) it has been replaced with:
Also be aware that what I am suggesting is similar to the same behavior adopted in opentracing java-cdi (not yet integrated in Wildfly):
Also notice that opentracing java-ejb (not yet integrated in Wildfly) also requires a registration in GlobalTracing:
Thank you for your support.