Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-11538

Opentracing - SmallRye - IllegalStateException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 15.0.0.Final
    • MP OpenTracing
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              jaslee@redhat.com Jason Lee
              alessandro.moscatelli@live.com Alessandro Moscatelli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: