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

Cannot invoke "java.util.Map.size()" because "map" is null #116

Open
nobody102 opened this issue Nov 13, 2023 · 10 comments · May be fixed by #122
Open

Cannot invoke "java.util.Map.size()" because "map" is null #116

nobody102 opened this issue Nov 13, 2023 · 10 comments · May be fixed by #122

Comments

@nobody102
Copy link

wildfly 27. Using swagger maven plugin, with JDK 21, and getting the above error.



io.openapitools.swagger
swagger-maven-plugin

            <configuration>
                <resourcePackages>
                    <resourcePackage>com.hsntech.bannerjwt.rest</resourcePackage>
                </resourcePackages>
                <outputDirectory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}</outputDirectory>
                <outputFilename>openapi</outputFilename>
                <outputFormats>
                    <outputFormat>JSON</outputFormat>
                    <outputFormat>YAML</outputFormat>
                </outputFormats>
                <prettyPrint>true</prettyPrint>
                <swaggerConfig>
                    <servers>
                        <server>
                            <url>/SecurityService/rest</url>
                            <description>Endpoint URL for Banner Security Service API's</description>
                        </server>
                    </servers>
                    <info>
                        <title>Security Service - OpenAPI</title>
                        <version>1.0.0</version>

                        <description>REST API Framework designed to allow third party vendors the ability to
                            access Banner client data without having to go through the Banner UI Framework.</description>
                    </info>
                </swaggerConfig>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <!-- Download Swagger UI webjar. -->
            <artifactId>maven-dependency-plugin</artifactId>
            <version>${maven-dependency-plugin.version}</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.webjars</groupId>
                                <artifactId>swagger-ui</artifactId>
                                <version>${swagger-ui.version}</version>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>${project.build.directory}/swagger-ui</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <!-- Add Swagger UI resources to the war file. -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven-war-plugin.version}</version>
            <configuration>
                <webResources combine.children="append">
                    <resource>
                        <directory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}</directory>
                        <includes>
                            <include>**/*.*</include>
                        </includes>
                        <targetPath>swagger-ui</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <!-- Replace the OpenAPI specification example URL with the local one. -->
            <groupId>com.google.code.maven-replacer-plugin</groupId>
            <artifactId>replacer</artifactId>
            <version>${replacer.version}</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>replace</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <file>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html</file>
                <replacements>
                    <replacement>
                        <token>http://petstore.swagger.io/v2/swagger.json</token>
                        <!-- value>/api/openapi.json</value -->
                        <!-- value>'http://localhost:8080/SecurityService/openapi.json'</value -->
                        <value>openapi.yaml</value>
                    </replacement>
                </replacements>
            </configuration>
        </plugin>
    </plugins>
</build>
@salake
Copy link

salake commented Nov 16, 2023

Same issue here

@ataraxus
Copy link

Same here

@ataraxus
Copy link

Ah got it, used already jakarta but this plugin searches for javax :/

@dgautier
Copy link

dgautier commented Feb 12, 2024

@ataraxus seems to be quite annoying, anybody knows about someone fixing this ?

@prabhat2020
Copy link

@ataraxus so this library can't be used to generate for jakarta apis.Did you got any other plugin to generate open api spec

@ataraxus
Copy link

ataraxus commented Mar 8, 2024

I wrote a custom plugin. My API Definitions are in a separate Module and my plugin, stubs them all during compiletime and generates the openApi spec using this plugin.

@dgautier dgautier linked a pull request Mar 12, 2024 that will close this issue
@bdevos
Copy link

bdevos commented Apr 4, 2024

I do not know if this is the exact issue we ran into, but it sounds so similar that maybe this info helps.

We saw this exact same error and the reason seems to be that when there are no classes with @Path annotations in the package defined in <resourcePackage> of the plugin.

At first I thought the workaround was adding more <resoucePackage> to the plugins config, but we just needed to add the following to the config:

<useResourcePackagesChildren>true</useResourcePackagesChildren>

@mali30
Copy link

mali30 commented Apr 8, 2024

I wrote a custom plugin. My API Definitions are in a separate Module and my plugin, stubs them all during compiletime and generates the openApi spec using this plugin.

Could you share that custom plugin that you wrote or atleast a working example. I am running into this issue now and it seems like the fix hasn't been merged yet by the mainainer.

@mali30
Copy link

mali30 commented Apr 8, 2024

I do not know if this is the exact issue we ran into, but it sounds so similar that maybe this info helps.

We saw this exact same error and the reason seems to be that when there are no classes with @Path annotations in the package defined in <resourcePackage> of the plugin.

At first I thought the workaround was adding more <resoucePackage> to the plugins config, but we just needed to add the following to the config:

<useResourcePackagesChildren>true</useResourcePackagesChildren>

I tried this but it didn't work for me unfortunantly.

@traviscollins
Copy link

Same issue in JDK 17

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.

8 participants