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

[GSS](7.4.z) Sever throws IllegalStateException when call a getHeaders/handleFault/close in soap handler with the CDI bean invocation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 7.4.22.GA
    • 7.4.20.GA
    • 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);

      When call a getHeaders/handleFault/close method in soap handler with the CDI bean invocation, IllegalStateException has been thrown since JBoss EAP 7.4.19. It works until JBoss EAP 7.4.18. This issue is essentially the same as JBEAP-28310. This issue asks to fix thread context classloader during execution of getHeaders/handleFault/close methods. This behavior may be a regression issue.

      public class LoggingHandler implements SOAPHandler<SOAPMessageContext> {
          private static final Logger LOG = LoggerFactory.getLogger(LoggingHandler.class);
      
          @Override
          public boolean handleMessage(SOAPMessageContext soapMessageContext) {
              boolean isOutBound = (boolean) soapMessageContext.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY);
              if (isOutBound) {
                  LOG.info("### TCCL in SOAPHandler.handleMessage = " + Thread.currentThread().getContextClassLoader().toString());
                  new DelegateBean();   // it works 7.4.0 to 7.4.18 and 7.4.21+
      
                  // As a workaround, set TCCL to application module class loader for JBEAP-28311, fixed in JBoss EAP 7.4.21
      //            ClassLoader old = Thread.currentThread().getContextClassLoader();
      //            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
      //            new DelegateBean();
      //            Thread.currentThread().setContextClassLoader(old);
              }
              return true;
          }
      
          @Override
          public Set<QName> getHeaders() {
              LOG.info("### TCCL in SOAPHandler.getHeaders = " + Thread.currentThread().getContextClassLoader().toString());
              new DelegateBean();  // In 7.4.19+,  java.lang.IllegalStateException: Unable to access CDI 
               // the same workaround for JBEAP-28310 is available
      //        ClassLoader old = Thread.currentThread().getContextClassLoader();
      //        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
      //        new DelegateBean();
      //        Thread.currentThread().setContextClassLoader(old);
      
              return Collections.emptySet();
          }
      
          @Override
          public boolean handleFault(SOAPMessageContext soapMessageContext) {
              LOG.info("### TCCL in SOAPHandler.handleFault = " + Thread.currentThread().getContextClassLoader().toString());
              new DelegateBean();  // In 7.4.19+,  java.lang.IllegalStateException: Unable to access CDI 
          }
      
          @Override
          public void close(MessageContext messageContext) {
              LOG.info("### TCCL in SOAPHandler.close = " + Thread.currentThread().getContextClassLoader().toString());
              new DelegateBean();  // In 7.4.19+,  java.lang.IllegalStateException: Unable to access CDI 
          }
      }
      

      DelegateBean.java

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

              jboss-set_jira JBoss SET
              rhn-support-nagetsum Norito Agetsuma
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: