users@jaxb.java.net

NPE when generating Schema on Windows

From: Matt Raible <mraible_at_gmail.com>
Date: Mon, 16 Nov 2009 12:05:53 -0500

Hello all,

I'm using the following Maven plugin on a project with Maven 2.2.1 and Java 6.

<groupId>com.sun.tools.jxc.
maven2</groupId>
<artifactId>maven-jaxb-schemagen-plugin</artifactId>
<version>1.2</version>
<executions>
    <execution>
        <phase>process-sources</phase>
        <goals>
            <goal>generate</goal>
        </goals>
    </execution>
</executions>

First of all, what's the difference between this plugin and the Maven
plugin hosted at Codehaus?

http://mojo.codehaus.org/jaxb2-maven-plugin/index.html

Secondly, I'm seeing the following error after trying to introduce a
second schema to my project. The first schema is generated from Java
classes, while the 2nd one is XUL, which I've created some classes to
map to.

Problem encountered during annotation processing;
see stacktrace below for more information.
java.lang.InternalError: Error escaping one of these uris:
        C:\Source\project\services\target\cla
sses\META-INF\com\company\schema\xul.xsd
        C:\Source\project\services\target\cla
sses\META-INF\com\company\schema\conversation-definition-1.0.xsd
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.relativize(XmlSchema
Generator.java:1272)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(Xm
lSchemaGenerator.java:482)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$600
(XmlSchemaGenerator.java:341)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGener
ator.java:322)
        at com.sun.tools.xjc.api.impl.j2s.JAXBModelImpl.generateSchema(JAXBModel
Impl.java:153)
        at com.sun.tools.jxc.apt.SchemaGenerator$1.process(SchemaGenerator.java:
78)
        at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.
process(AnnotationProcessors.java:60)
        at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
        at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
        at com.sun.tools.apt.main.Main.compile(Main.java:1102)
        at com.sun.tools.apt.main.Main.compile(Main.java:964)
        at com.sun.tools.apt.Main.processing(Main.java:95)
        at com.sun.tools.apt.Main.process(Main.java:85)
        at com.sun.tools.apt.Main.process(Main.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.tools.jxc.AptBasedTask$InternalAptAdapter.execute(AptBasedTas
k.java:61)
        at com.sun.tools.jxc.AptBasedTask.compile(AptBasedTask.java:108)
        at com.sun.tools.jxc.maven2.SchemaGenAdapter.execute(SchemaGenAdapter.ja
va:111)
        at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:161
)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] schema generation failed
[INFO] ------------------------------------------------------------------------
[INFO] Trace
schema generation failed
        at com.sun.tools.jxc.AptBasedTask.compile(AptBasedTask.java:110)
        at com.sun.tools.jxc.maven2.SchemaGenAdapter.execute(SchemaGenAdapter.ja
va:111)
        at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:161
)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)

In the plugin configuration, I reference both XSDs with the following
(where xul.xsd is located in my src/main/resources folder).

                <configuration>
                    <includes>
                        <include>**/schema/**</include>
                    </includes>
                    <destdir>

${project.build.directory}/classes/META-INF/com/company/schema
                    </destdir>
                    <schemas>
                        <schema>

<namespace>http://www.company.com/schema/conversation-definition</namespace>
                            <file>conversation-definition-1.0.xsd</file>
                        </schema>
                        <schema>

<namespace>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</namespace>
                            <file>xul.xsd</file>
                        </schema>
                    </schemas>
                </configuration>

The strange thing is everyone works fine on Linux and OS X. But it
fails with the exception above when run on Windows. Any ideas?

Thanks,

Matt