Spring Boot on Websphere.

unic8der
4 min readJun 17, 2021
IBM Websphere logo
IBM WebSphere logo

I've been intending to write about this topic for a while, but I always end up putting it off. So I thought it was time, after listening a podcast where it encourages talking about a subject, even though there are thousands of threads about it.

The reason

Where I work, before we start our migration to the cloud, we made a lot of use of WebSphere Application Server. There were our more than 200 applications, from old back offices to services for partners.

For a long time "WebSphere" was our great friend and our biggest villain.

Making application development easy was always our goal, and for this reason, we made use of the Spring Boot Framework in our Java applications, but to publish them to WebSphere it was necessary to make a set of configurations that we can only find through research and testing.

So the goal here is show the step by step to create a Spring Boot application and publish it to WebSphere.

Create the application

To publish a Spring Boot application, we're going to create it directly through spring initialzr.

Just generate an application using Java 8, and add Spring Web, Lombok and Spring Security dependencies.

We’re going to make use of a web container, we don’t need Spring Boot to generate a fat jar, so, choose packagin war.

Many times, in the examples, they were always using only the Spring Web and I always wondered whether or not there were compatibility issues.

spring initializr
spring initializr

WebSphere

With our application generated, we will follow the step by step for its publication.

Click on WebSphere enterprise application

WebSphere Enterprise Applications
WebSphere Enterprise Applications

Click on Install

Install new application
Install new application
Choose the application path
Choose the application path
Choose the type of installation
Choose the type of installation

So far we've taken advantage of everything that WebSphere makes it easy for us, we don't need to detail the entire installation to publish our application.

Now we will actually start configuring our application, in Step 1 just choose the name of your application.

Choose application name
Choose application name

In Step 2 we will select the server that the application will run. The important thing is that it contains the Java 8 that you selected when generating the application.

Choose the server
Choose the server

In Step 3 we will select the host.

Choose the virtual host
Choose the virtual host

In Step 4 we will define the context root to access the application. Choose a name that is not being used.

Choose context root
Choose context root

In Step 5, set the option to true so that your application’s metadata can be generated and persisted.

Choose metada
Choose metada

Finally, review and publish your application.

Summary
Summary
Nodes successfully synchronized
Nodes successfully synchronized

Configuration indeed

You have published the application, but as you can see, trying to launch it will not work.

Application not initialized
Application not initialized

Now the configurations actually begin, in fact there aren’t many. The concept you need to understand is that WebSphere has a set of libraries, that if loaded in the wrong sequence will not allow your application to start successfully.

For that, just change the class loading, so far a simple task.

Class loading and update detection
Class loading and update detection

Select the Classes loaded with local class loader first (parent last) option. This option causes the class loader to attempt to load classes from its local class path before delegating the class loading to its parent. Using this policy, an application class loader can override and provide its own version of a class that exists in the parent class loader.

Class loader order
Class loader order

What worked for us was modifying the module class loader.

Module class loader
Module class loader

Select the Classes loaded with local class loader first (parent last) option for the module as well.

Module class loader order
Module class loader order

After these settings go back and try to start the application again, if everything goes correctly it will start without any problem.

Application started successfully
Application started successfully

--

--

unic8der

The cousin webdesign, the son who repairs the printer, sometimes a developer.