5

I have wasted mutiple days trying to figure it out, how can something that seems pretty straightforward (generating code from a WSDL/XSD) be so extremly complicated. Are there any approaches? I feel I have tried them all, in diffrent versions using diffrent jaxb bindings and implementations in their diffrent versions

I tried using the following plugins:

<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>

No plugin is able to output jakarta Annotations and always failes bc some javax.xml Annotiation or com.sun.* Class is missing. At this point I am thinking about writing a plugin myself, because this is ridiculous, I just need a simple POJO with some annotations and dont want to write them myself when the xsd or wsdl changes.

Are there any approaches you guys used that work for Jakarta 4?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Chris
  • 109
  • 2
  • 9

1 Answers1

11

Try this one:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        *
    </parent>

    <artifactId>*</artifactId>

    <properties>
        <service.package>com.company</service.package>

        <jakarta.xml.ws-api.version>4.0.0</jakarta.xml.ws-api.version>
        <jaxws-rt.version>4.0.0</jaxws-rt.version>
        <jaxws-ri.version>4.0.0</jaxws-ri.version>
        <jaxws-maven-plugin.version>3.0.0</jaxws-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <version>${jakarta.xml.ws-api.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>${jaxws-rt.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <version>${jaxws-ri.version}</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>${jaxws-maven-plugin.version}</version>
                <configuration>
                    <wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
                    <sourceDestDir>${basedir}/src/main/java</sourceDestDir>
                    <extension>true</extension>
                </configuration>
                <executions>
                    <execution>
                        <id>USER_INFO</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlFiles>
                                <wsdlFile>user_info.xml.wsdl</wsdlFile>
                            </wsdlFiles>
                            <packageName>${service.package}.userinfo</packageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

All dependencies now are jakarta.xml instead of javax.xml.

  • How can I generate setter methods for collection type parameters with the above code. I was using org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1 with org.codehaus.mojo:jaxws-maven-plugin before migrating from javax to jakarta, but this does not seem to work with com.sun.xml.ws plugin – Chamila Wijayarathna Jun 01 '23 at 03:11
  • Works like a charm, actually generates weird setter for collections (like any other xml ws plugin) – Максим Цюпко Jul 11 '23 at 08:43