使用XJC插件的Maven构建在Jenkins

时间:2015-12-23 15:15:02

标签: java maven jenkins

我们正在尝试构建一个maven项目,我们使用jaxb2-maven-plugin(版本1.4)从一些xsd文件生成Java类。 一次执行的配置如下所示:

<execution>
<id>executionA</id>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaFiles>path/A.xsd</schemaFiles>
<packageName>package.info.name</packageName>
<staleFile>target/generated-sources/A.jaxb</staleFile>
<bindingFiles>A.xjb</bindingFiles>
</configuration>
<goals>
<goal>xjc</goal>
</goals>
</execution>

因此,我们有一个A.xjb绑定文件,该文件位于默认的&#s; src / main / xjb&#39;文件夹,它指定一些绑定。 例如:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:extensionBindingPrefixes="xjc">
<jxb:globalBindings>
<xjc:simple />
<xjc:serializable uid="1" />
...
</jxb:globalBindings>
<jxb:bindings schemaLocation="../path/A.xsd" node="/xs:schema">
<jxb:schemaBindings>
...
</jxb:schemaBindings>
<jxb:bindings node="//xs:element[@name = 'XXX']">
...
</jxb:bindings>
...
</jxb:bindings>
</jxb:bindings>

在Jenkins上执行构建时发生以下错误:

  

[INFO] - jaxb2-maven-plugin:1.4:xjc(executionA)@ schemas - [INFO]   生成源... [INFO]解析模式... [错误]   文件:/opt/home/diojenkins/workspace/project/schemas/src/main/xjb/A.xjb [12118]   com.sun.istack.SAXParseException2;的systenId:   文件:/opt/home/diojenkins/workspace/project/schemas/src/main/xjb/A.xjb;   lineNumber:12; columnNumber:118;   &#34;文件:/opt/home/diojenkins/workspace/project/schemas/src/main/path/A.xsd"   不是这个汇编的一部分。这是一个错误   &#34;文件:/home/diojenkins/workspace/project/schemas/src/main/path/A.xsd" ;?   在   com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Internalizer.java:598)   在   com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Internalizer.java:592)   在   com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:246)   在   com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:375)   在   com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:136)   在   com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:98)   在   com.sun.tools.xjc.reader.internalizer.DOMForest.transform(DOMForest.java:447)   在com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:342)   at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:374)   在com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)at   com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)at at   com.sun.tools.xjc.Driver.run(Driver.java:313)at   org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:314)   在   org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)   在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)   在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)   在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)   在   org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)   在   org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)   在   org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)   在   org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)   在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)at at   org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)at at   org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)at   org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)   在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   在java.lang.reflect.Method.invoke(Method.java:606)at   org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)   在   org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)   在jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)   在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   在java.lang.reflect.Method.invoke(Method.java:606)at   hudson.maven.Maven3Builder.call(Maven3Builder.java:136)at   hudson.maven.Maven3Builder.call(Maven3Builder.java:71)at   hudson.remoting.UserRequest.perform(UserRequest.java:121)at   hudson.remoting.UserRequest.perform(UserRequest.java:49)at   hudson.remoting.Request $ 2.run(Request.java:326)at   hudson.remoting.InterceptingExecutorService $ 1.call(InterceptingExecutorService.java:68)   在java.util.concurrent.FutureTask.run(FutureTask.java:262)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)   在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)   at java.lang.Thread.run(Thread.java:745)[INFO]无法解析   架构。

您可能需要知道/ opt / home / diojenkins和/ home / diojenkins之间存在符号链接,因此它们是相同的。

只有在Jenkins上执行构建时才会出现错误,如果我们在Jenkins工作区中使用相同的选项构建它就可以正常工作。任何人都可以帮助我们吗?

0 个答案:

没有答案