[jboss-jira] [JBoss JIRA] (WFLY-11538) Opentracing - SmallRye - IllegalStateException

Alessandro Moscatelli (Jira) issues at jboss.org
Thu Dec 20 08:41:05 EST 2018


Alessandro Moscatelli created WFLY-11538:
--------------------------------------------

             Summary: Opentracing - SmallRye - IllegalStateException
                 Key: WFLY-11538
                 URL: https://issues.jboss.org/browse/WFLY-11538
             Project: WildFly
          Issue Type: Bug
          Components: MP OpenTracing
    Affects Versions: 15.0.0.Final
            Reporter: Alessandro Moscatelli
             Fix For: 16.0.0.Beta1


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:
https://github.com/wildfly/wildfly/blob/master/microprofile/opentracing-smallrye/src/main/java/org/wildfly/microprofile/opentracing/smallrye/TracerProducer.java
https://github.com/smallrye/smallrye-opentracing/blob/1.1.1/implementation/src/main/java/io/smallrye/opentracing/SmallRyeTracingCDIInterceptor.java

Those are delivered with Wildfly 15 out of the box in:
smallrye-opentracing-1.1.1.jar
wildfly-microprofile-opentracing-smallrye-15.0.0.Final.jar

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.

My suggestion:

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.

This should be done by:
https://github.com/wildfly/wildfly/blob/master/microprofile/opentracing-smallrye/src/main/java/org/wildfly/microprofile/opentracing/smallrye/TracerInitializer.java

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:
https://github.com/opentracing-contrib/java-interceptors/blob/master/src/main/java/io/opentracing/contrib/interceptors/OpenTracingInterceptor.java

Also be aware that what I am suggesting is similar to the same behavior adopted in opentracing java-cdi (not yet integrated in Wildfly):
https://github.com/opentracing-contrib/java-cdi/blob/master/opentracing-cdi/src/main/java/io/opentracing/contrib/cdi/internal/TracerInitializer.java
https://github.com/opentracing-contrib/java-cdi/blob/master/opentracing-cdi/src/main/java/io/opentracing/contrib/cdi/internal/TracerProducer.java

Also notice that opentracing java-ejb (not yet integrated in Wildfly) also requires a registration in GlobalTracing:
https://github.com/opentracing-contrib/java-ejb/blob/master/opentracing-ejb/src/main/java/io/opentracing/contrib/ejb/OpenTracingInterceptor.java

Thank you for your support.



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list