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

NPE - OpenAPI document creation failed. #3165

Closed
silvafabio opened this issue Sep 14, 2018 · 2 comments
Closed

NPE - OpenAPI document creation failed. #3165

silvafabio opened this issue Sep 14, 2018 · 2 comments
Assignees
Labels
Type: Bug Label issue as a bug defect
Milestone

Comments

@silvafabio
Copy link

Description


When try to get the OpenApi documentation (http://localhost:8080/openapi) a NPE is throwed in server log and the browser shows nothing.

Expected Outcome

OpenApi documentation

Current Outcome

Browser outcome:

paths: {}
components: {}

server.log outcome:

[2018-09-13T21:07:46.066-0300] [Payara 5.183] [WARNING] [] [fish.payara.microprofile.openapi.impl.rest.app.service.OpenApiResource] [tid: _ThreadID=38 _ThreadName=http-thread-pool::http-listener-1(1)] [timeMillis: 1536883666066] [levelValue: 900] [[ OpenAPI document creation failed. fish.payara.microprofile.openapi.api.OpenAPIBuildException: java.lang.NullPointerException at fish.payara.microprofile.openapi.impl.OpenApiService$OpenApiMapping.buildDocument(OpenApiService.java:292) at fish.payara.microprofile.openapi.impl.OpenApiService$OpenApiMapping.getDocument(OpenApiService.java:272) at fish.payara.microprofile.openapi.impl.OpenApiService$OpenApiMapping.access$300(OpenApiService.java:255) at fish.payara.microprofile.openapi.impl.OpenApiService.getDocument(OpenApiService.java:188) at fish.payara.microprofile.openapi.impl.rest.app.service.OpenApiResource.getResponse(OpenApiResource.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:200) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268) at org.glassfish.jersey.internal.Errors.process(Errors.java:316) at org.glassfish.jersey.internal.Errors.process(Errors.java:298) at org.glassfish.jersey.internal.Errors.process(Errors.java:268) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:704) at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:755) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:575) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:516) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:213) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException at fish.payara.microprofile.openapi.impl.processor.ApplicationProcessor.visitQueryParam(ApplicationProcessor.java:365) at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotation(OpenApiWalker.java:217) at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotations(OpenApiWalker.java:197) at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotations(OpenApiWalker.java:206) at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.accept(OpenApiWalker.java:150) at fish.payara.microprofile.openapi.impl.processor.ApplicationProcessor.process(ApplicationProcessor.java:157) at fish.payara.microprofile.openapi.impl.OpenApiService$OpenApiMapping.buildDocument(OpenApiService.java:288) ... 58 more ]]

Steps to reproduce (Only for bug reports)

1 -** Create a basic JAX-RS application with a simple class with @get and @QueryParam:

@Path("/test")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public class TestService {
    private static final String START_PAGE = "1";
    @GET
    public List<String> getProdutos(@QueryParam("page") int page) {
        return new ArrayList<String>();
    }
}

2 -** Create a class that extends org.glassfish.jersey.server.ResourceConfig with a default constructor and register any component:

@ApplicationPath("/")
public class ApplicationServices extends ResourceConfig {
public ApplicationServices() {
    packages("br.com.fabioluis.openapipayara5183error.services");

    // https://jersey.github.io/documentation/latest/security.html#d0e12436
    register(RolesAllowedDynamicFeature.class);

    // https://jersey.github.io/documentation/latest/declarative-linking.html
    register(DeclarativeLinkingFeature.class);

    // https://jersey.github.io/documentation/latest/media.html#json.moxy
    register(MoxyJsonFeature.class);

    // https://jersey.github.io/documentation/latest/media.html#d0e8809
    register(MoxyXmlFeature.class);

    // https://jersey.github.io/documentation/latest/entity-filtering.html
    // Register the EntityFilteringFeature.
    register(EntityFilteringFeature.class);
    }
}

3 -** Deploy the war and point you browser to http://localhost:8080/openapi

Samples

Project: openapi-payara-5183-error.zip

Context (Optional)

To the problem occur we need two premisses:

1 -** At least one registered component in the ResourceConfig extended class constructor.
2 -** At least one method annotated with @get and one @QueryParam in that same method

Environment

  • Payara Version: 5.183.0
  • Edition: Full
  • JDK Version: penjdk version "1.8.0_181"
  • Operating System: Fedora release 28 (Twenty Eight) / CentOS 6 / CentOS 7
  • Database: None
@MattGill98
Copy link
Contributor

Hi @silvafabio,

This bug is caused by registering a Jersey provider, which causes the getClasses() method on the class to only return the providers registered. This information is used in generating the endpoint paths, and therefore causes the operation context to be null. I've made a pull request to address this issue which you can find here. Feel free to test that this fixes your issue. This fix will be included in 5.184.

Kind regards,

Matt

@MattGill98 MattGill98 added Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect and removed 0:Triaged labels Sep 19, 2018
@smillidge smillidge added this to the Payara 5.184 milestone Sep 20, 2018
@MattGill98
Copy link
Contributor

Hi @silvafabio,

Since a fix has been merged, I'll close this issue.

Kind regards,

Matt

@MattGill98 MattGill98 removed the Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev label Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

4 participants