So I was trying to figure it for a while. I have a Java class with JAXB annotations:
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Book {
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
I can then run schemagen
as follows:
schemagen -d d:\Temp Book.java
and the XML schema is generated: schema1.xsd
. And the return code is 0 (tried both windows (echo %ERRORLEVEL%
) and linux (echo $?
).
Now I need to add some Jackson annotation to this class so I am adding a single JSON attribute:
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
@XmlRootElement
public class Book {
@JsonProperty("title")
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
Unfortunately, now when I run schemagen it appears it succeeds (schema file is generated) but the return code is 1 (both on Linux and Windows) which is problematic for me as it causes gmake to fail.
Sadly schemagen
does not output any error messages. But my suspicion is that it cannot find jackson jars so I copied jackson-annotation jar (with dependencies of jackson-core and jackson-databind) to common D:\Temp location and run schemagen
as follows:
schemagen -cp d:\Temp -d d:\Temp Book.java
unfortunately same results, if I run it like this:
schemagen -cp d:\Temp\* -d d:\Temp Book.java
I will also get single null
outputed on console (JAXB guys really emphasized verbosity here) and return code of -1.
How to get schemagen run successfully (return code 0) with Jackson annotations? Any suggestions?