Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchMethodError: What version of Apache Xml Security do I need?

Tags:

java

wss4j

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>
like image 339
hocikto Avatar asked Apr 08 '26 21:04

hocikto


1 Answers

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>
like image 52
Young Emil Avatar answered Apr 11 '26 11:04

Young Emil