javaee / metro-jaxws-commons

Metro has been contributed to Eclipse Foundation. This repository is for legacy review only. Please refer to the Eclipse EE4J Metro project for the very latest
https://eclipse-ee4j.github.io/metro-wsit/
Other
10 stars 9 forks source link

jaxws-maven-plugin >= 1.10 does not handle xjcArg correctly for XJC extnsion plugins #46

Closed glassfishrobot closed 13 years ago

glassfishrobot commented 15 years ago

I am upgrading from jaxws-maven-plugin from version 1.9 to latest 1.12 and discovered that since version 1.10 it does not handle any XJC args that are really intended to be processed by XJC extension plugins like Equlas, Copy plugins etc.

This causes following in plugin configuration to cause the plugin to fail...

-Xequals -XhashCode -Xcopyable -Xannotate

To further compound thhe problem the failure does not say why it failed and instead I had to run a standalone wsimport with same options as the plugin to find out the root problem.

I tested with changing my pom to only change the jaxws-maven-plugin version and found that 1.9 works while 1.10-1.12 do not.

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 15 years ago

Reported by najmi@java.net

glassfishrobot commented 14 years ago

jessecrossley@java.net said: I succeeded in getting jaxws-maven-plugin 1.12 to correctly handle xjcArgs intended for XJC extension plugins (specifically equals, toString, hashCode, and inject-prop-listeners). The trick is to specify the complete classpath required by the plugin(s). For inject-prop-listeners, this was simple: we only need proplistinjector-0.3 and coll-prop-0.1.1. However, there were a great deal more needed by the jaxb2-basics plugins.

These are the xjcArgs used to successfully integrate xjc plugins with jaxws-maven-plugin:

-cp $ {settings.localRepository}/org/no0ne/proplistinjector/0.3-SNAPSHOT/proplistinjector-0.3-SNAPSHOT.jar;${settings.localRepository} /org/no0ne/coll-prop/0.1.1/coll-prop-0.1.1.jar;$ {settings.localRepository}/org/jvnet/jaxb2_commons/jaxb2-basics/0.5.2/jaxb2-basics-0.5.2.jar;${settings.localRepository} /org/jvnet/jaxb2_commons/jaxb2-basics-runtime/0.5.2/jaxb2-basics-runtime-0.5.2.jar;$ {settings.localRepository}/org/jvnet/jaxb2_commons/jaxb2-basics-tools/0.5.2/jaxb2-basics-tools-0.5.2.jar;${settings.localRepository} /commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar;$ {settings.localRepository}/commons-lang/commons-lang/2.2/commons-lang-2.2.jar;${settings.localRepository} /commons-io/commons-io/1.2/commons-io-1.2.jar;$ {settings.localRepository} /commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar; -Xinject-prop-listeners -XtoString -Xequals -XhashCode

Please note the proplistinjector-0.3-SNAPSHOT is a separate debugging effort; use the 0.3 until a new version is available.

glassfishrobot commented 14 years ago

shibug@java.net said: Adding to cc list

glassfishrobot commented 13 years ago

@lukasj said: Ideally sth like following snippet should work (and still works on JDK 5) but apparently it doesn't work on JDK 6 & 7. Will investigate more after updating plugin to jax-ws 2.2.x

<plugin>
    <groupId>org.jvnet.jax-ws-commons</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>some-version</version>
    <dependencies>
        <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>0.6.3</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <id>id1</id>
            <goals>
<goal>wsimport</goal>
            </goals>
            <configuration>
<xjcArgs>
    <xjcArg>-Xequals</xjcArg>
    <xjcArg>-XtoString</xjcArg>
</xjcArgs>
            </configuration>
        </execution>
    </executions>
</plugin>
glassfishrobot commented 13 years ago

@lukasj said: The problem is: java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider org.jvnet.jaxb2_commons.plugin.jaxbindex.JaxbIndexPlugin could not be instantiated: java.lang.ClassCastException: Cannot cast org.jvnet.jaxb2_commons.plugin.jaxbindex.JaxbIndexPlugin to com.sun.tools.xjc.Plugin at java.util.ServiceLoader.fail(ServiceLoader.java:224) ...

The cause of this is that there are currently too many classloaders being created before wsimport is called by WsImportMojo.

Fix is to instead of doing:

