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

NoSuchMethodError in io.javalin.openapi.plugin.DefinitionConfiguration #233

Open
mikera opened this issue Nov 5, 2024 · 2 comments
Open

Comments

@mikera
Copy link

mikera commented Nov 5, 2024

I recently encountered the following exception (Javalin 6.3.0), which occurs when trying to access the swagger UI:

[JettyServerThreadPool-165] ERROR io.javalin.Javalin - Fatal error occurred while servicing http-request
java.lang.NoSuchMethodError: 'io.javalin.openapi.plugin.DefinitionConfiguration io.javalin.openapi.plugin.DefinitionConfiguration.withInfo(java.util.function.Consumer)'
	at convex.restapi.RESTServer.lambda$8(RESTServer.java:135)
	at io.javalin.openapi.plugin.OpenApiPlugin$createDocumentation$1.invoke(OpenApiPlugin.kt:36)
	at io.javalin.openapi.plugin.OpenApiPlugin$createDocumentation$1.invoke(OpenApiPlugin.kt:25)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)

I would expect this not to throw such an exception, because the code compiles fine and the target method apparently exists.

Calling code looks like:

	protected void addOpenApiPlugins(JavalinConfig config) {
		String docsPath="openapi-plugin/openapi-default.json";
		
		config.registerPlugin(new OpenApiPlugin(pluginConfig -> {
                    pluginConfig
                    .withDocumentationPath(docsPath)
                    .withDefinitionConfiguration((version, definition) -> {
                    	DefinitionConfiguration def=definition;
                        def=def.withInfo((Consumer <OpenApiInfo> )info -> {
					info.setTitle("Convex REST API");
					info.setVersion("0.7.0");
                        });
                    });
		}));

		config.registerPlugin(new SwaggerPlugin(swaggerConfiguration->{
			swaggerConfiguration.setDocumentationPath(docsPath);
		}));
		config.registerPlugin(new ReDocPlugin(reDocConfiguration -> {
	        reDocConfiguration.setDocumentationPath(docsPath);
	    }));
		
		for (JsonSchemaResource generatedJsonSchema : new JsonSchemaLoader().loadGeneratedSchemes()) {
	        System.out.println(generatedJsonSchema.getName());
	    }
	}

This looks like a bug, though I could be doing something wrong?

@dzikoysk
Copy link
Member

dzikoysk commented Dec 9, 2024

This function is definitely there:

Maybe you faced some issue with local internal build cache? 🤔 Does it throw when you're launching your code within IDE, or it comes from the final jar?


Sorry for late response, I have a lot of notifications and just missed that one. Next time, feel free to ping me in issues/on Discord if I won't reply within a couple of days 😔

@mikera
Copy link
Author

mikera commented Dec 15, 2024

Thanks @dzikoysk ! I think I managed to solve the problem though I'm not entirely sure how. Possibly some interaction with the way that Eclipse handles JPMS modules?

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

No branches or pull requests

2 participants