wsdl2java icon indicating copy to clipboard operation
wsdl2java copied to clipboard

Not able to run project as jar, works fine in IDE

Open DPetrunov opened this issue 6 years ago • 0 comments

Hey guys,

I've used this plugin to generate some java files based on a WSDL for a Spring Boot 2.0+ project. It runs fine when I run in it in IntelliJ/Eclipse, however when i package it to a jar and try to run it the JAXBContext for my Jaxb2Marshaller complains about some files missing the XMLElementRef annotation. Here's a bit more details:

This is my build.gradle

configurations {

jaxb

}

buildscript {

ext {

    springBootVersion = "${springBootVersion}"
}

repositories {

    jcenter()
    mavenCentral()

    maven {

        url "https://plugins.gradle.org/m2/"
    }
}

dependencies {

    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath('se.transmode.gradle:gradle-docker:1.2')
    classpath('no.nils:wsdl2java:0.10')
}

}

apply plugin: 'java' apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'docker' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'no.nils.wsdl2java'

group = 'com.urbanise.middleware' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8

repositories {

maven {

    mavenLocal()
    jcenter()

}

task genJaxb {

ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schemaDir = "${projectDir}/src/main/resources"

outputs.dir classesDir

doLast() {

    project.ant {

        taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", classpath: configurations.jaxb.asPath
        mkdir(dir: sourcesDir)
        mkdir(dir: classesDir)

        xjc(destdir: sourcesDir) {

            schema(dir: schemaDir, includes: "**/*.xsd")
            arg(value: "-wsdl")
            produces(dir: sourcesDir, includes: "**/*.java")
        }

        javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true, debugLevel: "lines,vars,source",
                classpath: configurations.jaxb.asPath, includeantruntime: "false") {

            src(path: sourcesDir)
            include(name: "**/*.java")
            include(name: "*.java")
        }

        copy(todir: classesDir) {

            fileset(dir: sourcesDir, erroronmissingdir: false) {
                exclude(name: "**/*.java")
            }
        }
    }
}

}

bootJar {

baseName = 'urgtech-plaza'
version = '0.0.1-SNAPSHOT'
from genJaxb.classesDir
dependsOn wsdl2java

}

dependencies {

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail'

implementation group: 'org.springframework', name: 'spring-orm'

implementation group: 'org.springframework.cloud', name: 'spring-cloud-aws-autoconfigure'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-aws-messaging'

implementation group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: "${springSecurityOAuth2Version}"
implementation group: 'org.springframework.security.oauth', name: 'spring-security-oauth2'

implementation group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${apacheCommonsVersion}"
implementation group: 'wsdl4j', name: 'wsdl4j', version: "${wsdl4JVersion}"

implementation group: 'org.postgresql', name: 'postgresql', version: "${postgresqlVersion}"

implementation group: 'org.flywaydb', name: 'flyway-core', version: "${flywayVersion}"

implementation group: 'com.google.guava', name: 'guava', version: "${guavaVersion}"

implementation group: 'org.apache.commons', name: 'commons-text', version: "${apacheCommonsTextVersion}"
implementation group: 'commons-validator', name: 'commons-validator', version: "${apacheValidationVersion}"

implementation group: 'org.apache.camel', name: 'camel-spring-boot', version: "${camelVersion}"
implementation group: 'org.apache.camel', name: 'camel-jackson', version: "${camelVersion}"
implementation group: 'org.apache.camel', name: 'camel-metrics', version: "${camelVersion}"

implementation group: 'io.hawt', name: 'hawtio-springboot', version: "${hawtIoVersion}"
implementation group: 'io.hawt', name: 'hawtio-web', version: "${hawtIoWebVersion}"
implementation group: 'io.hawt', name: 'hawtio-core', version: "${hawtIoVersion}"
implementation group: 'io.hawt', name: 'hawtio-system', version: "${hawtIoVersion}"

implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda'

implementation group: 'org.freemarker', name: 'freemarker', version: "${freemakerVersion}"

implementation group: 'com.amazonaws', name: 'aws-java-sdk-ses', version: "${awsSDKSESVersion}"

compileOnly group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'

jaxb group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: "${jaxbxjcVersion}"

implementation(files(genJaxb.classesDir).builtBy(genJaxb))

testImplementation('org.springframework.boot:spring-boot-starter-test')

}

dependencyManagement {

applyMavenExclusions false

imports {

    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.SR2'
}

}

wsdl2java {

generatedWsdlDir = file("${projectDir}/src/main/java/com/urbanise/middleware/urgtechplaza/generated")
wsdlsToGenerate = [
        ['-autoNameResolution', 'src/main/resources/urgtech.wsdl']
]
wsdlDir = file("$projectDir/src/main/resources")
locale = Locale.ENGLISH
stabilizeAndMergeObjectFactory = true

}

wsdl2javaExt {

cxfVersion = "3.3.2"
deleteGeneratedSourcesOnClean = true

}

compileJava.dependsOn wsdl2java

sourceSets {

main.java.srcDirs += [wsdl2java.generatedWsdlDir]

}

and when i run the jar generated by bootJar task I get:

org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 69 counts of IllegalAnnotationExceptions There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract}Data. this problem is related to the following location: at protected javax.xml.bind.JAXBElement urgtech.service.data.datacontract.File.data at urgtech.service.data.datacontract.File at protected java.util.List urgtech.service.data.datacontract.Files.file at urgtech.service.data.datacontract.Files at public javax.xml.bind.JAXBElement urgtech.service.data.datacontract.operation.ObjectFactory.createCreateQuoteFiles(urgtech.service.data.datacontract.Files) at urgtech.service.data.datacontract.operation.ObjectFactory at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.CreateQuote.data at service.urgtech.supplierapi.service.CreateQuote at public service.urgtech.supplierapi.service.CreateQuote service.urgtech.supplierapi.service.ObjectFactory.createCreateQuote() at service.urgtech.supplierapi.service.ObjectFactory at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ReadAssignments.authentication at service.urgtech.supplierapi.service.ReadAssignments There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract/Response}Message. this problem is related to the following location: at protected javax.xml.bind.JAXBElement urgtech.service.data.datacontract.response.RequestStatus.message at urgtech.service.data.datacontract.response.RequestStatus at public javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ObjectFactory.createCreateQuoteResponseCreateQuoteResult(urgtech.service.data.datacontract.response.RequestStatus) at service.urgtech.supplierapi.service.ObjectFactory at protected javax.xml.bind.JAXBElement service.urgtech.supplierapi.service.ReadAssignments.authentication at service.urgtech.supplierapi.service.ReadAssignments There's no ObjectFactory with an @XmlElementDecl for the element {UrgTech/Service/Data/DataContract/Response}CallerName. this problem is related to the following location:

etc.etc.etc.

I did a dependency analysis with gradle and everything seems to be aligned properly. Am I missing something obvious here?

DPetrunov avatar Jun 13 '19 11:06 DPetrunov