Skip to content

ClassNotFoundException from ApiModelProperty and dataType #12

@benco33

Description

@benco33

I'm upgrading a Scala + Play app (2.11.8 --> 2.12.8 and 2.5.12 --> 2.8.16, respectively) and was having issues upgrading to 1.7.1 of io.swagger:swagger-play2, presumably due to transient dependencies as described in https://stackoverflow.com/a/68015459, which is how I discovered this fork.

Since switching to this fork in my upgrade branch, I did initially experience numerousClassNotFoundException errors relating to the dataType field under ApiImplicitParam, which I was able to resolve by switching over to using dataTypeClass and classOf per swagger-api#174.

However, I experienced a very similar error coming from an @ApiModelProperty annotation, like:

@ApiModelProperty(dataType = "com.org.full.big.long.classpath.but.defined.in.same.file.as.this.annotation.MyClassOfInterest")

resulting in:

java.lang.ClassNotFoundException: MyClassOfInterest
at java.base / java.net.URLClassLoader.findClass (URLClassLoader.java: 476)
at java.base / java.lang.ClassLoader.loadClass (ClassLoader.java: 589)
...

I was not able to resolve this exception in a similar manner to ApiImplicitParam as it appears the dataTypeClass is not available for ApiModelProperty. Is this a remaining / known bug or likely user error? Suggestions / workarounds?

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