3

I use cxf-codegen-plugin to generate a series of WS clients using Maven, on construction time. These WSDL reference some XSD schema definitions using a relative path like so: ../someService/schema.xsd

Now when I trigger a construction from Eclipse this works properly since my XSD files are placed in the right path.

But when I launch a construction job from Jenkins, it fails because it seems it's using Jenkins workspace as the root of the construction.

I don't even know if you can change this behavior of Jenkins, but since I have no control over my Jenkins instance, what I would like to know is for cxf-codegen-plugin to exclude XSD processing altogether, and then generate those classes explicitly using a different execution phase with a different plugin.

I've read you can do it like this:

<defaultOptions>
    <extraargs>
        <extraarg>-nexclude</extraarg>
        <extraarg>http://*.ws.cntxes.emprego.xunta.es</extraarg>
    </extraargs>
</defaultOptions>

But this assumes I know those namespaces prior to constructing, which I don't (WSDL files are taken from external dependencies using maven dependency plugin).

I also tried:

<wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>
<includes>
    <include>
    **/*.wsdl
    </include>
</includes>
<excludes>
    <exclude>
     *.xsd
    </exclude>
</excludes>

But this does not work, the plugin just keeps parsing the XSD files and generating the related classes.

Is there any other way I'm missing to prevent the parsing of XSD files and just process the WSDL definitions?

EDIT: this is the error Jenkins is giving me:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources-wsclient-cxf) on project my-project: Execution generate-sources-wsclient-cxf of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : file:/var/lib/jenkins/workspace/MYPROJECT/myproject-webservice/src/main/resources/wsdl/Descriptor/serviceDescriptor.wsdl
[ERROR] Caused by : WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing '../xsd/schema.xsd'.: java.io.FileNotFoundException: /var/lib/jenkins/workspace/xsd/actividadFormativa.xsd (No such file or directory)

It is looking on the root of jenkins' workspace instead of /var/lib/jenkins/workspace/MYPROJECT/myproject-webservice/src/main/resources/wsdl/xsd/schema.xsd

Xstian
  • 8,184
  • 10
  • 42
  • 72
MichelReap
  • 5,630
  • 11
  • 37
  • 99
  • Main question is, why relative paths behave diffently in Jenkins? Does it work from command line with Maven? – lexicore Dec 03 '14 at 09:21
  • Im not sure but to my understanding it uses mvn command line console to build the project – MichelReap Dec 03 '14 at 09:33
  • I have updated my question to reflect Jenkins' error message – MichelReap Dec 03 '14 at 09:36
  • What I am asking is - have you tried building the project with Maven in CLI on the developer machine? In exactly the same project that you've in Eclipse? The question is - if the problem in in Jenkins vs. Eclipse or in Maven from command line vs. Maven from Eclipse. – lexicore Dec 03 '14 at 09:53
  • I will now, and let you know – MichelReap Dec 03 '14 at 09:58
  • From CLI, on my computer, it works exactly as it does from eclipse. – MichelReap Dec 03 '14 at 10:06
  • First of all why a relative path in WSDL isn't it a bug from your provider which shouldn't be fixed first. Second is there any requirement for regeneration of classes in during jenkins execution, anyways it would have been created during build phase. so shouldn't it be skiped? – Karthik Prasad Dec 04 '14 at 15:21
  • @MichaelReap I have the same problem but with the WSDL files. Could you solve your problem? – Lonzak Jul 13 '16 at 13:21
  • @MichelReap I know this is old, but did you ever figure out how to do this? – Kikkomann Aug 20 '21 at 07:03

1 Answers1

1

I had the same problem (only with the wsdl files). After long research I figured out that the problem was a case sensitivity issue - windows (local CLI and eclipse builds) and the linux/unix hudson/jenkins build environment:

The problematic wsdl had a big letter S

<wsdlOption>
 <wsdl>${basedir}/src/main/resources/Some.wsdl</wsdl>
</wsdlOption>

But on the filesystem the file was some.wsdl So it was not the path issue (.../workspace/...) as I also initially expected...

Lonzak
  • 9,334
  • 5
  • 57
  • 88