-
Notifications
You must be signed in to change notification settings - Fork 52
ClassNotFoundException when jaxrs classes extends and/implement from other modules #158
Comments
Having looked some more I can verify that |
I worked around by hand-cranking the dependency urls into the Buildscript dependencies in a task in my build file.
|
This has been a long-standing issue with this plugin, there have been several issues opened regarding it, I believe this was the first one: |
Same error, is there at least a workaround ? |
The workaround from @melowe worked for me! More details of how to add it into your task fixGenerateSwaggerDocumentation {
doLast {
project.configurations.compileClasspath.resolve()
.collect { it.toURI().toURL() }
.each { buildscript.classLoader.addURL it }
}
}
generateSwaggerDocumentation.dependsOn fixGenerateSwaggerDocumentation |
If you fancy raising a PR to fix this rather than a work around, please do. I really don't get the time to dig into this kind of stuff at the moment (and won't do for a while yet). |
FWIW the above fix didn't work for me =( |
@jonnii That fix didn't work for me either |
The workaround mentioned above worked for me with the following environment:
And the following gradle.build (just part of it): plugins {
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.freefair.lombok' version '4.1.6'
id 'com.benjaminsproule.swagger' version '1.0.7'
}
dependencies {
runtimeOnly "org.postgresql:postgresql:42.0.0"
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"
...
}
...
swagger {
apiSource {
springmvc = false
locations = [ 'com.MYPACKAGENAME...' ]
schemes = [ 'https' ]
basePath = apiPath
info {
title = 'Pricing API'
version = apiVersion
description = 'Some description'
contact {
email = '[email protected]'
name = 'Eng Team'
}
}
swaggerDirectory = "${project.rootDir}/generated/swagger-ui"
}
}
// Workaround for an issue in the generateSwaggerDocumentation plugin
// check https://github.com/gigaSproule/swagger-gradle-plugin/issues/158#issuecomment-585823379
task fixGenerateSwaggerDocumentation {
doLast {
project.configurations.compileClasspath.resolve()
.collect { it.toURI().toURL() }
.each { buildscript.classLoader.addURL it }
}
}
generateSwaggerDocumentation.dependsOn fixGenerateSwaggerDocumentation |
By adding the flag to skip including super types and also adding the above work around my problems have been solved. Thanks all! |
Looks like the latest version 1.0.8 published a few days ago solve the issue, I could remove the workaround and now there is no more errors in the task. |
False positive 😞 , looks like I had a kind of cache even when I launch a |
This workaround does not work for me. After applying the workaround the classes in my project itself can't be found. Whereas before it just couldn't find any classes in my dependencies. Very weird. Can't quite put my finger on what is going wrong. |
@jonnii Which flag are you referring to? Link to doc that mentions this flag? |
@jonnii Oh, I see you are referring to the Including that plus the workaround does indeed work for me as well. |
The workaround alone does not fix the issue for me, and I am unable to update to version 1.0.8 of the plugin to use Has anyone who did not see their issue resolved with the workaround found any alternatives that do not require |
In my case, the plugin was scanning a class which inherited from a class coming from an external jar. This made it throw such numerous reflection exceptions about my class (since it probably couldn't find the parent class which it inherits from). |
Incorporate workaround for including classes from project dependencies in the classpath
The workaround didn't work for me, I am getting |
create separate configuration called "swagger" for building the classpath which will include all main project runtime class files
create separate configuration called "swagger" for building the classpath which will include all main project runtime class files
undo other fixes change default value for expandSuperTypes to false
undo other fixes change default value for expandSuperTypes to false
undo other fixes change default value for expandSuperTypes to false
@wakingrufus I see you are (hopefully) preparing a PR for this. Any luck? |
Looks like my PR was merged: 99091a1 🎉 |
Yeah, still trying to find the time to deal with CircleCI and it's OOM issues. The classic fun job of I can never replicate nor have the time to really look into it. I'm hoping to have some time this weekend to try it out. |
I'm unsure if this is an issue with the plugin itself or my fumbling around with Gradle.
Previously I used swagger-maven-plugin to generate the swagger descriptors and I basically ported like for like configuration to this plugin.
I have an Application class that extends a super class defined in another module. When plugin uses its ClassFinder to look the class up refections can't find the super class in any of its class loaders..
The text was updated successfully, but these errors were encountered: