microprofile-extensions / openapi-ext

Some extensions for MicroProfile OpenAPI
Apache License 2.0
22 stars 13 forks source link

org.microprofileext.openapi.swaggerui.OpenApiUiService MethodNotFound error #44

Closed WilliamYuhangLee closed 2 years ago

WilliamYuhangLee commented 2 years ago

Hi, I was trying out the helidon-feature-example, however when I ran the mvn -Prun-example clean install command, it gave me this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project openapi-helidon-features-example: Compilation failure: Compilation failure:
[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/UiApplication.java:[17,19] cannot find symbol
[ERROR]   symbol:   method of(java.lang.Class<org.microprofileext.openapi.swaggerui.OpenApiUiService>,java.lang.Class<org.microprofileext.openapi.swaggerui.StaticResourcesService>)
[ERROR]   location: interface java.util.Set
[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/MyApplication.java:[14,19] cannot find symbol
[ERROR]   symbol:   method of(java.lang.Class<org.microprofileext.openapi.features.example.GreetResource>)
[ERROR]   location: interface java.util.Set

This error also occurred when I tried to integrate the OpenAPI UI into my Helidon MP project, but in a slightly different format: a MethodNotFound error on io.smallrye.openapi.api.OpenApiConfigImpl.scanClasses().

Upon removing this dependency from my pom.xml, this error is gone. So I believe this is something to do with your project. Please help as I would really love to use the OpenAPI UI feature.

phillip-kruger commented 2 years ago

@tvallin can you comment ?

tvallin commented 2 years ago

Hi @WilliamYuhangLee, What JDK are you using to build the sample ?

WilliamYuhangLee commented 2 years ago

@tvallin Oracle GraalVM Enterprise Edition 22.2.0 macOS x86 for Java 17 JDK as found here

tvallin commented 2 years ago

Please use JDK 11 and let me know if you face the same issue.

WilliamYuhangLee commented 2 years ago

@tvallin Running on OpenJDK 17 gives the error:

[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/UiApplication.java:[17,19] cannot find symbol
  symbol:   method of(java.lang.Class<org.microprofileext.openapi.swaggerui.OpenApiUiService>,java.lang.Class<org.microprofileext.openapi.swaggerui.StaticResourcesService>)
  location: interface java.util.Set
[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/MyApplication.java:[14,19] cannot find symbol
  symbol:   method of(java.lang.Class<org.microprofileext.openapi.features.example.GreetResource>)
  location: interface java.util.Set
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.879 s
[INFO] Finished at: 2022-08-15T13:15:35-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project openapi-helidon-features-example: Compilation failure: Compilation failure: 
[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/UiApplication.java:[17,19] cannot find symbol
[ERROR]   symbol:   method of(java.lang.Class<org.microprofileext.openapi.swaggerui.OpenApiUiService>,java.lang.Class<org.microprofileext.openapi.swaggerui.StaticResourcesService>)
[ERROR]   location: interface java.util.Set
[ERROR] /Users/wyl/Desktop/helidon-test/openapi-ext/openapi-examples/helidon-features-example/src/main/java/org/microprofileext/openapi/features/example/MyApplication.java:[14,19] cannot find symbol
[ERROR]   symbol:   method of(java.lang.Class<org.microprofileext.openapi.features.example.GreetResource>)
[ERROR]   location: interface java.util.Set

Running on JDK 11 however, gives:

io/helidon/microprofile/cdi/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Sorry it's just been a mess trying to revert to Java 11, with everything giving me incompatibility errors. Could you possibly make it clearer in your pom.xml the Java version you are supporting?

WilliamYuhangLee commented 2 years ago

@tvallin Running my own project on Java 11:

/Library/Java/JavaVirtualMachines/jdk-11.0.16.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -jar /Users/wyl/Work/appointment_scheduling/repo/intern/helidon/service/target/SchedulingAppInternalBackend.jar
2022.08.15 14:34:52 INFO io.helidon.common.LogConfig !thread!: Logging at initialization configured using classpath: /logging.properties
2022.08.15 14:34:52 INFO org.jboss.weld.Version !thread!: WELD-000900: 3.1.6 (Final)
2022.08.15 14:34:52 INFO org.jboss.weld.Bootstrap !thread!: WELD-ENV-000020: Using jandex for bean discovery
2022.08.15 14:34:53 INFO org.jboss.weld.Bootstrap !thread!: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
2022.08.15 14:34:53 INFO org.jboss.weld.Event !thread!: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jersey.ext.cdi1x.internal.ProcessAllAnnotatedTypes.processAnnotatedType(@Observes ProcessAnnotatedType<?>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2022.08.15 14:34:53 INFO org.jboss.weld.Event !thread!: WELD-000411: Observer method [BackedAnnotatedMethod] private io.helidon.microprofile.openapi.OpenApiCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<X>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2022.08.15 14:34:53 INFO io.helidon.tracing.tracerresolver.TracerResolverBuilder !thread!: TracerResolver not configured, tracing is disabled
2022.08.15 14:34:53 WARNING io.helidon.microprofile.tracing.TracingCdiExtension !thread!: helidon-microprofile-tracing is on the classpath, yet there is no tracer implementation library. Tracing uses a no-op tracer. As a result, no tracing will be configured for WebServer and JAX-RS
2022.08.15 14:34:53 INFO io.helidon.microprofile.security.SecurityCdiExtension !thread!: Authentication provider is missing from security configuration, but security extension for microprofile is enabled (requires providers configuration at key security.providers). Security will not have any valid authentication provider
2022.08.15 14:34:53 INFO io.helidon.microprofile.security.SecurityCdiExtension !thread!: Authorization provider is missing from security configuration, but security extension for microprofile is enabled (requires providers configuration at key security.providers). ABAC provider is configured for authorization.
2022.08.15 14:34:53 INFO io.helidon.microprofile.server.ServerCdiExtension !thread!: Registering JAX-RS Application: SchedulingAppInternalBackendApplication
2022.08.15 14:34:54 INFO io.helidon.microprofile.server.ServerCdiExtension !thread!: Registering JAX-RS Application: OpenApiUiApplication
2022.08.15 14:34:54 INFO io.helidon.webserver.NettyWebServer !thread!: Channel '@default' started: [id: 0xd6a96902, L:/0:0:0:0:0:0:0:0:8080]
2022.08.15 14:34:54 INFO io.helidon.microprofile.server.ServerCdiExtension !thread!: Server started on http://localhost:8080 (and all other host addresses) in 2404 milliseconds (since JVM startup).
2022.08.15 14:34:54 INFO io.helidon.webserver.NettyWebServer !thread!: Channel '@default' closed: [id: 0xd6a96902, L:/0:0:0:0:0:0:0:0:8080]
2022.08.15 14:34:54 WARNING io.helidon.webserver.jersey.JerseySupport !thread!: Exception while shutting down Jersey's application handler ServiceLocatorImpl(__HK2_Generated_0,0,245703044) has been shut down
2022.08.15 14:34:54 INFO io.helidon.microprofile.server.ServerCdiExtension !thread!: Server stopped in 17 milliseconds.
2022.08.15 14:34:54 INFO org.jboss.weld.Bootstrap !thread!: WELD-ENV-002001: Weld SE container c643c269-1969-4f24-a220-2d90f6bd56d4 shut down
Exception in thread "main" javax.enterprise.event.ObserverException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.lang.Class.newInstance(Class.java:584)
    at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
    at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:103)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
    at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:168)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
    at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
    at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
    at org.jboss.weld.util.Observers.notify(Observers.java:166)
    at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
    at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:96)
    at io.helidon.microprofile.cdi.HelidonContainerImpl.doStart(HelidonContainerImpl.java:341)
    at io.helidon.common.context.Contexts.runInContext(Contexts.java:137)
    at io.helidon.microprofile.cdi.HelidonContainerImpl.start(HelidonContainerImpl.java:251)
    at io.helidon.microprofile.cdi.Main.main(Main.java:80)
Caused by: java.lang.NoSuchMethodError: io.smallrye.openapi.api.OpenApiConfigImpl.scanClasses()Ljava/util/Set;
    at io.helidon.microprofile.openapi.MPOpenAPIBuilder.appRelatedClassesToFilteredIndexView(MPOpenAPIBuilder.java:177)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at io.helidon.microprofile.openapi.MPOpenAPIBuilder.buildPerAppFilteredIndexViews(MPOpenAPIBuilder.java:124)
    at io.helidon.microprofile.openapi.MPOpenAPIBuilder.lambda$indexViewsSupplier$2(MPOpenAPIBuilder.java:214)
    at io.helidon.openapi.OpenAPISupport.model(OpenAPISupport.java:181)
    at io.helidon.openapi.OpenAPISupport.prepareModel(OpenAPISupport.java:176)
    at io.helidon.microprofile.openapi.MPOpenAPISupport.prepareModel(MPOpenAPISupport.java:33)
    at io.helidon.microprofile.openapi.OpenApiCdiExtension.buildModel(OpenApiCdiExtension.java:121)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
    ... 15 more