This discussion is archived
2 Replies Latest reply: Nov 4, 2012 10:23 AM by jschellSomeoneStoleMyAlias RSS

How to convert code using com.sun.tools.jxc.SchemaGenTask

swpalmer Newbie
Currently Being Moderated
I 've been search the web high and low and I still can't find how to change code that is using the old SchemaGen ANT task to something that works with JDK 8 where the class is not longer included.

E.g.I have a Maven build that is using the ANT task that fails with:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (generate-schemas) on project MyProject: An Ant BuildException has occured: taskdef A class needed by class com.sun.tools.jxc.SchemaGenTask cannot be found: com/sun/mirror/apt/AnnotationProcessorFactory
[ERROR] using the classloader ...snip...
[ERROR] around Ant part ...<taskdef classname="com.sun.tools.jxc.SchemaGenTask" name="schemagen" classpathref="maven.compile.classpath"/>... @ 6:113 in /Users/scott/dev/Path_to_my_project/target/antrun/build-main.xml: com.sun.mirror.apt.AnnotationProcessorFactory

This has been marked deprecated for a while, with vague references to using javac annotation processing, but never any actual information about how to convert such code.

The JDK 8 docs still link to it in fact.
http://download.java.net/jdk8/docs/technotes/tools/share/schemagen.html

The link to the ANT task there fails.. But I found this (remove the '.dev') :
http://jaxb.java.net/nonav/2.1.3/docs/schemagenTask.html

Which basically instructs you to do what doesn't work.

What's the deal?
  • 1. Re: How to convert code using com.sun.tools.jxc.SchemaGenTask
    swpalmer Newbie
    Currently Being Moderated
    I should also point out that JDK 8 links to JAXB 2.1.3 docs (or tries to), but JDK 7 includes JAXB 2.2.4 according to:
    http://jaxb.java.net/guide/Which_JAXB_RI_is_included_in_which_JDK_.html

    And it remains unclear if any classpath is necessary in :

    <taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask">
    <classpath>
    <fileset dir="path/to/jaxb/lib" includes="*.jar" />
    </classpath>
    </taskdef>

    given that JAXB is included in the JDK. According to the above URL, "...the JAXB RI in JDK is package renamed to avoid any conflict with the stand-alone JAXB RI distribution..." Which leads me to think this may be a simple matter of figuring out what the correct package is for the SchemaGenTask. Perhaps I'm picking up some external to the JDK copy and the internal AnnotationProcessor bits it is expecting are not in the expected package.

    Scott
  • 2. Re: How to convert code using com.sun.tools.jxc.SchemaGenTask
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    If it is just a package name then you can look in the jars (or extract them) and just look for the class name.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points