通过maven编译时出现SAXParseException

时间:2015-03-06 16:53:54

标签: maven-3 jaxb2 saxparseexception

大家好我知道之前可能会有这样的问题,所以提前抱歉(havnt有足够的代表在其他帖子上发表评论)

当我通过mvn编译我的项目时,我得到一些SAXParse异常,即使我可以构建和运行我的项目没问题。我只是清理一些构建警告,并想知道为什么会发生这种情况......任何帮助都非常感激

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)

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>

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,问题是verbose标志已打开,而verbose的日志记录只是为了记录而创建错误。

XJC代码中基本上存在“错误”,他们调用

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

并编写调试语句

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

然后调用

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

因此,由于记录器的实现方式,它会记录完整的堆栈跟踪。查找起来更有趣,因为SAXParseException仅用于创建日志语句,并且永远不会被抛出。