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

Incomplete Openapi document - Warning for ClassCastException in OpenApiWalker #3043

Closed
vassterg opened this issue Aug 14, 2018 · 3 comments
Closed
Assignees
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect

Comments

@vassterg
Copy link

Description


When deploying a JAX-RS application to 5.182 that contains a subresource with a @PathParam annotated parameter, I get a warning and empty openapi descriptor

Expected Outcome

No warnings and a complete openapi document

Current Outcome

Info:   Loading application [openapi-test] at [/openapi-test]
Warning:   Exception while dispatching an event
java.lang.ClassCastException: java.lang.reflect.Field cannot be cast to java.lang.reflect.Parameter
	at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotation(OpenApiWalker.java:217)
	at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotations(OpenApiWalker.java:187)
	at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.processAnnotations(OpenApiWalker.java:206)
	at fish.payara.microprofile.openapi.impl.visitor.OpenApiWalker.accept(OpenApiWalker.java:151)
	at fish.payara.microprofile.openapi.impl.processor.ApplicationProcessor.process(ApplicationProcessor.java:157)
	at fish.payara.microprofile.openapi.impl.OpenApiService.createOpenApiDocument(OpenApiService.java:186)
	at fish.payara.microprofile.openapi.impl.OpenApiService.event(OpenApiService.java:151)
	at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
	at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:369)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.initialize(ApplicationLifecycle.java:541)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:542)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:549)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:545)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:360)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:544)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:575)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:567)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:360)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:566)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1475)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1857)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1733)
	at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:131)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:549)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:545)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:360)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:544)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:575)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:567)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:360)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:566)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1475)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1857)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1733)
	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:564)
	at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:251)
	at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:166)
	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)

Info:   openapi-test was successfully deployed in 460 milliseconds.

openapi

paths: {}
components: {}

The application is working as expected.

Steps to reproduce (Only for bug reports)

Create a simple javaee 8 maven JAX-RS project.
Example pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.insurit</groupId>
    <artifactId>openapi-test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>openapi-test</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <name>openapi-test</name>
</project>

Add the following three classes:

@ApplicationPath("resources")
public class JAXRSConfiguration extends Application {

}
@Path("foo")
public class Foo {

    @Context
    private ResourceContext rc;

    @GET
    public String getMethod() {
        return "get foo";
    }
    
    @Path("bar/{id}")
    public Bar sub() {
        return rc.getResource(Bar.class);
    }
}
public class Bar {

    @PathParam("id") String id;
    
    @GET
    public Response barMethod() {
        return Response.ok().entity("bar -> " + id).build();
    }

}

Build and deploy project.
Access http://localhost:8080/openapi-test/resources/foo/bar/1 to verify correct application working.

Samples

Context (Optional)

Environment

  • Payara Version: 5.182
  • Edition: Full
  • JDK Version: 1.8.0_181; Java HotSpot(TM) 64-Bit Server VM 25.181-b13
  • Operating System: Linux / Ubuntu 18.04
  • Database:
@smillidge smillidge added try to reproduce PR: TESTS REQUIRED PR Requires Tests to be merged labels Aug 18, 2018
@vassterg
Copy link
Author

I hoped that explanation was enough but anyway, attached is the sample project and the (zipped) war archive.

openapi-jaxrs-subresource-bug.zip
openapi-bug.zip

@vassterg vassterg reopened this Aug 29, 2018
@MattGill98 MattGill98 self-assigned this Sep 7, 2018
@MattGill98
Copy link
Contributor

Hi @vassterg,

I can confirm this is a bug. The implementation doesn't expect a field to be @...Param annotated, so throws an error when it finds it. I've created internal issue PAYARA-3085 to address it.

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 PR: TESTS REQUIRED PR Requires Tests to be merged try to reproduce labels Sep 7, 2018
@MattGill98
Copy link
Contributor

Fixed by #3163

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

No branches or pull requests

3 participants