Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-28311

[GSS](7.4.z) Sever throws IllegalStateException when call a handler with the CDI bean invocation in EAP 7.4.19

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.4.21.GA
    • None
    • Web Services
    • None
    • False
    • None
    • False
    • Hide

      Set the application module classloader to TCCL before CDI.current(); in SOAPHandler

      // As a workaround, set TCCL to application module class loader
      ClassLoader old = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
      CDI.current();
      Thread.currentThread().setContextClassLoader(old);
      
      Show
      Set the application module classloader to TCCL before CDI.current(); in SOAPHandler // As a workaround, set TCCL to application module class loader ClassLoader old = Thread .currentThread().getContextClassLoader(); Thread .currentThread().setContextClassLoader( this .getClass().getClassLoader()); CDI.current(); Thread .currentThread().setContextClassLoader(old);
    • Hide

      Steps to reproduce:
      1. deploy attached jaxws-client.war client and jaxws-server.war applications to JBossEAP_7_4_19_HOME/standalone/deployments/
      2. Start JBoss EAP 7.4.19 by JBossEAP_7_4_19_HOME/bin/standalone.sh
      3. curl 127.0.0.1:8080/jaxws-client/call_soap
      4. The WARNING messages are logged in the console. The WARNING is not logged in JBoss EAP 7.4.18.

      Show
      Steps to reproduce: 1. deploy attached jaxws-client.war client and jaxws-server.war applications to JBossEAP_7_4_19_HOME/standalone/deployments/ 2. Start JBoss EAP 7.4.19 by JBossEAP_7_4_19_HOME/bin/standalone.sh 3. curl 127.0.0.1:8080/jaxws-client/call_soap 4. The WARNING messages are logged in the console. The WARNING is not logged in JBoss EAP 7.4.18.

      This issue happens after https://issues.redhat.com/browse/JBWS-4385 is fixed and sever throws IllegalStateException when call a handler with the CDI bean invocation. That cause of this exception is that the thread's context classloader in SOAP handler has changed from application module class loader to org.jboss.ws.common.utils.DelegateClassLoader in JBoss EAP 7.4.19. It works until JBoss EAP 7.4.18, so it's kind of compatibility issue.

      15:36:18,744 WARNING [org.apache.cxf.jaxws.handler.HandlerChainInvoker] (default task-2) Handler execution raised a runtime exception.: java.lang.IllegalStateException: WFLYWELD0039: Singleton not set for org.jboss.ws.common.utils.DelegateClassLoader@49134e6f. This means that you are trying to access a weld deployment with a Thread Context ClassLoader that is not associated with the deployment.
      	at org.jboss.as.weld@7.4.19.GA-redhat-00002//org.jboss.as.weld.services.ModuleGroupSingletonProvider$TCCLSingleton.get(ModuleGroupSingletonProvider.java:77)
      	at org.jboss.as.weld@7.4.19.GA-redhat-00002//org.jboss.as.weld.services.ModuleGroupSingletonProvider$TCCLSingleton.get(ModuleGroupSingletonProvider.java:134)
      	at org.jboss.weld.core@3.1.10.Final-redhat-00001//org.jboss.weld.Container.instance(Container.java:57)
      	at org.jboss.as.weld@7.4.19.GA-redhat-00002//org.jboss.as.weld.WeldProvider.getCDI(WeldProvider.java:69)
      	at javax.enterprise.api@2.0.2.redhat-00002//javax.enterprise.inject.spi.CDI.lambda$getCDIProvider$0(CDI.java:87)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
      	at java.base/java.util.TreeMap$KeySpliterator.tryAdvance(TreeMap.java:2763)
      	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
      	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
      	at javax.enterprise.api@2.0.2.redhat-00002//javax.enterprise.inject.spi.CDI.getCDIProvider(CDI.java:88)
      	at javax.enterprise.api@2.0.2.redhat-00002//javax.enterprise.inject.spi.CDI.current(CDI.java:64)
      	at deployment.jaxws-server.war//org.example.soap.DelegateBean.<init>(DelegateBean.java:8)
      	at deployment.jaxws-server.war//org.example.soap.LoggingHandler.handleMessage(LoggingHandler.java:17)
      

      The soap handler:

      public class LoggingHandler implements SOAPHandler<SOAPMessageContext> {
          @Override
          public boolean handleMessage(SOAPMessageContext soapMessageContext) {
              boolean isOutBound = (boolean) 
              soapMessageContext.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY);
              if (isOutBound) {
                  System.out.println("### TCCL in SOAPHandler = " + Thread.currentThread().getContextClassLoader().toString());
                  new DelegateBean();    // Call CDI.current() when instantiating
              }
             return true;
          } 
      }
      

      DelegateBean.java

      @Dependent
      public class DelegateBean {
          EmptyBean logic = CDI.current().select(EmptyBean.class).get();
      } 
      

              rhn-support-pesilva Pedro Silva
              rhn-support-nagetsum Norito Agetsuma
              Jim Ma
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: