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

[GSS](8.0.z) JBWS-4430 - Sever throws IllegalStateException when call a handler with the CDI bean invocation in EAP 8.0.3 or later

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 8.0 Update 5
    • 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.3.1_HOME/standalone/deployments/
      2. Start JBoss EAP 8.0.3.1 by JBossEAP_8.0.3.1_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.

      Show
      Steps to reproduce: 1. deploy attached jaxws-client.war client and jaxws-server.war applications to JBossEAP_8.0.3.1_HOME/standalone/deployments/ 2. Start JBoss EAP 8.0.3.1 by JBossEAP_8.0.3.1_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.

      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 JAXPDelegateClassLoader in JBoss EAP 8.0.3+. It works until JBoss EAP 8.0.2.1, so it's kind of compatibility issue.

      15:35:43,181 WARNING [org.apache.cxf.jaxws.handler.HandlerChainInvoker] (default task-2) Handler execution raised a runtime exception.: java.lang.IllegalStateException: Unable to access CDI at jakarta.enterprise.api@4.0.1//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//jakarta.enterprise.inject.spi.CDI.current(CDI.java:65) 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) at deployment.jaxws-server.war//org.example.soap.LoggingHandler.handleMessage(LoggingHandler.java:11) at org.apache.cxf.impl//org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeHandleMessage(HandlerChainInvoker.java:355) at org.apache.cxf.impl//org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeHandlerChain(HandlerChainInvoker.java:254) at org.apache.cxf.impl//org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeProtocolHandlers(HandlerChainInvoker.java:131)
      

      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-engineering-ema Jim Ma
            rhn-support-nagetsum Norito Agetsuma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: