Creating a shared library in IBM WebSphere Application Server 8.5.0.0

Reading Time: 2 minutes

Shared library is a splendid feature offered by many of J2EE servers which reduces the size of war files. However, one of key benefit of the shared library is that, if you want to use JSF version 2.2 which is not offered by WAS 8.5, you can simply use your own libraries. To do that I’ll use the below maven configuration;

<dependencies>
 <dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-impl</artifactId>
 <version>2.2.6</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-api</artifactId>
 <version>2.2.6</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>javax.el</groupId>
 <artifactId>javax.el-api</artifactId>
 <version>2.2.1</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>javax.servlet-api</artifactId>
 <version>3.1.0</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>javax.servlet.jsp</groupId>
 <artifactId>javax.servlet.jsp-api</artifactId>
 <version>2.3.1</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>javax.servlet.jsp.jstl</groupId>
 <artifactId>jstl-api</artifactId>
 <version>1.2</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>org.richfaces</groupId>
 <artifactId>richfaces</artifactId>
 <version>4.5.17.Final</version>
 </dependency>
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>3.8.1</version>
 <scope>test</scope>
 </dependency>
 </dependencies>

The instructions as follow;

1. Download all these jar files from the maven repository,

2. Navigate to your WAS folder in my case “C:\Program Files (x86)\IBM\WebSphere\AppServer\” then go to the “lib” folder, here create a new folder and move all the downloaded jar files here

3. Go to your WAS console and navigate to “Environment >> WebSphere variables” create variables as “JSF_LIB_HOME”
value “${WAS_INSTALL_ROOT}/lib/jsflibs” in each scope

4. Then navigate to “Environment >> Shared libraries” for name enter “JSF” and the classpath;

${JSF_LIB_HOME}/javax.el-api-2.2.1.jar
${JSF_LIB_HOME}/javax.servlet.jsp-api-2.3.1.jar
${JSF_LIB_HOME}/javax.servlet-api-3.1.0.jar
${JSF_LIB_HOME}/jsf-api-2.2.6.jar
${JSF_LIB_HOME}/jsf-impl-2.2.6.jar
${JSF_LIB_HOME}/jstl-api-1.2.jar

5. Then navigate to “Applications >> Application Types >> WebSphere enterprise applications” here select your application. In this chapter we will take two actions;

5.1. In the “JSP and JSF options” page the “DEFAULT” value should be selected

5.2. In the “Shared library references” page refer your JSF library to the EAR, you can also point it to your WAR too.

6. Then test your application

voilĂ !!!

 

useful links:

http://www-01.ibm.com/support/docview.wss?uid=swg21700711

http://stackoverflow.com/questions/6810908/how-to-configure-ear-to-access-exisiting-websphere-shared-lib

http://stackoverflow.com/questions/24117960/shared-library-in-websphere-7

https://www.ibm.com/developerworks/community/blogs/aimsupport/entry/create_shared_library_and_associate_it_with_the_application_server_or_application_on_websphere_application_server?lang=en

https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tcws_sharedlib_create.html

http://stackoverflow.com/questions/11477995/how-to-force-websphere-as-8-to-use-a-specific-jsf-implementation

http://wasbehindtheglass.blogspot.se/2011/11/myfaces-20-and-websphere-application.html