3

I was getting this exception

java.lang.NoSuchMethodError: org.apache.xml.security.utils.XMLUtils.decode

Then I updated my dependencies and moved on to another similar exception which I am unable to resolve for quite a while:

I am getting NoSuchMethodError when my module receives the request upon calling this method

WebServiceTemplate client = ...;
client.marshalSendAndReceive(req, new ActionCallback("http://samples/RequestOrder"));

it throws

java.lang.NoSuchMethodError: org.apache.xml.security.encryption.AbstractSerializer: method <init>()V not found
    at org.apache.cxf.ws.security.wss4j.StaxSerializer.<init>(StaxSerializer.java:62)

the (at least I think) relevant part of my dependencies

        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.15</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-security</artifactId>
            <version>3.0.9.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
            <version>3.3.6</version>
        </dependency>

I was looking at multiple versions of org.apache.xml.security.encryption and it doesn't look like any of those versions have such method. Any idea what would be the correct combination of versions?

as a sidenote I also found this library and thought that would be helpful , but it seems it is somewhat different than aforementioned <groupId>org.apache.ws.security</groupId>

<dependency>
    <groupId>org.apache.wss4j</groupId>
    <artifactId>wss4j</artifactId>
    <version>2.3.0</version>
    <type>pom</type>
</dependency>
hocikto
  • 871
  • 1
  • 14
  • 29

1 Answers1

4

I had similar issue and tried possible solutions online but to no avail. Some of the documents suggested that dependency mismatch with other dependencies is key, like here.

In relation to this exact reported error, I kept on changing the version of the below dependency and finally reached this, which was the latest version as at the time this answer was posted.

<dependency>
    <groupId>org.apache.santuario</groupId>
    <artifactId>xmlsec</artifactId>
    <version>2.1.4</version>
</dependency>

But remember to ensure that if you have the below dependency, exclude that of xmlsec :

<dependency>
    <groupId>org.springframework.ws</groupId>
    <artifactId>spring-ws-security</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.apache.santuario</groupId>
            <artifactId>xmlsec</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Young Emil
  • 2,220
  • 2
  • 26
  • 37