views:

750

answers:

3

We're trying to generate source code stubs from a series of WSDLs (each with their own XSDs). We can do this fine and works perfectly under JDK1.6, however we need it to work under JDK1.5.

We're using jaxws-maven-plugin to generate the source code, however it depends on the wsimport binary being available (this is not available in JDK1.5). We found a work around for this, we can now generate the source code.

The final problem comes when we try and use the compiled stub code with Spring (2.5.6) we're using a JaxWsPortProxyFactoryBean to interface with the generated client code. We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. I investigated why this was and found that the javax.xml.ws/javax-api/2.1 dependency did not contain this class. I upgraded the version number to 2.1-1 and now when we build the project (to generate the source code) we get the following error:

cannot find symbol
symbol : method partName()
location : @interface javax.jws.WebParam

Can anyone provide a solution to this so we can generate our JAXWS client stub code and make it work with the JaxWsPortProxyFactoryBean?

Thanks in advance

Jonathan

A: 

We're using jaxws-maven-plugin to generate the source code, however it depends on the wsimport binary being available (this is not available in JDK1.5). We found a work around for this, we can now generate the source code.

Actually, wsimport, which is part of JAX-WS, is not included in Java 5 (unlike Java 6 which includes JAX-WS 2.x, Java 6u14 includes JAX-WS 2.1.6) but it is available for Java 5 as long as you provide it. The odd part is that the jaxws-maven-plugin declare these dependencies (see for example jaxws-maven-plugin-1.12.pom), there must be a classloading issue somewhere, hence the "work around".

The final problem comes when we try and use the compiled stub code with Spring (2.5.6) we're using a JaxWsPortProxyFactoryBean to interface with the generated client code. We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. [...]

What version of the plugin are you using exactly? I'd suggest to use the version 1.12 and the same version of jax-ws as in the plugin in your pom.xml:

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-tools</artifactId>
  <version>2.1.7</version>
</dependency>
Pascal Thivent
+1  A: 

I managed to solve this one, after hours of studying the dependencies and looking at what each of them had inside I discovered that the dependency javax.xml.ws:jaxws-api:2.1-1 was required, but we had to take a copy of this dependency and take out:

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181</artifactId>
    <version>1.0</version>
</dependency>

Then I had to include the following dependency in the pom.xml of my application:

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181-api</artifactId>
    <version>1.0-MR1</version>
</dependency>

This is far from ideal, we have to maintain a separate proprietary dependency in our maven repository and remember to include this dependency. The annoying thing is Maven doesn't allow me to exclude by version number (only by groupId and artifactId). If anyone has a suggestion to make this solution better please let me know.

Thanks for your help.

Jonnie
A: 

It seems that they mess with this jar, see this link.

The workaround is the following :

  1. delete M2_REPO/javax/xml/ws/jaxws-api/2.1/ directory
  2. use this dependency

    <dependency>
     <groupId>javax.xml.ws</groupId>
     <artifactId>jaxws-api</artifactId>
     <version>2.1</version>
    </dependency>
    
  3. put these repositories at the top of your list :

    <repository>
     <id>javanet</id>
     <url>http://download.java.net/maven/2/&lt;/url&gt;
    </repository>
    <repository>
     <id>javanet legacy</id>
     <url>http://download.java.net/maven/1/&lt;/url&gt;
     <layout>legacy</layout>
    </repository>
    
@user213917: Thank you for the link. I hit the same issue!
dma_k