WPS Shared Library Creation and Usage scenarios

You might be aware of default Shared library of WPS, which is <PortalServer> /shared/app folder and it is the place where we keep the jar files which we want to be shared across all applications deployed on portal. Jar files placed here are loaded with portal class loader.

You can find entry for this portal shared library entry on WAS under

Environment --> Shared Libraries --> WPSlib

In the same way, there could be scenarios where you have several portlet applications deployed on portal and some of them might be using common libraries. 
We generally keep libraries in individual applications lib folder but few jars files might be common to some applications. In this case, there is no meaning to put these common jars to individual applications lib folder. Ultimately we will be increasing size of EAR or WAR  and reloading of same jar file from different application.

Best solution to this would be to create our own shared library.
The way WPS share library works, we can also create our own shared library and put common jars there so that all our applications make use of them and now we don't require to put those common jars in our application specific lib folder.

Here i tell you, how to achieve the same.
First, we will create a folder on drive, and then we will copy our common jar files to this folder.
For example:- /shared/app/appsharedlib

Next step would be to create a shared library entry in WAS and pointing it to above path
1) login to WAS as admin
2) navigate to Environment --> Shared Libraries
3) select your node where you want to create library
4) click on New
5) provide following details on the screen
Classpath:- ${WPS_HOME}/shared/app/appsharedlib
6) click on ok and then save.
7) Restart Portal and WAS.

You can now test by putting all the common jars to our appsharedlib folder and remove those jars from applications lib directory.

No comments: