1

I have one WebService installed on JBOSS EAP 6.2. Problem appears when i want to fetch SOAP headers.

Code, where exception is raised:

 ArrayList<SoapHeader> hl = (ArrayList<SoapHeader>) wsctx.getMessageContext().get("org.apache.cxf.headers.Header.list");
    String username = "";
    String password = "";

    for (int i = 0; i < hl.size(); i++) { //for(SoapHeader header : hl) gives this same exception
        SoapHeader header = hl.get(i);
        //here is fetching data from this header. Not important to this case.
    }

I know it isn't really pretty, but i really interested in fetching header and exception raised percisely in this method:

hl.get(i)

And message of exception is:

 org.apache.cxf.binding.soap.SoapHeader cannot be cast to org.apache.cxf.binding.soap.SoapHeader

At first i thought about wrong version in my Maven's POM file so:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-bindings-soap</artifactId>
        <version>2.4.2</version>
    </dependency>

But it work good i think.

So my question: how to avoid it? Can anyone help me? Thanks

Dawid Pura
  • 991
  • 9
  • 32

2 Answers2

2

There could be indirect dependency. One of your modules or libraries could also have dependency org.apache.cxf.

Try to figure out whether there are multiple versions. The simplest way is to check all the target dirs and find all the jars. Then compare versions and exclude incorrect ones

  <exclusions>
    <exclusion>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-bindings-soap</artifactId>
      <version>2.4.2</version>
    </exclusion>
  </exclusions>

Also it is possible that JBoss somehow also has the library.

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • I can't find correct one version. I looked into https://access.redhat.com/site/articles/112673 but there is only specified JBoss WS_CXF. Maybe i should use it instead of original apache's library? – Dawid Pura Mar 30 '14 at 19:54
  • Yup, you're right, but the real solution is to use other library: jboss-cxf-server. Thanks for a clue! – Dawid Pura May 03 '14 at 19:49
0

Solution was found, just add other library than usual apache-cxf bindings:

    <dependency>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-jaxws</artifactId>
        <version>2.0.1.SP2</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.ws.cxf</groupId>
        <artifactId>jbossws-cxf-server</artifactId>
        <version>4.2.0.Alpha1</version>
        <scope>provided</scope>
    </dependency>
Dawid Pura
  • 991
  • 9
  • 32