Can't read swagger JSON

4,011 views
Skip to first unread message

Manish Agrawal

unread,
Feb 26, 2015, 4:05:11 PM2/26/15
to swagger-sw...@googlegroups.com
HI All,

I have followed below link to create API docs for my REST services using Swagger with Spring.


Everything goes smooth but when I try to access api docs for swagger using the url http://localhost:8080/rest/api-docs, I am getting Can't read swagger JSON. Can someone please help?

Tony Tam

unread,
Feb 26, 2015, 4:23:10 PM2/26/15
to swagger-sw...@googlegroups.com
Hit that link in a browser and post what the response is. 


--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manish Agrawal

unread,
Feb 26, 2015, 4:58:17 PM2/26/15
to swagger-sw...@googlegroups.com
I am getting below error

{"status":404,"errorCode":100,"message":"NotFoundException: HTTP 404 Not Found"}

My log shows below error

javax.ws.rs.NotFoundException: HTTP 404 Not Found
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:300)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1072)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:399)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:140)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

On Thursday, February 26, 2015 at 3:23:10 PM UTC-6, tony tam wrote:
Hit that link in a browser and post what the response is. 



On Feb 26, 2015, at 1:05 PM, Manish Agrawal <manish....@gmail.com> wrote:

HI All,

I have followed below link to create API docs for my REST services using Swagger with Spring.


Everything goes smooth but when I try to access api docs for swagger using the url http://localhost:8080/rest/api-docs, I am getting Can't read swagger JSON. Can someone please help?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

tony tam

unread,
Feb 26, 2015, 11:53:33 PM2/26/15
to swagger-sw...@googlegroups.com
What version of swagger?  How did you add the depenencies?  How is your server configured?  Via web.xml or spring?  What are the logs?  Is your API really mounted on /rest?  You need to share more if you want help.  I'm happy to do so, but it's literally impossible with this info.

Manish Agrawal

unread,
Feb 27, 2015, 12:23:43 PM2/27/15
to swagger-sw...@googlegroups.com
Hi Tony,

I have following swagger dependency

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
<version>1.3.12</version>
<exclusions>
          <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
          </exclusion>
        </exclusions>
</dependency>

All my server configuration are thru web.xml except swagger configuration which was causing issue with my Hateos(Hateos links were getting null value if I configure swagger in web.xml following https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup#hooking-up-swagger-core-in-your-application link). If I configure swagger using Custom Application then I was getting below error as it was conflicting with ExceptionMapper

"status":500,"errorCode":100,"message":"JsonMappingException: No serializer found for class com.wordnik.swagger.model.ResourceListing and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS

So after a little research, I found that it's better to configure swagger thru spring which I initially posted but with that I am getting error Can't read swagger JSON

As per my API, it's mounted on /rest. Please let me know If you need any more information, I will be happy to provide. Struggling with this issue for past couple of days..  

Ron Ratovsky

unread,
Feb 27, 2015, 12:45:47 PM2/27/15
to swagger-sw...@googlegroups.com
I found that it's better to configure swagger thru spring which I initially posted but with that I am getting error Can't read swagger JSON.

But how did you configure it via spring?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------

Manish Agrawal

unread,
Feb 27, 2015, 12:59:37 PM2/27/15
to swagger-sw...@googlegroups.com
Ron,

You can find how we can configure via spring by following below link.


So can you please have a look & let me know If you need any other information.

Ron Ratovsky

unread,
Feb 27, 2015, 1:14:03 PM2/27/15
to swagger-sw...@googlegroups.com
Unfortunately, as much as I appreciate the work the author of that blog post has done, the description there is inaccurate and inconsistent.
One problem is that he talks about Jersey but the sample uses Jersey 2 (and they are different enough to put emphasis on it).
Another problem is that he uses the wrong classes in the Spring configuration for Swagger.

Since there are possible nuances, it would if you shared the relevant files (pom.xml, web.xml, applicationContext.xml) so that we may be able to pinpoint the problem.
Unfortunately, I did not write the documentation for Jersey 2 + Spring configuration since I had no sample to start with and I'm no Spring expert.
Keep in mind there's actually more than one way to do the Spring integration, which makes it a tad more difficult.

If you don't want to share the files publicly, that's understandable, you can email me the files directly.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manish Agrawal

unread,
Feb 27, 2015, 1:53:29 PM2/27/15
to swagger-sw...@googlegroups.com
Ron,

I will mail you the details soon. Mean while I tried another dependency swagger4spring-web from https://github.com/wkennedy/swagger4spring-web and still getting Can't read swagger JSON.


Manish Agrawal

unread,
Mar 3, 2015, 11:57:57 AM3/3/15
to swagger-sw...@googlegroups.com

I have changed my context root a little bit & it's now soa-service-web & the url pattern for my jersey servlet starts with /service/* as per some new need in my project but still I am getting same error. Can someone please help as I have been struggling with this for more than a week. I am attaching some screen shots from my developer tool, in case that give you some clue.





Swagger Issue Developer Tool Screen 01.jpg
Swagger Issue Developer Tool Screen 02.jpg

tony tam

unread,
Mar 3, 2015, 7:57:37 PM3/3/15
to swagger-sw...@googlegroups.com
Swagger is simply a JSON endpoint that is exposed by your web service.  If it can't read *anything* then you're either pointing to the wrong location, or it's not configured.

If you really want help, you might consider sharing the error logs, trying other endpoints on your service that work, or a sample project.  Most the time, the best thing to do is follow a sample project.

Manish Agrawal

unread,
Mar 4, 2015, 10:18:14 AM3/4/15
to swagger-sw...@googlegroups.com
Tony,

My swagger UI works fine when I do swagger config thru web.xml after following the jersey-2 sample from github. But when I do the same config thru spring it fails as I have been mentioning from beginning. My spring config for swagger looks good to me, so not sure why it's breaking with this error. Is swagger for Jersey-2 is only supposed to config thru web.xml. If that's not the truth then I doubt below dependency might be conflicting with some of my dependency.

dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
<version>1.3.12</version>
<exclusions>
           <exclusion>
             <groupId>javax.ws.rs</groupId>
             <artifactId>jsr311-api</artifactId>
           </exclusion>
         </exclusions>
</dependency>

 Attaching all dependencies from my project pom.
My Project Dependencies.xml
Reply all
Reply to author
Forward
0 new messages