Apache CXF 3.4.2 JDK 11 - Issue while Wsdl2Java. Could not load extension class org.apache.cxf.common.util.ASMHelperImpl

Viewed 5960

Am trying to generate Java code from wsdl using apache cxf 3.4.2 & JDK 11 . Getting following exceptions

Exception in thread "main" org.apache.cxf.tools.common.ToolException: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.common.util.ASMHelperImpl Caused by: java.lang.IncompatibleClassChangeError: class org.apache.cxf.common.util.ASMHelperImpl can not implement org.apache.cxf.common.util.ASMHelper, because it is not an interface (org.apache.cxf.common.util.ASMHelper is in unnamed module of loader 'app')

following is snippet from pom.xml

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-rs-client</artifactId>
    <version>3.4.2</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.4.2</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
    <version>3.4.2</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-api</artifactId>
    <version>2.7.18</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>3.4.2</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-simple</artifactId>
    <version>3.4.2</version>
</dependency>
<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.3.0</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.neethi</groupId>
            <artifactId>neethi</artifactId>
            <version>3.1.0</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.basedir}/src/main/generated</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/wsdl/test.wsdl</wsdl>
                        <wsdlLocation>classpath:wsdl/test.wsdl</wsdlLocation>
                        <extraargs>
                            <extraarg>-client</extraarg>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-autoNameResolution</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>com.cxf</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
4 Answers

When you'll try to find ASMHelper class in your IDE then you can see that your class look like this: public class ASMHelper (cxf-core:3.3.0 / cxf-core:3.3.1 / cxf-core:3.3.5) so indeed it's not an interface. However when you look at ASMHelper in cxf-core:3.4.4 you'll see public interface ASMHelper which can be implemented.

So problem is caused by old version of library.

In my case, the problem was solved by aligning all the CXF type dependencies 3.4.4.

Please remove the cxf-api dependency from your pom.xml. It is outdated and has the class ASMHelper.java which is getting loaded instead of the interface from cxf-core jar which is the right package to load. No need to declare cxf-core separately, it is transitively included as part of cxf-rt-frontend-jaxws

Change version of plugin from:

3.3.0

to

3.4.2

Related