简体   繁体   中英

JavaToWS Error: java.lang.NoClassDefFoundError

I am using CXF JavaToWS to create a WSDL file based on my Java code. I am using Gradle for the build. My Java code references another project and I have them tied together through my settings.gradle and build.gradle files. That is all working well.

The problem I am seeing is JavaToWS is getting a NoClassDefFoundError on one of the classes that is in the secondary project. It's almost as if JavaToWS does not have access to the classpath of the project. Eclipse finds everything it needs and the project builds without errors. It's just the JavaToWS step that fails. Any ideas on how I can get JavaToWS to see my classpath? Is there a way to pass in more than one parameter to the "-cp" argument maybe?

Here is my JavaToWS step in my gradle.build file:

task java2ws(type: JavaExec) {

    ext {
        outputDir = file("src/main/java")
        mainDir = file("$buildDir/classes/main")
        wsdlDir = file("src/main/resources/wsdl")
    }

    main = 'org.apache.cxf.tools.java2ws.JavaToWS'

    classpath = configurations.cxf

    // Arguments to be passed to JavaToWS.
    args '-cp', mainDir
    args '-s', outputDir
    args '-d', wsdlDir
    args '-classdir', mainDir
    args '-o', 'MyService.wsdl'
    args '-createxsdimports' 
    args '-verbose'
    args '-frontend', 'jaxws'
    args '-databinding', 'jaxb'
    args '-wsdl'
    args '-wrapperbean', 'com.foo.MyService'    
}

I was able to resolve this issue by changing the classpath line from:

classpath = configurations.cxf

to:

classpath = files(configurations.cxf, configurations.runtime)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM