Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running plugin returns the error "Scanner SubTypesScanner was not configured" #96

Open
rujiel opened this issue May 8, 2022 · 7 comments · May be fixed by #119
Open

Running plugin returns the error "Scanner SubTypesScanner was not configured" #96

rujiel opened this issue May 8, 2022 · 7 comments · May be fixed by #119

Comments

@rujiel
Copy link

rujiel commented May 8, 2022

Hello, I'm trying to set up automatic register of resources with this plugin, but having some difficulty getting it to work with Tomcat. When running mvn verify I'm getting the cryptic error "Scanner SubTypesScanner was not configured". It sounds like something is exploding when trying to use reflection.

I am currently trying with version 2.1.6 of the plugin. For version 1 of the plugin and swagger, the plugin ran properly but it outputted a swagger.json that was nearly empty, so I'm trying v2. I'm using JDK 17, here are the important parts of my pom and my classes, am I doing something majorly wrong?

A couple other questions
* is the swagger annotations dependency required for this to work?
* It used to be with BeanConfig I could tell it to automatically scan for resources, is there a way I need to do that for SwaggerConfiguration?


    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-jaxrs2</artifactId>
        <version>2.2.0</version>
    </dependency>

  <plugin>
	<groupId>io.openapitools.swagger</groupId>
	<artifactId>swagger-maven-plugin</artifactId>
	<version>2.1.6</version>
	<configuration>
	  <resourcePackages>
		<resourcePackage>org.xyz.boundary</resourcePackage>
	  </resourcePackages>
	  <outputDirectory>${basedir}/target/</outputDirectory>
	  <outputFilename>swagger</outputFilename>
	  <outputFormats>JSON</outputFormats>
	  <prettyPrint>true</prettyPrint>
	</configuration>
	<executions>
	  <execution>
		<goals>
		  <goal>generate</goal>
		</goals>
	  </execution>
	</executions>
  </plugin>

My resource

	@Path("/test")
	@Tag(name = "test", description = "test")
	public class TestResource {
		@GET
		@Operation(summary = "do ting")
		@Produces("application/json")
		public ThingDO getThing() {
			return new ThingDO("testy");
		}
	}

Application config

	@ApplicationPath("/rs")
	public class ApplicationConfig extends Application {
		public ApplicationConfig(@Context ServletConfig config) {
			OpenAPI bc = new OpenAPI();
			Info info = new Info()
				.title("Test")
				.description("better")
				.contact(new Contact().email("hello@hello.com"))
				.version("1.0");
			bc.info(info);
			SwaggerConfiguration oasConfig = new SwaggerConfiguration()
				.openAPI(bc)
				.prettyPrint(true)
				.resourcePackages(Set.of("org.xyz.boundary"));
			try {
				new JaxrsOpenApiContextBuilder()
	//                .servletConfig(servletConfig)
					.application(this)
					.openApiConfiguration(oasConfig)
					.buildContext(true);
			} catch (OpenApiConfigurationException e) {
				throw new RuntimeException(e.getMessage(), e);
			}
		}
	}

@amirgalor-gong
Copy link

I'm getting similar issue with the about the same configuration

@rujiel
Copy link
Author

rujiel commented May 20, 2022

FWIW I wound up getting openapi to work by not using the plugin, switching to tomee microprofile and including it:

<dependency>
  <groupId>org.eclipse.microprofile.openapi</groupId>
  <artifactId>microprofile-openapi-api</artifactId>
  <version>3.0</version>
</dependency>

From there, the /openapi endpoint sends back a yaml file, and swagger ui works once I set that address for it.

@langecode
Copy link
Member

langecode commented May 21, 2022 via email

@Kiiv
Copy link

Kiiv commented Oct 19, 2022

Same problem here, the plugin is not usable for me at the moment.

@JonasCir
Copy link

Same here:

<plugin>
	<groupId>io.openapitools.swagger</groupId>
	<artifactId>swagger-maven-plugin</artifactId>
	<version>2.1.6</version>
	<executions>
		<execution>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>io.swagger.core.v3</groupId>
			<artifactId>swagger-jaxrs2</artifactId>
			<version>2.1.13</version>
		</dependency>
	</dependencies>
</plugin>

Stacktrace is:

    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-swagger of goal io.openapitools.swagger:swagger-maven-plugin:2.1.6:generate failed: Scanner SubTypesScanner was not configured
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.reflections.ReflectionsException: Scanner SubTypesScanner was not configured
    at org.reflections.Store.get (Store.java:39)
    at org.reflections.Store.get (Store.java:61)
    at org.reflections.Store.get (Store.java:46)
    at org.reflections.Store.getAll (Store.java:93)
    at org.reflections.Reflections.getSubTypesOf (Reflections.java:404)
    at io.openapitools.swagger.JaxRSScanner.applicationInstance (JaxRSScanner.java:44)
    at io.openapitools.swagger.GenerateMojo.resolveApplication (GenerateMojo.java:152)
    at io.openapitools.swagger.GenerateMojo.execute (GenerateMojo.java:124)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@ashonline
Copy link

I had this exact issue with v2.1.6 of the plugin and resolved it by dropping down to v2.1.5.

@CarstenWickner CarstenWickner linked a pull request Jan 3, 2024 that will close this issue
@CarstenWickner
Copy link

I encountered the same issue here.

This is a known limitation of the reflections library. One could change the way it is being used (just different configuration) or even better: replace the unmaintained reflections library with classgraph.
I've created #119 to make that change.

With that new version of the plugin, the Swagger generation works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants