Showing posts with label sharedlib. Show all posts
Showing posts with label sharedlib. Show all posts

Attaching shared library to deployed portlet

Some times you might not want to copy all the .jar files that your portlets require in the server shared lib instead you might want to attach them only to every deployed portlet.

Ex. Lets say you want to use a different JSF library in your portlets so instead of copying those .jars in shared/app you want to create a separate shared lib and attach it to every deploy portlet, you can configure Deployment service to solve this use case

Follow these steps

  • Create a shared lib containing your jars using Create shared library instructions

  • Now next step is to configure Deployment Service. For that first login into the WAS Admin Console. Go to Resources -> Resource Environment -> Resource Environment Provider



  • Click on the WP DeploymentService link it will take you the WP DeploymentService details like this


  • On this screen click on new and add new portletapp.shared.library.list property like this. In this value of the Value field should be name of the shared library or comma separated list of name of shared libs

    Click ok to save your changes.

  • Now restart the server for your changes to take effect

  • Once server is restarted you can deploy a portlet and once the portlet is deployed you will notice that the shared lib is attached to the .ear file of that portlet and portlet is aable to access the classes in that shared lib


Application Level shared lib

The Application Level Shared Lib allows you to attach shared lib to particular enterprise application or .war file inside enterprise application. Follow these steps


  • Create testsharedlib shared library by following the steps defined in Create Shared Lib section

  • In the WAS Admin Console, Go to Application -> Enterprise Applications, select the application that you want to attach this shared lib to. I want to attach it to PA_SharedLib enterprise application. So its detail screen looks like this


  • Click on Shared Library references link in the References section, it will display list of shared library referenced from both .ear and the .war file inside the .ear


  • I want to attach the shared lib to the SharedLibPortlet, so select it and click on Reference Shared Libraries button



  • It is displaying list of available shared libraries on the left hand side, select the testsharedlib and add it to selected section.


  • When you click on Ok it will take you to the previous screen and now you will be able to see the testsharedlib being attached to SharedLibPortlet




After making this change i tested my enterprise application and it was able to access the classes defined in the shared lib. If that does not work try restarting the enterprise application

Shared Library

Shared libraries allow you to attach set of .jar files to application or server. Ex. Most of the portlets in your company are using JSF as MVC framework or say set of Apache Axis jars so instead of copying all the .jar files required by portlets in the WEB-INF/lib folder of every portlet you can create a directory on your server copy all the required jars in that directory and add that directory to the classpath of either your server or your portlet application.

Creating a shared library


You can create a shared library by following these steps

  • Create c:\temp\shared directory on your machine and copy all the .jar files in this directory

  • Log into the WAS Admin console and go to Environment -> Shared Libraries. Choose the appropriate scope and click on New

    On this screen assign name to the shared lib and set the class path for that shared lib.


This is how you create testsharedlib shared library.

Now you have two choices either you can make this shared lib available to all the enterprise applications in your server, which is called server level shared lib or you can assign this shared libs to few applications by adding application level shared lib.