Skip to content

Cannot get property 'imports' on null object #13

@realdadfish

Description

@realdadfish

I'm trying to generate Kotlin classes for my XSDs. This is the calling code:

class CodeGen extends KotlinGen {
    CodeGen(File schemaFile, File targetDir, String targetPackage) {
        super()
        schemaURL = schemaFile.toURI().toURL()
        srcDir = targetDir
        packageName = targetPackage
        addSuffixToEnumClass = null
        anyPropertyName = 'text'
    }
}

The XSD file is valid (and was used to create Java Beans via xjc before), the targetDir is valid as well and exists, the package name is non-empty. When I execute this code in my custom task, I receive the following crash:

java.lang.NullPointerException: Cannot get property 'imports' on null object
        at com.javagen.schema.model.MSource$Imports.leftShift(MSource.groovy:83)
        at com.javagen.schema.model.MSource$Imports$leftShift.call(Unknown Source)
        at com.javagen.schema.kotlin.KotlinJacksonCallback$_gen_closure1.doCall(KotlinJacksonCallback.groovy:116)              at com.javagen.schema.kotlin.KotlinJacksonCallback.gen(KotlinJacksonCallback.groovy:113)
        at com.javagen.schema.kotlin.KotlinJacksonCallback$gen.call(Unknown Source)
        at com.javagen.schema.java.JavaGen.visit(JavaGen.groovy:357)
        at com.javagen.schema.xml.XmlSchemaVisitor$visit$2.call(Unknown Source)
        at com.javagen.schema.xml.XmlSchemaVisitor$Trait$Helper.visit(XmlSchemaVisitor.groovy:37)
        at com.javagen.schema.xml.XmlSchemaVisitor$Trait$Helper$visit$1.call(Unknown Source)
        at com.javagen.schema.java.JavaGen.visit(JavaGen.groovy:143)
        at com.javagen.schema.java.JavaGen$visit.callCurrent(Unknown Source)
        at com.javagen.schema.kotlin.KotlinGen.gen(KotlinGen.groovy:186)
        at com.javagen.schema.kotlin.KotlinGen$gen.call(Unknown Source)

My Groovy-foo is not good enough to figure out whats going on here, so maybe you have an idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions