WSO2 API Manager 2.0 Swagger控制台无法正常工作

我们已经部署了WSO2 API Manager 2.0,它运行良好.虽然我们正面临着swagger控制台的问题,但没有加载并返回无法从https://myapimanager.com/store/api-docs/admin/PizzaShackAPI/1.0.0?envName=undefined读取swagger
JSON.

虽然来自服务器的日志没有显示任何内容,但我们能够找到问题.问题在于,当我们尝试打开它提供的网页时

错误404:找不到资源.
您要查找的资源可能已被删除,名称已更改,暂时不可用或不存在.

另外,我们发现如果我们只请求页面

https://myapimanager.com/store/api-docs

它返回

错误500:无法显示页面.服务器遇到内部错误或配置错误,无法完成您的请求.

并且API Manager日志返回:


    ERROR - WebAppManager org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.registry.core.secure.AuthorizationFailedException: User wso2.anonymous.user is not authorized to read the resource /_system/governance/apimgt/applicationdata/provider/store//api-docs/swagger.json. (/store/site/blocks/api-doc/ajax/get.jag#90)
org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.registry.core.secure.AuthorizationFailedException: User wso2.anonymous.user is not authorized to read the resource /_system/governance/apimgt/applicationdata/provider/store//api-docs/swagger.json. (/store/site/blocks/api-doc/ajax/get.jag#90)
      at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:571)
      at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
      at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:588)
      at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:508)
      at org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:377)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
      at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
      at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
      at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
      at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
      at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
      at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
      at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
Caused by: org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.registry.core.secure.AuthorizationFailedException: User wso2.anonymous.user is not authorized to read the resource /_system/governance/apimgt/applicationdata/provider/store//api-docs/swagger.json. (/store/site/blocks/api-doc/ajax/get.jag#90)
      at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754)
      at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148)
      at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
      at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0._c_anonymous_1(/store/site/blocks/api-doc/ajax/get.jag:90)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0.call(/store/site/blocks/api-doc/ajax/get.jag)
      at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0._c_script_0(/store/site/blocks/api-doc/ajax/get.jag:11)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0.call(/store/site/blocks/api-doc/ajax/get.jag)
      at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
      at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0.call(/store/site/blocks/api-doc/ajax/get.jag)
      at org.jaggeryjs.rhino.store.site.blocks.api_doc.ajax.c0.exec(/store/site/blocks/api-doc/ajax/get.jag)
      at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
      ... 45 more
 Caused by: org.wso2.carbon.registry.core.secure.AuthorizationFailedException: User wso2.anonymous.user is not authorized to read the resource /_system/governance/apimgt/applicationdata/provider/store//api-docs/swagger.json.
      at org.wso2.carbon.registry.core.caching.CacheBackedRegistry.get(CacheBackedRegistry.java:195)
      at org.wso2.carbon.registry.core.session.UserRegistry.getInternal(UserRegistry.java:617)
      at org.wso2.carbon.registry.core.session.UserRegistry.access$400(UserRegistry.java:61)
      at org.wso2.carbon.registry.core.session.UserRegistry$5.run(UserRegistry.java:597)
      at org.wso2.carbon.registry.core.session.UserRegistry$5.run(UserRegistry.java:594)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.wso2.carbon.registry.core.session.UserRegistry.get(UserRegistry.java:594)
      at org.wso2.carbon.registry.core.session.UserRegistry.get(UserRegistry.java:61)
      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.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
      ... 57 more

正如您所看到的,它记录了一个试图访问但没有权限的匿名用户.

Swagger是API描述中的一个很棒的功能,我们希望保留它.

提前致谢!
最好的祝福

最佳答案 在swagger.json的路径中,中间有一个额外的斜线.

/_system/governance/apimgt/applicationdata/provider/store//api-docs/swagger.json

确保你已经为这样的商店设置了proxy_path. (最后没有斜线)

proxy_pass https://localhost:9443/store 

类似的经历了here.

点赞