This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 157460 - Maven prj w/ JAX-WS client cannot be built from IDE
Summary: Maven prj w/ JAX-WS client cannot be built from IDE
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-26 19:36 UTC by Jesse Glick
Modified: 2009-02-19 22:43 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
my POM (3.15 KB, text/xml)
2009-01-30 21:58 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-01-26 19:36:57 UTC
090126, JDK 5. I made a new Maven project with simple jar archetype and added a JAX-WS client "with dispatch code" from

http://www.webservicex.net/CurrencyConvertor.asmx?wsdl

after setting source level to 1.5. 'mvn clean install' works from the command line (Maven 2.0.9). But Clean & Build from
the IDE does not work:


1. jaxws:wsimport fails with

[jaxws:wsimport {execution: wsimport-generate-CurrencyConvertor.asmx}]
Processing: /tmp/test105645maven/src/wsdl/www.webservicex.net/CurrencyConvertor.asmx.wsdl
jaxws:wsimport args: [-s, /tmp/test105645maven/target/generated-sources/jaxws-wsimport, -d,
/tmp/test105645maven/target/classes, -verbose, -catalog, /tmp/test105645maven/src/jax-ws-catalog.xml, -extension,
-Xnocompile, /tmp/test105645maven/src/wsdl/www.webservicex.net/CurrencyConvertor.asmx.wsdl]
parsing WSDL...


------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
Error executing: wsimport [-s, /tmp/test105645maven/target/generated-sources/jaxws-wsimport, -d,
/tmp/test105645maven/target/classes, -verbose, -catalog, /tmp/test105645maven/src/jax-ws-catalog.xml, -extension,
-Xnocompile, /tmp/test105645maven/src/wsdl/www.webservicex.net/CurrencyConvertor.asmx.wsdl]
------------------------------------------------------------------------
For more information, run Maven with the -e switch