1) create and set up classloaders 2) ask jax-ws, particularly Invoker class, to create and set up classloaders 3) call wsimport using reflection

call directly WsImport using API (omit step 2 and change step 3). After this, it should be enough to just declare a dependency on a jaxb2 plugin and it will work.

glassfishrobot commented 13 years ago

@lukasj said: http://java.net/projects/jax-ws-commons/sources/svn/revision/946

glassfishrobot commented 12 years ago

shibug said: I applied the patch to jaxws-maven-plugin-2.1 and it worked fine but I still need to place jaxb-api-2.2.5 jar in endorsed folder of jdk 6u26. Although I don't require jaxb-api-2.2.5 jar at runtime.

I wish I could use it with default jdk 6u26.

glassfishrobot commented 12 years ago

@lukasj said: can you try this with jaxws-maven-plugin-2.2-SNAPSHOT instead, please? Thanks!

to use JAX-WS from some particular JDK, just setup plugin dependencies as described at plugin's usage page (or for the 2.2 plugin version, see http://java.net/projects/jax-ws-commons/sources/svn/content/trunk/jaxws-maven-plugin/src/site/apt/usage.apt?rev=949 )

glassfishrobot commented 12 years ago

shibug said: I tried with jaxws-maven-plugin-2.2-SNAPSHOT but it still doesn't work unless I keep jaxb-api-2.2.5 jar under endorsed folder in jdk 6u26. This is the error I get

[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.2-SNAPSHOT:wsimport (default) on project account-ejb: Error executing: wsimport [-s, C:\Workspaces\indigo\account\ejb\target\generated-sources\jaxws\wsimport, -d, C:\Workspaces\indigo\account\ejb\target\classes, -httpproxy:199.68.81.27:8080, -wsdllocation, META-INF/WSDL/Account-SoapHttp.wsdl, -Xnocompile, -B-extension, -B-Xcommons-lang, -B-Xfluent-api, -B-Xvalue-constructor, -B-Xdefault-value, -b, C:\Workspaces\indigo\account\ejb\src\main\resources\META-INF\jaxws\bindings.xml, C:\Workspaces\indigo\account\ejb\src\main\resources\META-INF\wsdl\Account-SoapHttp.wsdl]: UndeclaredThrowableException: javax.xml.bind.annotation.XmlElementRef.required() -> [Help 1]

Here are my pom declarations:

... ... com.sun.xml.ws jaxws-rt 2.2.5 ... ... org.jvnet.jax-ws-commons jaxws-maven-plugin 2.2-SNAPSHOT wsimport $ {project.basedir}/src/main/resources/META-INF/wsdl ${project.basedir} /src/main/resources/META-INF/jaxws $ {project.build.directory}/generated-sources/jaxws/wsimport ${project.build.directory} /generated-sources/jaxws/stale/.staleFlag -extension -Xcommons-lang -Xfluent-api -Xvalue-constructor -Xdefault-value com.sun.xml.ws jaxws-tools 2.2.5 org.jvnet.staxex stax-ex org.jvnet.staxex stax-ex 1.6 javax.xml.stream stax-api org.jvnet.jaxb2_commons jaxb2-commons-lang 2.3 org.jvnet.jaxb2_commons jaxb2-fluent-api 3.0 org.jvnet.jaxb2_commons jaxb2-value-constructor 3.0 org.jvnet.jaxb2_commons jaxb2-default-value 1.1 maven-compiler-plugin 1.6 1.6 $ {project.build.directory}/endorsed org.apache.maven.plugins maven-dependency-plugin 2.3 validate copy ${project.build.directory} /endorsed true javax javaee-endorsed-api 6.0 jar javax.xml.bind jaxb-api 2.2.5 jar javax.xml.ws jaxws-api 2.2.7 jar ... ...
glassfishrobot commented 11 years ago

@lukasj said: closing old and already fixed issues

glassfishrobot commented 13 years ago

File: jax_ws_commons-45-46-tests.diff.txt Attached By: @lukasj

glassfishrobot commented 13 years ago

File: jax_ws_commons-45-46.diff.txt Attached By: @lukasj

glassfishrobot commented 15 years ago

Issue-Links: depends on JAX_WS_COMMONS-52 is related to JAX_WS_COMMONS-45

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAX_WS_COMMONS-46

glassfishrobot commented 13 years ago

Marked as fixed on Thursday, November 3rd 2011, 10:03:41 am