Here is my sample schemagen ant file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectname" default="generate-schema" basedir=".">
<path id="classpath">
<pathelement location="path/to/classes"/>
<fileset dir="/path/to/jaxb/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask">
<classpath refid="classpath"/>
</taskdef>
<target name="generate-schema">
<schemagen srcdir="path/to/src" destdir="path/to/generatedfiles">
<classpath refid="classpath"/>
<schema namespace="http://namespace" file="nameOfMySchema.xsd" />
</schemagen>
</target>
</project>
However, if java classes contains jpa specific annotations, the apt tool could not handle this and throw annotation specific exceptions when the lib coming with jaxb ri is used in the classpath.
Annotations for Persistence part on http://www.devx.com/Java/Article/34069/0/page/1 solves this. download sample code on http://assets.devx.com/sourcecode/18778.zip and use the lib coming with the sample on path 18778/JAXB/lib. Actually, the above ant file is a simplified version of 18778/JAXB/3-JAXB and JPA/build.xml coming with the example..
So, it is ok for now :)
please elaborate the way to generate schema for annotted classes
YanıtlaSilsure! the annotations which crashes with jaxb (mentioned above) are jpa annotations. using the lib coming with this sample(http://assets.devx.com/sourcecode/18778.zip ) prevents this crash and schemagen is able to create the schema files. btw, classes without no-arg constructors will lead to error while using schemagen, so take them out from your source folder prior to using schemagen tool.. i hope it is more clear now..
YanıtlaSilyes..but the link you gave is not being extracted...
YanıtlaSilthe zip file is showing error..
YanıtlaSil[End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
himm.. when i try downloading and opening the zip file in my open suse environment, there is no problem..
YanıtlaSilthen, maybe you can construct your own jaxb lib by collecting the following files:
- activation.jar
- jaxb-api.jar
- jaxb-impl.jar
- jaxb-xjc.jar
- jsr173_1.0_api.jar
- junit4.1.jar
- mysql-connector-java-5.0.4-bin.jar
- toplink-essentials-agent.jar
- toplink-essentials.jar
btw, the file set i listed above may not be the minimal list (i mean maybe not all of them are required), but this set works somehow!
will you please re zip the content and send me @ jigarjm@gmail.com
YanıtlaSilfinally solved by maven plugin
YanıtlaSilnow the point is that can i generate schema xsd (request & response )from interface ?
YanıtlaSili tried schemagen with a sample interface and it just ignored it, no schema is created.. i don't think you can do that..
YanıtlaSilThe blog you quote is a blatant ripoff taken from
YanıtlaSilhttp://www.devx.com/Java/Article/34069/0/page/1
you are absolutely right! i replaced the link with the original one.. thanks for the correction..
YanıtlaSil