2. If you do this step from the cmdline, but then modify some src/main/java/**.java (to force compilation to be out of
date) and do a non-clean build from the IDE, it still fails:

[compiler:compile]
Compiling 1 source file to /tmp/test105645maven/target/classes
------------------------------------------------------------------------
[ERROR]BUILD FAILURE
------------------------------------------------------------------------
Compilation failure

test/test105645maven/App.java.java:[14,27] cannot access javax.jws.WebService
file javax/jws/WebService.class not found
        System.out.println(new CurrencyConvertor().getCurrencyConvertorSoap().conversionRate

test/test105645maven/App.java.java:[14,8] cannot access javax.jws.WebParam
file javax/jws/WebParam.class not found
        System.out.println(new CurrencyConvertor().getCurrencyConvertorSoap().conversionRate

and in fact target/generated-sources/jaxws-wsimport/net/webservicex/CurrencyConvertorSoap.java is marked with errors for
javax.jws.**.


3. If you compile from the cmdline, Run Project also fails with

[exec:exec]
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jws/soap/SOAPBinding$Style
        at com.sun.xml.ws.model.wsdl.WSDLBoundPortTypeImpl.<init>(WSDLBoundPortTypeImpl.java:135)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseBinding(RuntimeWSDLParser.java:417)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:321)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:146)
        at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:264)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:227)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:175)
        at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
        at javax.xml.ws.Service.<init>(Service.java:56)
        at net.webservicex.CurrencyConvertor.<init>(CurrencyConvertor.java:46)
        at test.test105645maven.App.main(App.java:14)

Similar if I use CoS to run the program - says there are errors and if I continue anyway gives this stack trace.


BTW the checkbox "Use external Maven for build execution" is checked ("mvn" in my $PATH is 2.0.9); if I uncheck it and
press OK, it is still checked when I reopen the Properties dialog.
Comment 1 Milos Kleint 2009-01-27 06:33:33 UTC
milane, can you look into this? thanks.
Comment 2 Milan Kuchtiak 2009-01-27 13:50:22 UTC
Able to reproduce after cleaning local Maven Repository :

By running with stack traces I got :

Error executing: wsimport [-s,
/space/home/mkuchtiak/NetBeansProjects/mavenproject2/target/generated-sources/jaxws-wsimport, -d,
/space/home/mkuchtiak/NetBeansProjects/mavenproject2/target/classes, -verbose, -catalog,
/space/home/mkuchtiak/NetBeansProjects/mavenproject2/src/jax-ws-catalog.xml, -extension, -Xnocompile,
/space/home/mkuchtiak/NetBeansProjects/mavenproject2/src/wsdl/www.webservicex.net/CurrencyConvertor.asmx.wsdl]
        at org.codehaus.mojo.jaxws.WsImportMojo.wsImport(WsImportMojo.java:283)
        at org.codehaus.mojo.jaxws.WsImportMojo.processLocalWsdlFiles(WsImportMojo.java:235)
        at org.codehaus.mojo.jaxws.WsImportMojo.execute(WsImportMojo.java:191)
        at org.codehaus.mojo.jaxws.MainWsImportMojo.execute(MainWsImportMojo.java:15)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
        ... 16 more
Comment 3 Milan Kuchtiak 2009-01-27 16:30:32 UTC
We need to add one project dependency :
<dependency>
 <groupId>javax.jws</groupId>                                              
 <artifactId>jsr181-api</artifactId>
 <version>1.0-MR1</version>
</dependency>
(the same to jaxws-maven-plugin)

Need to discuss with mkleint more.

The workaround is also using JDK1.6.
Comment 4 Milan Kuchtiak 2009-01-28 10:31:56 UTC
Fixed:
http://hg.netbeans.org/main?cmd=changeset;node=8a00483f9796
Comment 5 Jesse Glick 2009-01-28 18:38:49 UTC
Now when I add a WS client to a Maven project, the project got broken:

        <dependency>
            <groupId></groupId>
            <artifactId>javax.jws</artifactId>
            <version>poms</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.3</version>
        </dependency>

After correcting the first dep to

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

the build failed:

Downloading: http://download.java.net/maven/1/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.pom
Downloading: http://repo1.maven.org/maven2/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.pom
Downloading: http://download.java.net/maven/1/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar
Downloading: http://repo1.maven.org/maven2/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar
------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
Failed to resolve artifact.

Missing:
----------
1) javax.jws:jsr181-api:jar:1.0-MR1
Comment 6 Jesse Glick 2009-01-28 18:47:04 UTC
Manually changing the POM to say

<layout>legacy</layout>

lets Maven find the library, but then I get the same error as I originally reported in this issue (wsimport goal failure).
Comment 7 Quality Engineering 2009-01-28 22:49:19 UTC
Integrated into 'main-golden', will be available in build *200901281643* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8a00483f9796
User: mkuchtiak@netbeans.org
Log: #157460: fixed maven dependencies for JAX-WS 2.1 library
Comment 8 Milan Kuchtiak 2009-01-29 08:49:53 UTC
You may have forgotten to apply the following change, I did tomorrow in maven module :
http://hg.netbeans.org/main/rev/0f7affeed3be

Sorry, I should have mentioned that.
Hopefully it's OK now.
Comment 9 Jesse Glick 2009-01-29 16:41:40 UTC
Ah.
Comment 10 Jesse Glick 2009-01-29 16:42:04 UTC
Original bug would be fixed then (not yet verified).
Comment 11 Jesse Glick 2009-01-29 17:17:20 UTC
I can still reproduce the original bug, running an IDE with a clean build of cluster.config=enterprise from
6cfd3277c702, which should include both of your fixes, on JDK 5. The POM looks to be what you wanted:

        <dependency>
            <groupId>javax.jws</groupId>
            <artifactId>jsr181-api</artifactId>
            <version>1.0-MR1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.3</version>
        </dependency>

'mvn clean install' works from the command line using JDK 6u11 but not using JDK 5u15.

org.apache.maven.plugin.MojoExecutionException: Error executing: wsimport [-s,
/tmp/test105645maven5/target/generated-sources/jaxws-wsimport, -d, /tmp/test105645maven5/target/classes, -verbose,
-catalog, /tmp/test105645maven5/src/jax-ws-catalog.xml, -extension, -Xnocompile,
/tmp/test105645maven5/src/wsdl/www.webservicex.net/CurrencyConvertor.asmx.wsdl]
	at org.codehaus.mojo.jaxws.WsImportMojo.wsImport(WsImportMojo.java:283)
Comment 12 Milos Kleint 2009-01-29 17:41:14 UTC
just my opinion, but I'm not sure this is something we can ever effectively target from the IDE integration. It's a
shortcoming/bug in the jaxws-plugin, AFAIK it's already filed. Milane, do you have the URL to the plugin issue?
Comment 13 Milan Kuchtiak 2009-01-30 09:23:03 UTC
Please, send me your project.

Does the pom file contain the right repository, needed for jaxws21 ?

The end of pom.xml (after ws client is added) should be the following :
...
    <repositories>
        <repository>
            <url>http://download.java.net/maven/1</url>
            <id>jaxws21</id>
            <layout>legacy</layout>
            <name>Repository for library Library[jaxws21]</name>
        </repository>
    </repositories>
    <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
        <dependency>
            <groupId>javax.jws</groupId>
            <artifactId>jsr181-api</artifactId>
            <version>1.0-MR1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.3</version>
        </dependency>
    </dependencies>
</project>

For me it works perfectly from cmd line and from ide. Tested on jdk1.5.0_15.

> mkleint: just my opinion, but I'm not sure this is something we can ever effectively target from the IDE integration.
JAX-WS wsimport plugin has mess in its dependencies. 
That's why we need to add another dependency to jsr181-api (workaround).
It's not needed for jdk1.6, since jsr181 is there.
I need to consult this with jax-ws team.
Comment 14 Jesse Glick 2009-01-30 21:58:45 UTC
Created attachment 76397 [details]
my POM
Comment 15 Jesse Glick 2009-01-30 22:00:30 UTC
The attached builds for me (clean install) using Maven 2.0.9 using JDK 6 but not JDK 5, even after

rm -rfv ~/.m2/repository/javax/jws
rm -rfv ~/.m2/repository/com/sun/xml/ws
Comment 16 Jesse Glick 2009-01-30 22:28:44 UTC
Using the patch from

https://jax-ws-commons.dev.java.net/nonav/issues/show_bug.cgi?id=32

I got a stack trace:

java.lang.NoClassDefFoundError: javax/jws/WebParam$Mode
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.getParameterOrder(WSDLModeler.java:2555)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.processLiteralSOAPOperation(WSDLModeler.java:767)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.processSOAPOperation(WSDLModeler.java:704)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.processPort(WSDLModeler.java:472)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.processService(WSDLModeler.java:251)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:221)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:133)
	at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:183)
Comment 17 Jesse Glick 2009-01-30 22:49:14 UTC
The mentioned class does exist in jsr181-api-1.0-MR1.jar, and 'cl' in WsImportMojo.wsImport - a URLClassLoader - can
load it. But the defining loader of WsimportTool is a org.codehaus.classworlds.RealmClassLoader. So WsimportTool is
being loaded by too low a loader. I tried

final ClassLoader cl = Invoker.createClassLoader(new java.net.URLClassLoader(((java.net.URLClassLoader)
Thread.currentThread().getContextClassLoader()).getURLs(), ClassLoader.getSystemClassLoader()));

but this just results in

java.lang.NoClassDefFoundError: com/sun/tools/xjc/api/ErrorListener
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
	at java.lang.Class.getConstructor0(Class.java:2671)
	at java.lang.Class.getConstructor(Class.java:1629)
	at org.codehaus.mojo.jaxws.WsImportMojo.wsImport(WsImportMojo.java:293)

for reasons I haven't figured out yet.
Comment 18 Jaroslav Pospisil 2009-02-02 09:56:43 UTC
There's needed to add this code into pom.xml in jax-ws plugin section:

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

This workaround works,but it seems issue is restricted only on Windows platform.
Comment 19 Milan Kuchtiak 2009-02-02 10:07:23 UTC
Thanks,
I thought it's enough to add one global dependency for jsr181 API.
The strange thing is that it works for me fine without this additional (plugin) dependency.
Anyway, I will add this dependency to wsimport plugin.
Comment 20 Milan Kuchtiak 2009-02-02 10:39:31 UTC
Fixed:
http://hg.netbeans.org/main?cmd=changeset;node=52b334f993e4
Comment 21 Jesse Glick 2009-02-02 16:57:59 UTC
Have not tested maven.jaxws change yet, but can confirm that adding the XML snippet to POM does make it buildable on JDK
5 (CLI mvn) for me.
Comment 22 Jesse Glick 2009-02-02 17:09:41 UTC
Now the build completes, but trying to run the app fails:

[compiler:compile]
Compiling 4 source files to /tmp/test105645maven6/target/classes
[exec:exec]
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing
        at com.sun.xml.ws.model.wsdl.WSDLPortImpl.freeze(WSDLPortImpl.java:126)
        at com.sun.xml.ws.model.wsdl.WSDLServiceImpl.freeze(WSDLServiceImpl.java:118)
        at com.sun.xml.ws.model.wsdl.WSDLModelImpl.freeze(WSDLModelImpl.java:238)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:147)
        at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:263)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:226)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:174)
        at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
        at javax.xml.ws.Service.<init>(Service.java:56)
        at net.webservicex.CurrencyConvertor.<init>(CurrencyConvertor.java:46)
        at test.test105645maven6.App.main(App.java:14)
------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
Result of /bin/sh -c cd /tmp/test105645maven6 && /space/jdk5/bin/java -classpath
/tmp/test105645maven6/target/classes:/home/jglick/.m2/repository/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar:/home/jglick/.m2/repository/com/sun/xml/ws/jaxws-rt/2.1.3/jaxws-rt-2.1.3.jar:/home/jglick/.m2/repository/javax/xml/ws/jaxws-api/2.1/jaxws-api-2.1.jar:/home/jglick/.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar:/home/jglick/.m2/repository/javax/xml/stream/stax-api/1.0/stax-api-1.0.jar:/home/jglick/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/home/jglick/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.6/jaxb-impl-2.1.6.jar:/home/jglick/.m2/repository/com/sun/xml/messaging/saaj/saaj-impl/1.3/saaj-impl-1.3.jar:/home/jglick/.m2/repository/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar:/home/jglick/.m2/repository/com/sun/xml/stream/buffer/streambuffer/0.7/streambuffer-0.7.jar:/home/jglick/.m2/repository/org/jvnet/staxex/stax-ex/1.2/stax-ex-1.2.jar:/home/jglick/.m2/repository/com/sun/xml/stream/sjsxp/1.0/sjsxp-1.0.jar:/home/jglick/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar:/home/jglick/.m2/repository/org/jvnet/mimepull/1.1/mimepull-1.1.jar
test.test105645maven6.App execution is: '1'.

Here is my main class:

package test.test105645maven6;
import net.webservicex.Currency;
import net.webservicex.CurrencyConvertor;
public class App {
    public static void main(String[] args) {
        System.out.println(new CurrencyConvertor().getCurrencyConvertorSoap().conversionRate
                (Currency.EUR, Currency.USD));
    }
}
Comment 23 Quality Engineering 2009-02-03 08:31:53 UTC
Integrated into 'main-golden', will be available in build *200902030229* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/52b334f993e4
User: mkuchtiak@netbeans.org
Log: #157460: add jsr181 dependency to wsimport plugin
Comment 24 Milan Kuchtiak 2009-02-05 11:54:45 UTC
Really not able to reproduce. Asked also guys here - no success.
The mentioned, missing class, should have been downloaded within:
http://download.java.net/maven/1/javax.xml.ws/jars/jaxws-api-2.1.jar

... but from the command line you sent looks you have it there.

Have you tried to clean up your maven repository?
Or may be just remove .m2/repository/javax/xml/ws
Comment 25 Jesse Glick 2009-02-11 01:45:25 UTC
x
Comment 26 Jesse Glick 2009-02-11 01:46:30 UTC
After deleting parts of my Maven cache yet again, and trying again in a new clean build with a fresh project, it is
finally working for me.