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

[GSS](8.0.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
    • None
    • 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_8.0.5_HOME/standalone/deployments/
      2. Start JBoss EAP 8.0.5 by JBossEAP_8.0.5_HOME/bin/standalone.sh
      3. curl 127.0.0.1:8080/jaxws-client/call_soap
      4. The following WARNING messages are logged in the console. The WARNING is not logged in JBoss EAP 8.0.2.1.

      2024-12-25 11:23:59,951 INFO  [com.redhat.gss.example.soap.LoggingHandler] (default task-2) ### TCCL in SOAPHandler.getHeaders = org.jboss.wsf.stack.cxf.JAXPDelegateClassLoader@69871fb7
      2024-12-25 11:23:59,954 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-2) Interceptor for {http://soap.example.gss.redhat.com/}EchoWebServiceService has thrown exception, unwinding now: java.lang.IllegalStateException: Unable to access CDI
              at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.lambda$getCDIProvider$0(CDI.java:98)
              at java.base/java.util.Optional.orElseThrow(Optional.java:403)
              at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.getCDIProvider(CDI.java:98)
              at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.current(CDI.java:65)
              at deployment.jaxws-server.war//com.redhat.gss.example.soap.DelegateBean.<init>(DelegateBean.java:8)
              at deployment.jaxws-server.war//com.redhat.gss.example.soap.LoggingHandler.getHeaders(LoggingHandler.java:35)
              at org.apache.cxf.impl//org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.getUnderstoodHeaders(SOAPHandlerInterceptor.java:96)
              ....
      
      Show
      Steps to reproduce: 1. deploy attached jaxws-client.war client and jaxws-server.war applications to JBossEAP_8.0.5_HOME/standalone/deployments/ 2. Start JBoss EAP 8.0.5 by JBossEAP_8.0.5_HOME/bin/standalone.sh 3. curl 127.0.0.1:8080/jaxws-client/call_soap 4. The following WARNING messages are logged in the console. The WARNING is not logged in JBoss EAP 8.0.2.1. 2024-12-25 11:23:59,951 INFO [com.redhat.gss.example.soap.LoggingHandler] (default task-2) ### TCCL in SOAPHandler.getHeaders = org.jboss.wsf.stack.cxf.JAXPDelegateClassLoader@69871fb7 2024-12-25 11:23:59,954 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-2) Interceptor for {http://soap.example.gss.redhat.com/}EchoWebServiceService has thrown exception, unwinding now: java.lang.IllegalStateException: Unable to access CDI at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.lambda$getCDIProvider$0(CDI.java:98) at java.base/java.util.Optional.orElseThrow(Optional.java:403) at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.getCDIProvider(CDI.java:98) at jakarta.enterprise.api@4.0.1.redhat-00001//jakarta.enterprise.inject.spi.CDI.current(CDI.java:65) at deployment.jaxws-server.war//com.redhat.gss.example.soap.DelegateBean.<init>(DelegateBean.java:8) at deployment.jaxws-server.war//com.redhat.gss.example.soap.LoggingHandler.getHeaders(LoggingHandler.java:35) at org.apache.cxf.impl//org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.getUnderstoodHeaders(SOAPHandlerInterceptor.java:96) ....

      When call a getHeaders/handleFault/close method in soap handler with the CDI bean invocation, IllegalStateException has been thrown since JBoss EAP 8.0.3. It works until JBoss EAP 8.0.2. 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 8.0.0 to 8.0.2.1 and 8.0.5+
      
                  // As a workaround, set TCCL to application module class loader for JBEAP-28310, fixed in JBoss EAP 8.0.5
      //            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 8.0.3+, 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 8.0.3+, 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 8.0.3+, 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: