axis2 maven example

Larry Cai picture Larry Cai · May 22, 2010 · Viewed 49.4k times · Source

I try to use axis2 (1.5.1) version to generate java codes from wsdl files, but I can't figure out what is the correct pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.5.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <wsdlFile>src/main/resources/wsdl/stockquote.wsdl</wsdlFile>
                        <databindingName>xmlbeans</databindingName>
                        <packageName>a.bc</packageName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.5.1</version>
    </dependency>
</dependencies>

when I type mvn compile, it complains the

Retrieving document at 'src/main/resources/wsdl/stockquote.wsdl'.
java.lang.ClassNotFoundException: org.apache.xml.serializer.TreeWalker

And if i try to find the TreeWalker, it is a mess to find a suitable jar files.

can u someone give me a hints ? or give me correct pom.xml

[update] the xalan-2.7.0.jar needs be depedent as well, and the jar file is broken ( due to nexus problem), thx pascal

Answer

Pascal Thivent picture Pascal Thivent · May 22, 2010

It's maybe not optimal but the following pom.xml seems to allow the generated code to be compiled:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>Q2888422</artifactId>
  <version>1.0-SNAPSHOT</version>
  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.axis2</groupId>
      <artifactId>axis2</artifactId>
      <version>1.5.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-api</artifactId>
      <version>1.2.6</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-impl</artifactId>
      <version>1.2.6</version>
    </dependency>
    <dependency>
      <groupId>axis</groupId>
      <artifactId>axis-wsdl4j</artifactId>
      <version>1.5.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.xmlbeans</groupId>
      <artifactId>xmlbeans</artifactId>
      <version>2.3.0</version>
    </dependency>
    ...
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <version>1.5.1</version>
        <executions>
          <execution>
            <goals>
              <goal>wsdl2code</goal>
            </goals>
            <configuration>
              <wsdlFile>src/main/resources/wsdl/stockquote.wsdl</wsdlFile>
              <databindingName>xmlbeans</databindingName>
              <packageName>a.bc</packageName>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

This pom.xml is the result or try and error plus some googling, I couldn't find a single official or unofficial resource with a working setup. Seriously, why the hell is it so hard to setup an Axis2 project? One more reason I don't like Axis.