ciscoo / cxf-codegen-gradle

Gradle plugin to generate Java artifacts from WSDL
Apache License 2.0
28 stars 6 forks source link

Error - class com.sun.xml.ws.spi.ProviderImpl cannot be cast to class jakarta.xml.ws.spi.Provider #117

Closed hariraogotit closed 1 month ago

hariraogotit commented 1 month ago

Team, A favour please!

I am moving from io.mateo.cxf-codegen - 1.0.3 to io.mateo.cxf-codegen 2.4.0

I am using Java 21 and Spring boot 3.3

When I run the application I get

class com.sun.xml.ws.spi.ProviderImpl cannot be cast to class jakarta.xml.ws.spi.Provider

I played around the dependencies

If I replace 'com.sun.xml.ws:jaxws-rt' from 2.3.1 to 2.3.7 I get ValidationEventLocator not found exception. It belongs to javax.xml.bind:jaxb-api:2.3.1 jar.

I have cxfCodegen 'javax.xml.bind:jaxb-api:2.3.1' declared already. Again if I add implementaion 'javax.xml.bind:jaxb-api:2.3.1' I get duplicate boot jar exception.

Very similar to https://stackoverflow.com/questions/77332934/unable-to-create-provider-class-com-sun-xml-ws-spi-providerimpl-cannot-be-cast

but mine is Jakarta

Any help is much appreciated. I don't see anything related in https://ciscoo.github.io/cxf-codegen-gradle/docs/current/user-guide/

Apologies if I overlooked anything.

hariraogotit commented 1 month ago

java.lang.ClassCastException: class com.sun.xml.ws.spi.ProviderImpl cannot be cast to class jakarta.xml.ws.spi.Provider

I have been with the above error for couple of days now.

image image
ciscoo commented 1 month ago

This isn't an issue with the io.mateo.cxf-codegen plugin specifically, but rather dependency management on the application side. You need to ensure you are using the correct set of dependencies to generate code that aligns with your requirements. As called out in the documentation:

You will need to ensure the version of CXF you specify is compatible with the options used and your application’s version of Jakarta EE (Java EE).

Additionally, depending on the version of you CXF you specify, you will also need to ensure you have the appropriate dependencies for the cxfCodegen classpath and/or your application’s classpath.

Failure to do so can result in an error during code generation and/or compilation errors.

Version 1.0.x of the plugin were based on Apache CXF 3.5.x which in turn was based on the older Java EE specifications. Versions 2.1.x are based on Apache CXF 4.0.x which is based on Jakarta EE 9.1. You can get a full list of dependencies on the build classpath using ./gradlew buildEnvironment, as mentioned in the documentation, several dependencies are added already.

The issues you are facing are better suited to Stack Overflow. This issue tracker is primarily for bugs and enhancements for the io.mateo.cxf-codegen plugin, not application issues. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug with the code generation from io.mateo.cxf-codegen plugin specifically.