Forum Discussion

vaidya1973's avatar
vaidya1973
Visitor
2 years ago

Swagger UI not working on websphere liberty with spring boot and https

Hello world !!!,
 

Recently we migrated from websphere traditional to websphere liberty and since then we are not able to access swagger-ui from the browser.

We are using a spring boot app (2.5.12) on Websphere liberty (21.0.0.3) in linux. springfox-swagger-ui -3.0.0 is getting transitively added as part of the dependency chain. Relevant pom snippets are 

 

 

 

 

 

<properties>
		<java.version>11</java.version>
		<jjwt.version>0.11.2</jjwt.version>
		<maven.compiler.release>11</maven.compiler.release>
		<oracle.jdbc.version>21.3.0.0</oracle.jdbc.version>
		<mavensurefire.version>2.22.0</mavensurefire.version>
		<mavenfailsafe.version>2.22.0</mavenfailsafe.version>
		<jaspyt.version>1.9.3</jaspyt.version>
		<jaspyt.spring.version>3.0.4</jaspyt.spring.version>
		<sonarmaven.version>3.5.0.1254</sonarmaven.version>
		<springfox.version>3.0.0</springfox.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.build.timestamp.format>yyyy-MM-dd'T'HH-mm-ss'Z'</maven.build.timestamp.format>
		<jacoco.version>0.8.1</jacoco.version>
		<timestamp>${maven.build.timestamp}</timestamp>
		<!-- jacoco plugin to run junit tests coverage -->
		<jacoco.version>0.8.6</jacoco.version>
		<argLine>-Xmx1024m</argLine>
		<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
		<sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
		<sonar.language>java</sonar.language>
	</properties>

<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-tomcat</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-validation -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
		<dependency>
			<groupId>io.jsonwebtoken</groupId>
			<artifactId>jjwt-api</artifactId>
			<version>${jjwt.version}</version>
		</dependency>
		<dependency>
			<groupId>io.jsonwebtoken</groupId>
			<artifactId>jjwt-impl</artifactId>
			<version>${jjwt.version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>io.jsonwebtoken</groupId>
			<artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
			<version>${jjwt.version}</version>
			<scope>runtime</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc11 -->
		<dependency>
			<groupId>com.oracle.database.jdbc</groupId>
			<artifactId>ojdbc11</artifactId>
			<version>${oracle.jdbc.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-entitymanager</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-boot-starter</artifactId>
			<version>${springfox.version}</version>
		</dependency>
		<dependency>
			<groupId>com.github.ulisesbocchio</groupId>
			<artifactId>jasypt-spring-boot-starter</artifactId>
			<version>${jaspyt.spring.version}</version>
		</dependency>
		<!-- Test -->
		<dependency>
			<groupId>org.junit.platform</groupId>
			<artifactId>junit-platform-engine</artifactId>
		</dependency>
</dependencies>

 

 

 

 

 

However when we try to access the swagger ui with https://hostname:9443/<>/swagger-ui/ , we are not getting the swagger ui . We just get a blank screen

On the console in the browser we get

GET https://hostname:9443/<<root>>/swagger-ui/swagger-ui.css?v=3.0.0 net::ERR_CONNECTION_CLOSED 200
GET https://hostname:9443/<<root>>/swagger-ui/swagger-ui-bundle.js?v=3.0.0 net::ERR_CONNECTION_CLOSED 200
GET https://hostname:9443/<<root>>/swagger-ui/swagger-ui-standalone-preset.js?v=3.0.0 net::ERR_CONNECTION_CLOSED 200
https://hostname:9443/<<root>>/swagger-ui/<<root>>/swagger-ui/springfox.js?v=3.0.0 net::ERR_CONNECTION_CLOSED 200

On the server logs in websphere we get the following

  at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
        at [internal classes]
        at 
Caused by: java.io.IOException: com.ibm.ws.http2.upgrade.H2Exception: stream was already closed!
        ... 88 more
Caused by: com.ibm.ws.http2.upgrade.H2Exception: stream was already closed!
        ... 88 more

The same set up is working locally in windows and in linux(with http) , so I am guess its either the https / websphere liberty/swaggerui configuration or something that is preventing the .css from getting downloaded.

         1. Has anyone got this to work ? Especially in a https environment.

  • 2. Any WebSphere liberty configuration / spring boot configuration/swagger configuration that would help ?

If not, is there any way in which we can get the css bundled as part of the app so it doesn't need to go back to fetch the css.

Any help is appreciated.

Thx

 

5/4/2022 > A quick update, we moved to spring doc api by including the following in the pom 

 

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.7</version>
</dependency>

and with this we are now getting only one .css that we cant download. (swagger-ui.css with the error net::ERR_CONNECTION_CLOSED 200 )

 

We still cant see the whole swagger ui but its definitely better than with swagger 2. 

 

Really appreciate any help that i can get . is swagger ui not supposed to work with https ? any configuration changes we need to do on the websphere end to allow the css to get downloaded,etc.  

 

 

No RepliesBe the first to reply