Uploaded image for project: 'Red Hat Build of Apache Camel for Quarkus'
  1. Red Hat Build of Apache Camel for Quarkus
  2. CEQ-6926

Camel-cxf DefaultCxfBinding throws ClassCastException when invoking "extractInvocationContextFromCamel" method

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • Moderate
    • 0

      We have a simple camel-cxf route:

      from("cxf:bean:cxfServerBean")
                      .setHeader(Exchange.HTTP_METHOD, constant(HttpPost.METHOD_NAME))
                      .setHeader(Exchange.CONTENT_TYPE, constant("application/xml"))
                      .removeHeader(Exchange.HTTP_PATH)
                      .to("http://localhost:8081/hello?bridgeEndpoint=true");
      

      However, it throws a ClassCastException:

      java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')
      	at org.apache.camel.component.cxf.jaxws.DefaultCxfBinding.extractInvocationContextFromCamel(DefaultCxfBinding.java:598)
      	at org.apache.camel.component.cxf.jaxws.DefaultCxfBinding.populateCxfHeaderFromCamelExchangeBeforeCheckError(DefaultCxfBinding.java:396)
      	at org.apache.camel.component.cxf.jaxws.CxfConsumer$CxfConsumerInvoker.setResponseBack(CxfConsumer.java:321)
      	at org.apache.camel.component.cxf.jaxws.CxfConsumer$CxfConsumerInvoker.syncInvoke(CxfConsumer.java:248)
      	at org.apache.camel.component.cxf.jaxws.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:164)
      ......
      

      The "ResponseContext" header was populated in the camel exchange IN message after invoking against the other camel endpoint "http://localhost:8081/hello?bridgeEndpoint=true". The method "extractInvocationContextFromCamel" of the DefaultCxfBinding class was also called. Because the "ResponseContext" header was initialised as an ArrayList type, therefore, the exception was thrown at the line #598 in the DefaultCxfBinding.java class:
      https://github.com/apache/camel/blob/camel-3.18.x/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/DefaultCxfBinding.java#L598

            yfang@redhat.com Freeman(Yue) Fang
            rhn-support-qluo Joe Luo
            Lukas Lowinger Lukas Lowinger
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: