user5435ren
user5435ren

Reputation: 21

SAXParseException when compiling through maven

Hi all I know this might of been asked before, so sorry in advance(havnt got enough reps to comment on other thread)

When I compile my project through mvn I get some SAXParse exceptions, even though I can build and run my project no problem. I'm just cleaning up some build warnings and would like to know why this occurs...any help greatly appreciated

LOG.....

[INFO] --- jaxb2-maven-plugin:1.6:xjc (Shop) @ the-project ---
[INFO] Generating source...
[INFO] parsing a schema...
**[INFO] compiling a schema...
[WARNING] null[-1,-1]
org.xml.sax.SAXParseException; generating code**
at com.sun.tools.xjc.ErrorReceiver.debug(ErrorReceiver.java:140)
at com.sun.tools.xjc.Driver.run(Driver.java:361)
at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:316)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

the POM....

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
    <execution>
        <id>The</id>
        <goals>
            <goal>xjc</goal>
        </goals>
        <configuration>
            <schemaIncludes>
                <include>The.xsd</include>                              
            </schemaIncludes>
            <schemaDirectory>${schema.directory.The}</schemaDirectory>
            <packageName>${generated.source.The}</packageName>
            <verbose>true</verbose>
            <clearOutputDir>false</clearOutputDir>
        </configuration>
    </execution>
</executions>

Upvotes: 2

Views: 1584

Answers (1)

laoseth
laoseth

Reputation: 81

I was having the same problem, and the issue is that the verbose flag is turned on, and the logging for verbose creates errors just for the sake of logging.

There is basically a "bug" in the XJC code, where they call

//generate actual code receiver.debug("generating code");

and the debug statement is written

public final void debug( String msg ) {
    info( new SAXParseException(msg,null) );
}

which then calls

public void info(SAXParseException exception) {
    if(opt.verbose)
       super.info(exception);
 }

Thus, because of the way the the logger is implimented, it logs a full stack trace. This is even more fun to find, because the SAXParseExceptionis only created to create a logging statement, and is never thrown.

Upvotes: 4

Related Questions