'Sharing AWS CloudHSM between two Web Applciations on WildFly

I have two web applications deployed in Wildfly 18. Both of them use AWS ClOud HSM. They work perfectly fine while used alone. But as soon request is sent to both the applications I get the error "java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader".

There is a jar file cloudhsm.jar which internally loads the .so library. I have to use the following statement to register a new security provider Security.addProvider(new com.cavium.provider.CaviumProvider()); The same statement is used in both the applications

I have tried configuring the provider in java.security file also. But that also doesnt work. How should I configure the provider to be used in both the applciations.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source