4

I have generated Java code with Apache CXF tool wsdl2java. In the comments of my service it says that I should endorse Jaxws API 2.2 but don't know what it means. In my Maven POM I have this:

<dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2</version>
</dependency>

On build, I get these errors in Maven:

cannot find symbol symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])

I have checked JAX-WS API 2.2 and it actually has this constructor...what should I do?

4

1 回答 1

7

JAX-WS is part of the JDK. To use a newer version, you have to put it in the endorsed directory. To do that with Maven, you have to configure it with the maven-compiler-plugin.

This page has the gory details.

The critical snippet is:

   <!-- Don't forget to use endorsed with JAX-WS 2.2 on Java 6 !! -->
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <compilerArguments>
        <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
      </compilerArguments>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
          <silent>true</silent>
          <artifactItems>
            <artifactItem>
              <groupId>javax.xml.bind</groupId>
              <artifactId>jaxb-api</artifactId>
              <version>2.2.4</version>
              <type>jar</type>
            </artifactItem>
            <artifactItem>
              <groupId>javax.xml.ws</groupId>
              <artifactId>jaxws-api</artifactId>
              <version>2.2.8</version>
              <type>jar</type>
            </artifactItem>
          </artifactItems>
        </configuration>
      </execution>
    </executions>
  </plugin>
于 2013-03-30T19:16:08.817 回答