rascio
rascio

Reputation: 9279

Axis wsdl2java maven plugin with xmlbeans doesn't include resources folder

I'm using axis2 to re-generate the client code for an updated webservice that I need to use, for a legacy application.

Being a legacy application I would like to avoid changing the code that has been already written, and re-generate the classes as they were generated who-know-how-many years ago by the eclipse plugin, but this time using maven instead of eclipse.

So I seen that they were generated using axis2 and xmlbeans, and I produced the configuration in the maven plugin:

<plugin>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
    <version>1.5.6</version>
    <executions>
        <execution>
            <id>TheirsWs</id>
            <goals>
                <goal>wsdl2code</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <packageName>it.theirs.ws</packageName>
                <wsdlFile>${basedir}/src/main/resources/theirWs.wsdl</wsdlFile>
                <generateServerSide>false</generateServerSide>
                <databindingName>xmlbeans</databindingName>
                <unpackClasses>true</unpackClasses>
            </configuration>
        </execution>
    </executions>
</plugin>

What happen now is a very nice thing. The plugin generate a .class file in the generated-sources / axis2 / wsdl2code / resource folder, However it is not added by maven to the final package, causing a ClassNotFoundException when calling the webservice.

Upvotes: 1

Views: 1996

Answers (2)

I solve the problem by adding the resource folder into the JAR using the maven default feature of including and excluding folder. The solution for your case will be:

<build>
<!-- This will the MAVEN to copy the entire folder, you can copy only the .class files -->
<resources>
        <resource>
            <directory>${project.build.directory}/generated-src/resources</directory>
            <includes>
                 <include>**/*</include>
            </includes>     
        </resource>
    </resources>
<plugin>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
    <version>1.5.6</version>
    <executions>
        <execution>
            <id>TheirsWs</id>
            <goals>
                <goal>wsdl2code</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <packageName>it.theirs.ws</packageName>
                <wsdlFile>${basedir}/src/main/resources/theirWs.wsdl</wsdlFile>
                <generateServerSide>false</generateServerSide>
                <databindingName>xmlbeans</databindingName>
                <!-- I add this line just to be easy to referenciate the souce -->
                <outputDirectory>${project.build.directory}/generated-src</outputDirectory>
                <unpackClasses>true</unpackClasses>
            </configuration>
        </execution>
    </executions>
</plugin>

Upvotes: 1

ceonee
ceonee

Reputation: 1

Had the same problem, i changed the Ant build.xml buildfile from:

<target depends="pre.compile.test" name="compile.src" if="jars.ok">
    <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" destdir="${classes}" srcdir="${src}">
        <classpath refid="axis2.class.path"/>
    </javac>
</target>

To:

<target depends="pre.compile.test" name="compile.src" if="jars.ok">
    <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" destdir="${classes}" srcdir="${src}">
        <classpath refid="axis2.class.path"/>
    </javac>
    <copy todir="${classes}">
        <fileset dir="${resources}"/>
    </copy>
</target>

The new Copy task add all the resources to the target classes folder so the generated Jar will include them.

Hope it helps.

Upvotes: 0

Related Questions