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

Getting 406 : undefined on JBoss 7 with RESTeasy #405

Closed
Isnogud77 opened this issue Feb 27, 2014 · 14 comments
Closed

Getting 406 : undefined on JBoss 7 with RESTeasy #405

Isnogud77 opened this issue Feb 27, 2014 · 14 comments

Comments

@Isnogud77
Copy link

This message is issued by JBoss when I try to use swagger-ui:

Failed executing GET /api-docs: org.jboss.resteasy.spi.NotAcceptableException: No match for accept header

From the browser it workes fine. So I analyzed the request with chrome dev tools. It seems when the accept header is set to application/json, RESTeasy fails with the above message. It seems to only work if accept is set to */*.

Using this extra line I was able to workaround this issue but it seems to me like an hack. But maybe it's helpful for someone else.

window.authorizations.add("key", new ApiKeyAuthorization("accept", "*/*", "header"));
@rage-shadowman
Copy link

Have you set your @Produces and @Consumes annotations?

@Isnogud77
Copy link
Author

Yes, I have that set on my resource. I get this error from swagger-ui so it's not my resource but rather the swagger resource this error relates to.

@fehguy
Copy link
Contributor

fehguy commented Feb 27, 2014

That seems really wrong. What version of swagger-ui are you running? Can you re-test with the latest master? Also, what version of swagger-jaxrs are you using?

@Isnogud77
Copy link
Author

I'm using 1.3.2 of swagger-jaxrs and grabbed the swagger-ui dist folder yesterday from here.

@fehguy
Copy link
Contributor

fehguy commented Feb 28, 2014

can you open the network window and show the headers on the call? For example:

image

@Isnogud77
Copy link
Author

image
The server log shows this:

14:05:40,136 SCHWERWIEGEND [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-8080-6) Failed executing GET /api-docs: org.jboss.resteasy.spi.NotAcceptableException: No match for accept header
        at org.jboss.resteasy.core.registry.Segment.match(Segment.java:119) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:33) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:307) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:173) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:118) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.1.GA.jar:]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
        at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_45]

Actually I think this is probably the wrong place for this issue. Either it is some issue in swagger-core or in RESTeasy.

@fehguy
Copy link
Contributor

fehguy commented Feb 28, 2014

Yes, this does belong in swagger-core. And what do you get from issuing this statement:

curl -X GET -H "accept:application/json" http://localhost:8080/restapi/api-docs

curl -X GET -H "accept:application/json;charset=utf-8" http://localhost:8080/restapi/api-docs

By chance, did you forget to add the swagger providers?

https://github.com/wordnik/swagger-core/blob/master/samples/java-jaxrs/src/main/webapp/WEB-INF/web.xml#L12
com.wordnik.swagger.sample.util;com.wordnik.swagger.jaxrs.listing

@Isnogud77
Copy link
Author

I get the same 406 for both statements.

However it works with this:

curl -X GET -H "accept:*/*" http://localhost:8080/restapi/api-docs

Regarding the providers, my web.xml looks pretty much like this one.
https://github.com/riteshmodi/RestEasy/blob/master/src/main/webapp/WEB-INF/web.xml

@fehguy
Copy link
Contributor

fehguy commented Mar 20, 2014

if still an issue, let's take this to swagger -core.

@fehguy fehguy closed this as completed Mar 20, 2014
@hasselstromk
Copy link

I, too, have bumped into this today -- was this ever taken to swagger - core; if so, can someone please provide a link or any follow on information. Thank you.

@webron
Copy link
Contributor

webron commented Mar 28, 2014

@hasselstromk - As @fehguy mentioned, if you encounter this issue, please open a new on in swagger-core and give out as many details as you can. We'll take it from there.

@Isnogud77
Copy link
Author

I created a follow up issue in swagger-core.

@webron
Copy link
Contributor

webron commented May 28, 2014

@Isnogud77 - were you able to solve the 406 issue?

@fehguy
Copy link
Contributor

fehguy commented Sep 6, 2014

added swagger-api/swagger-js#120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants