jaxb2-annotate-plugin icon indicating copy to clipboard operation
jaxb2-annotate-plugin copied to clipboard

How can I use the annotation plugin to enhance classes generated with jaxws-maven-plugin?

Open end-user opened this issue 10 years ago • 12 comments
trafficstars

I am generating classes directly from a wsdl using wsimport. I would like to annotate the resulting classes. The jaxws-maven-plugin allows jaxb plugins to be included/compiled by including them as dependencies and passing the xjcArg that invokes them. Can I do the same with the jaxb2-annotate-plugin? How would I provide the binding file?

end-user avatar Nov 15 '15 18:11 end-user

Yes, the plugin should work with jaxws-maven-plugin.

Please send me a PR or a sample project which compiles something with the jaxws-maven-plugin and I'll add some annotations via jaxb2-annotate-plugin. The test project should go under https://github.com/highsource/jaxb2-annotate-plugin/tree/master/tests.

highsource avatar Nov 15 '15 18:11 highsource

I put what I've been working on up on github for cloning. I'm sorry I don't understand how it should be integrated under the project tests.

end-user avatar Nov 15 '15 19:11 end-user

See this tutorial:

https://yangsu.github.io/pull-request-tutorial/

highsource avatar Nov 15 '15 20:11 highsource

I can't just clone/copy your repo due to licensing issues.

highsource avatar Nov 15 '15 20:11 highsource

Here's an example of using jaxb2-annotate-plugin with the jaxws-maven-plugin:

https://github.com/highsource/jaxb2-annotate-plugin/tree/master/tests/jaxws

I've managed to make it work with definitions from the schema imported in WSDL but not with the schema inside the WSDL. Customizations are ignored there.

However there's a question on StackOverflow which hints that this may be possible:

http://stackoverflow.com/questions/7154563/can-jaxb2-basics-be-configured-to-specify-an-interface-for-a-type-variable-of-a

Seems like inheritance:implements gets processed. Maybe it works with cxf-codegen-plugin?

Workaround for the moment is to move your schema definitions into individual schema files out of the WSDL.

highsource avatar Nov 15 '15 23:11 highsource

This issue seems to have been fixed in the cxf-codegen-plugin:

https://issues.apache.org/jira/browse/CXF-2855

I'll move to cxf-codegen-plugin then.

highsource avatar Nov 15 '15 23:11 highsource

The following link doesn't work anymore: https://github.com/highsource/jaxb2-annotate-plugin/tree/master/tests/jaxws

Could you please point out the correct link or details about how to integrate jaxb2 annotate plugin with jaxws maven plugin?

ashokkhetan avatar Dec 06 '18 13:12 ashokkhetan

@ashokkhetan It does not work. I could not get jaxws-maven-plugin to run with XJC plugin under JDK 9+.

https://github.com/mojohaus/jaxws-maven-plugin/issues/54#issuecomment-397565960

highsource avatar Dec 06 '18 14:12 highsource

I see. I am using:

<groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.1</version>

Does this make a difference as it's not the mojohaus one? Does it mean that there is no possibility of annotating classes generated by jaxws-maven-plugin? I am creating classes for wsdl and corresponding schemas and need to change @XmlType (name) in some of the generated classes. Please suggest.

ashokkhetan avatar Dec 06 '18 14:12 ashokkhetan

Please ask authors of your target jaxws-maven-plugin how to enable an XJC plugin with their tool. jaxb2-annotate-plugin is just an XJC plugin. I'm sorry I can't consult on all possible XJC plugin integrations.

highsource avatar Dec 06 '18 16:12 highsource

sure, I will check. I just had a workaround in the meantime. I created the files using jaxws-maven-plugin - wsimport first, and then added another plugin entry to use jaxb2-annotate-plugin and overwrite some of the schema generated java files by applying bindings to xjc. Not so clean approach to do, I must admit.

ashokkhetan avatar Dec 06 '18 16:12 ashokkhetan

Duplicate of https://github.com/highsource/jaxb-tools/issues/471 extensionBindingPrefixes is not taken into account in jaxws:bindings so annox is not read by plugin

laurentschoelens avatar Feb 13 '24 10:02 laurentschoelens