SpringFox Swagger在IBM Liberty 19.0.0.1上没有按预期工作

问题描述 投票:0回答:1

附在下面(Swagger on Tomcat)(点击放大) - 我的应用程序在Tomcat 9上的Swagger UI enter image description here

附加(Swagger on Liberty)(点击放大) - 我的应用程序在Liberty 19.0.0.1上的Swagger UI enter image description here

在Tomcat中,可以看出,200响应主体被清楚地显示出来,并且“试一试”选项的执行是完美无缺的。

但是,在Liberty中,未显示200响应正文,并且“试一试”执行会导致响应主体填充错误,如下所示(截断):

<H1>Error Page Exception</H1>
<H4>SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below.</H4>
<BR><H3>Original Exception: </H3>
<B>Error Message: </B>Unauthorized<BR>
<B>Error Code: </B>401<BR>
<B>Target Servlet: </B>dispatcherServlet<BR>
<B>Error Stack: </B><BR>
com.ibm.ws.webcontainer.webapp.WebAppErrorReport: Unauthorized

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:630)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:648)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1328)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:164)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:164)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.util.OnCommittedResponseWrapper.sendError(OnCommittedResponseWrapper.java:119)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint.commence(BasicAuthenticationEntryPoint.java:61)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint.commence(DelegatingAuthenticationEntryPoint.java:95)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.access.ExceptionTranslationFilter.sendStartAuthentication(ExceptionTranslationFilter.java:213)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.access.ExceptionTranslationFilter.handleSpringSecurityException(ExceptionTranslationFilter.java:185)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:141)

<BR>&nbsp;&nbsp;&nbsp;&nbsp;
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
...
...
more

同时,Liberty控制台有以下错误(向右滚动以获取更多信息):

Error reported: 406

[ERROR   ] Error Page Exception:
                                                                                                               0-0

                                                                                                               Error Page Exception
                                                                                                               com.ibm.ws.webcontainer.webapp.WebAppErrorReport: SRVE0295E

我的Liberty的server.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>webProfile-8.0</feature>
        <feature>springBoot-2.0</feature>
        <feature>servlet-4.0</feature>
    </featureManager>

    <basicRegistry/>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="9090"
                  httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>

</server>

我的应用程序使用Java 8,Spring Boot(2.1.3)与Spring Integration,Spring Security,Spring REST Docs,Springfox 3.0.0-SNAPSHOT和Log4j 2。

有人可以帮助指出Liberty无法显示Swagger响应或提供“试用”功能背后的根本原因吗?就像我说的那样,在Tomcat 9上也能顺利运行。

真诚的,巴拉特

spring-boot swagger swagger-ui websphere-liberty springfox
1个回答
1
投票

此问题可能是由于在Liberty 19.0.0.1上部署SpringBoot 2.1.3应用程序,该应用程序支持SpringBoot 1.5和2.0应用程序,但缺乏thin embedded server dependencies from Spring Boot 2.1应用程序的功能。此功能已被添加到Liberty 19.0.0.2。请更新到Liberty 19.0.0.2并重试您的方案。如果更新无法解决问题,我已打开open-liberty issue 6870进行进一步讨论和发现。

© www.soinside.com 2019 - 2024. All rights reserved.