mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
107 stars 77 forks source link

schemagen no output with Exception classes included #29

Closed missedone closed 8 years ago

missedone commented 9 years ago

hi, folks

i encountered an issue that if i include my domain exception classes, schemagen has no output but see null on the terminal after enable debug mode (mvn -X clean jaxb2:schemagen):

[DEBUG] Configuring mojo org.codehaus.mojo:jaxb2-maven-plugin:1.5:schemagen from plugin realm ClassRealm[plugin>org.codehaus.mojo:jaxb2-maven-plugin:1.5, parent: sun.misc.Launcher$AppClassLoader@409a44d6]
[DEBUG] Configuring mojo 'org.codehaus.mojo:jaxb2-maven-plugin:1.5:schemagen' with basic configurator -->
[DEBUG]   (f) compileSourceRoots = [/Users/nick/workspace/xxx/xxx/domain/impl/src/main/java]
[DEBUG]   (f) includes = [x/y/z/**/*.java]
[DEBUG]   (f) outputDirectory = /Users/nick/workspace/xxx/xxx/domain/impl/target/schemas
[DEBUG]   (f) project = MavenProject: x.y.z:domain-impl:5.5.0-SNAPSHOT @ /Users/nick/workspace/xxx/xxx/domain/impl/pom.xml
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) workDirectory = /Users/nick/workspace/xxx/xxx/domain/impl/target/jaxb2/work
[DEBUG] -- end configuration --
[DEBUG] Using SchemaGen of JAXB Reference Implementation  version 2.2.5-2
null

if i exclude the Exception classes, the schema generated successfully so i'm wondering is this expected behavior or it's a defect? thanks

lennartj commented 9 years ago

The SchemaGen tool performs a compilation of your source code before generating XSD files from your bytecode. If your local Exception classes are referenced within your code, they are required to compile the source.

Do you get the same result if you run SchemaGen from the commandline? (I.e. not from within the jaxb2-maven-plugin)?

missedone commented 9 years ago

the Exception classes are under the same source folder of other classes, they were compiled together. by using the command line "schemagen -d xxx -cp xxxx xxx.java" i got the same result, there is no output of any schema at all.

missedone commented 9 years ago

wait a min, i noticed that i got error like "error: Two classes have the same XML type name. Use @XmlType.name and @XmlType.namespace to assign different names to them." with schemagen command line, after fix it, i can get the schema generated with schemagen cli, but still no output if run with jaxb2-maven-plugin (except i exclude the Exception java file in the pom.xml).

missedone commented 8 years ago

hi @lennartj the issue is still there, as I said the jaxb2-maven-plugin can NOT generate any output, though the schemagen cli does. so I think there might be still something wrong in the plugin itself.

the plugin version is 1.6, JDK version 1.8u102

Edit: however, looks like it works with plugin version 1.5

lennartj commented 8 years ago

At the moment we are working with plugin version 2.3.

However, getting SchemaGen to emit its standard error output stream to the error stream of the plugin is a somewhat tricky task. It is desire for proper operation, but not necessarily trivial because of hos SchemaGen is constructed.