I'm working on a related issue here, but I have a separate question. Perhaps it's all part of the same problem, but it seems different.
Because of the problems I'm having running XJC through the Ant task and through the facade, I'm now trying to run it with the command-line "xjc" tool from the JDK.
As in the original problem, I'm trying to use the "Element Wrapper" and "Fluent API" extensions, so my command line is the following:
xjc -extension -classpath "lib/jaxb-fluent-api-2.1.8.jar;lib/jaxb-xew-plugin-1.4.jar" -Xxew -summary target/xew-summary.txt -instantiate lazy -Xfluent-api schema/serviceCallResults.xsd
These are basically the same parameters I've been sending to the "cxf-jaxb-plugin" Maven plugin, which has been working for a long time. Unfortunately, this "xjc" command line fails with:
unrecognized parameter -Xxew
What might be wrong here?
Open a command prompt. Run the JAXB schema compiler, xjc command from the directory where the schema file is located. The xjc schema compiler tool is located in the app_server_root \bin\ directory. Use the generated JAXB objects within a Java application to manipulate XML content through the generated JAXB classes.
7.1. The JAXB-2 Maven plugin uses the JDK-supplied tool XJC, a JAXB Binding compiler tool that generates Java classes from XSD (XML Schema Definition). By default, this plugin locates XSD files in src/main/xsd.
Old JAXB XJCContains source code needed for binding customization files into java sources. In other words: the *tool* to generate java classes for the given xml representation.
Use the Java™ Architecture for XML Binding (JAXB) tools to generate Java classes from an XML schema with the xjc schema compiler tool.
This just does not work, sorry.
XJC plugins must extend the com.sun.tools.xjc.Plugin
class. But the XJC which is included into JDK and available as xjc
binary (ex. xjc.exe
under Windows) is repackaged: com.sun.tools.xjc
-> com.sun.tools.internal.xjc
.
So in vanilla command line xjc
you don't have the com.sun.tools.xjc.Plugin
class (which XJC plugins extend) but com.sun.tools.internal.xjc.Plugin
.
So CLI xjc
just does not work with XJC plugins. The only plugins which still work are those which are repackaged as well. (Ex. com.sun.tools.internal.xjc.addon.code_injector.PluginImpl
.)
If do you want command line then try to figure out java -cp ...
parameters, this is the only way to make it work with third-party XJC plugins like XEW or JAXB2-Basics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With