8

When I try to use maven-jaxb-schemagen-plugin with java 7

<groupId>com.sun.tools.jxc.maven2</groupId>
<artifactId>maven-jaxb-schemagen-plugin</artifactId>
<version>1.2</version>

I get an error:

[ERROR] Failed to execute goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate (default) on project TopologyProvisionerDom: Execution default of goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate failed: A required class was missing while executing com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate: com/sun/mirror/apt/AnnotationProcessorFactory

It seems like the AnnotationProcessorFactory is being removed/deprecated in Java 7? Is it possible to get jaxb schemagen to work using this plugin? Is there an alternative approach to get schema generation from the JAXB source code when using JDK 7?

lexicalscope
  • 7,158
  • 6
  • 37
  • 57

3 Answers3

9

Have you tried using the org.codehaus.mojo:jaxb2-maven-plugin instead?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • 2
    So this plugin seems to work. One downside is that it doesn't seem possible to name the output schema files using this plugin, so I had to resort to using the maven-antrun-plugin to rename the schema file. Also I get a warning "warning: The apt tool and its associated API are planned to be removed in the next major JDK release." - hopefully this mess will get sorted out before java 8 – lexicalscope Dec 20 '11 at 15:16
  • 1
    You can provide the output schema files using and – keiki Dec 06 '12 at 14:08
7

This is how it works (add this profile to your pom.xml):

<profile>
    <id>jdk7-fix</id>
    <activation>
        <file><exists>${java.home}/../lib/tools.jar</exists></file>
    </activation>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.sun.tools.jxc.maven2</groupId>
                    <artifactId>maven-jaxb-schemagen-plugin</artifactId>
                    <dependencies>
                        <dependency>
                            <groupId>com.sun</groupId>
                            <artifactId>tools</artifactId>
                            <version>1.7</version>
                            <scope>system</scope>
                            <systemPath>${java.home}/../lib/tools.jar</systemPath>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</profile>
yegor256
  • 102,010
  • 123
  • 446
  • 597
0

Not sure anyone is listening to this thread anymore but, what the hey...

I used the transformSchemas option e.g.

<transformSchemas>
    <transformSchema>
        <uri>YOUR NS IN YOUR GENERATED SCHEMA FILE</uri>
        <toFile>DESIRED NAME OF YOUR XSD FILE</toFile>
    </transformSchema>
</transformSchemas>

cheers

-m.

danopz
  • 3,310
  • 5
  • 31
  • 42
m3zk3th
  • 1
  • 2