-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
ServletContext null - Jersey + Grizzly2 Standalone - 1.5.x #1103
Comments
Same for me, using: <dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-servlet-server</artifactId>
<version>2.3.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.18</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.0</version>
</dependency>
Line 90 being: Swagger swagger = (Swagger) context.getAttribute("swagger"); Maybe related to: http://stackoverflow.com/questions/29974887/jersey-containerrequestfilter-does-not-get-context-servletrequest |
Yeah, it's related to Grizzly not using a servlet container. We need to find a work around for it. |
Hi, I fixed it quick and dirty which is sufficient for me. May be it can be used for a solid solution. Best regards,
|
I am using swagger on Jersey based RESTful service, onr service simply runs on JDK HttpServer so there is no chance to get context injected into ApiListResource. Therefore NPE will be thrown in line 90 if accessing /swagger.json: Swagger swagger = (Swagger) context.getAttribute("swagger"); configuration: <dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.0</version>
</dependency> I am +1 on not relying on ServletContext to initialize swagger instance. |
I suggest you send a PR then, you can even base it on the previous comments. |
Thanks for your comments. I will send out a PR later. |
…gger instance. Instead, allow initialize swagger via ResourceConfig.
Hi @fehguy I've filed the PR. Could you please take some time to review it? |
…o initailize swagger instance.
fixed in #1611 |
When using Grizzly2 in standalone mode, ServletContext is not available.
NPE at
com.wordnik.swagger.jaxrs.listing.ApiListingResource.scan(ApiListingResource.java:47)
com.wordnik.swagger.jaxrs.listing.ApiListingResource.getListingJson(ApiListingResource.java:68)
https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2742 [3.6]
The text was updated successfully, but these errors were encountered: