Saturday, October 30, 2010

How to add a new base entry to VMM DB?

VMM Database insert statement:

insert into dbentity (entity_id, entity_type, unique_id, unique_name, unique_name_key) values (-3000, 'OrgContainer', 'a9e5a980-3cec-11da-a833-828d43500d21', 'o=testOrg2', 'o=testOrg2');


wimconfig.xml file changes:

<config:repositories xsi:type="config:DatabaseRepositoryType" adapterClassName="com.ibm.ws.wim.adapter.db.DBAdapter"
id="DB2MemberRepos" isExtIdUnique="true" supportExternalName="false" supportPaging="false"
.......
.......
entityRetrievalLimit="50" JDBCDriverClass="com.ibm.db2.jcc.DB2Driver" saltLength="12">
<config:baseEntries name="o=testOrg1" nameInRepository="o=testOrg1"/>
<config:baseEntries name="o=testOrg2" nameInRepository="o=testOrg2"/>
</config:repositories>


<config:realms delimiter="/" name="defaultWIMFileBasedRealm" securityUse="active"
allowOperationIfReposDown="false">
<config:participatingBaseEntries name="o=defaultWIMFileBasedRealm"/>
<config:participatingBaseEntries name="o=testOrg"/>
<config:participatingBaseEntries name="o=testOrg1"/>
<config:participatingBaseEntries name="o=testOrg2"/>
<config:defaultParents entityTypeName="OrgContainer" parentUniqueName="o=testOrg"/>
<config:defaultParents entityTypeName="PersonAccount" parentUniqueName="o=testOrg"/>
<config:defaultParents entityTypeName="Group" parentUniqueName="o=testOrg"/>
<config:uniqueUserIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:userSecurityNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:userDisplayNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:uniqueGroupIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:groupSecurityNameMapping propertyForInput="cn" propertyForOutput="cn"/>
<config:groupDisplayNameMapping propertyForInput="cn" propertyForOutput="cn"/>
</config:realms>

<config:realms delimiter="/" name="dbdir.testOrg" securityUse="active" allowOperationIfReposDown="true">
<config:participatingBaseEntries name="o=defaultWIMFileBasedRealm"/>
<config:participatingBaseEntries name="o=testOrg"/>
<config:participatingBaseEntries name="o=testOrg1"/>
<config:participatingBaseEntries name="o=testOrg2"/>
<config:defaultParents entityTypeName="OrgContainer" parentUniqueName="o=testOrg2"/>
<config:defaultParents entityTypeName="PersonAccount" parentUniqueName="o=testOrg2"/>
<config:defaultParents entityTypeName="Group" parentUniqueName="o=testOrg2"/>
<config:uniqueUserIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:userSecurityNameMapping propertyForInput="principalName" propertyForOutput="externalName"/>
<config:userDisplayNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:uniqueGroupIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:groupSecurityNameMapping propertyForInput="cn" propertyForOutput="externalName"/>
<config:groupDisplayNameMapping propertyForInput="cn" propertyForOutput="cn"/>
</config:realms>

Friday, October 29, 2010

SECJ0369E: Authentication failed when using LTPA. The exception is

Check if following is correct based on the repository setting:

<config:supportedEntityTypes defaultParent="o=testOrg" name="PersonAccount">
<config:rdnProperties>uid</config:rdnProperties>

Check if defaultParent and config:rdnProperties have correct values.

Try cleaning up temporary folders :
wp_profile\temp
wp_profile\wstemp
wp_profile\tranlog

This might resolve the issue if all the configuration seems correct.

Thursday, April 1, 2010

New Features of WebSphere Application Server V 7.0

New features and enhancements in WebSphere Application Server V 7.0

Common
•    Built on top of Java Platform Enterprise Edition (Java EE) 5.0 and Java Standard Edition (Java SE) 6.0
•    Provides EJB 3.0
•    Provides Java Persistence API (JPA) 1.0
•    Ease in administration and movement of the applications from one environment to another.
•    Better performance than previous versions
•    EJB 3.0 API is simpler to code and provides better performance of previous versions.
•    Resource efficient features, faster run-time, and new high-performance Web Service Engine
•    LTPA Token V2.0 support for SSO

Administration
•    Easy administration with Job Manager – remotely manage different environments with Job Manager including standalone servers and clustered environments from one central location across dispersed geographical locations.
•    Administer multiple stand-alone nodes using Administrative agent – Single interface to administer multiple application servers, thereby reducing the overhead of running administrative services in every application server.
•    Provides support for portable properties files which can be deployed across multiple environments with portable resource identifiers. Improves administration and movement of applications across different environments like dev, test, uat, prod, etc.
•    Configure client reroute for applications using DB2 database – Specify alternate DB2 database server in case primary server fails to reroute the client requests to provide high availability.
•    Authentication alias can be defined for each server. Server level authentication aliases will not be visible / accessible to other servers in the environment.
•    Multiple mail providers and sessions supported. Different versions of the mail provider can co-exist with in the same JVM to provide better control and segregation for different applications.
•    Business-level application is a new way of grouping applications together. This is in addition to servers, clusters, cells, EARs, WARs, etc. This way multiple EARs/WARs/JARs can be grouped together into one logical unit and me managed that way like start/stop them all with one command.
•    Support of trusted context for DB2 databases to provide fine grained access control.

Security
•    Support for Security Domains – Multiple security domains can be configured. Different applications/servers/clusters can be assigned to different security domains to achieve fine grained control over authentication/authorization. Local configuration defined for an application/server/cluster will over-ride global configuration; Following can be configured at local level:
o    Application Security
o    Java 2 Security
o    User Realm (user registry)
o    Trust Association (TAI)
o    JAAS Login Module (Application, System and J2C Authentication Data)
o    Authentication mechanism attributes
o    Simple and Protected GSS-API Negotiation (SPNEGO) Web Authentication
o    Authorization provider
o    Other attributes
o    Custom properties
•    SPNEGO Web Authentication is now supported with enhanced features including dynamic reload of SPNEGO module with the need of server restart.

Development
•    Better transaction execution isolation with the provision to specify “commit priority” of the resources contained in a transaction.
•    Client reroute for applications that use DB2 databases
•    Better handling of data access exception with custom error mapping in DataStoreHelper

Saturday, March 13, 2010

Web 2.0 Theme – Navigation Issue – Links does not work after navigating back and forth on a page

WebSphere Portal Web 2.0 theme caches the links navigated. To overcome this problem comment out the following code in head_extras.jspf file:

function bootstrap() {
        var currentState = null;
        var prevUrl = com.ibm.portal.aggregation.backbutton.BACK_BUTTON_HANDLER.loadUrlFrag();
        var currentUrl = top.location.href;

        //if(prevUrl == currentUrl) {
//        alert('prevUrl == currentUrl');   
//        currentState = com.ibm.portal.aggregation.backbutton.BACK_BUTTON_HANDLER.loadState();
//            if ( currentState ) {
//                ibm.portal.debug.text( "Loaded state from back button handler: " + dojox.data.dom.innerXML( currentState ) );
//            }      
  //      }
        //Set flag to indicate CSA mode is active.
        document.isCSA = true;

 

This should resolve the issue of non-navigating links.

Friday, February 19, 2010

How to resolve SQL22201N Reason Code "1" Error ?

Sometimes when you are working in Admin mode on DB2 using Configuration Assistant you may accidentally delete the repository information relating to authentication/authorization. This may also happen due to some other reason. If you are able to open Control Center and able to view the database tables using any other user then you are safe.

Right click on the database name and select authorize. Now add the user that you want to give access rights. Similarly add group if you need to provide access to a group. Grant all the required access rights then apply. Restart DB2 server to let the changes take effect this will resolve the problem encountered by you.

Friday, February 5, 2010

Scoped Classloading in WebSphere

Often there are situations when libraries included in the web archive (*.war) file are to be loaded first since their version differs from the version being loaded at enterprise archive (*.ear) level. Lets take an example where X.ear has a war module Z.war. There is a common.jar file which is included at X.ear level. If Z.war wants to provide its own version of the common.jar file then the best way to load this jar file is to use application class loader only to load war module files also. By default application (.ear) has application scope class loader and web module (.war) has its own class loader. The default setting to load classes is “Parent First”. Change this setting to “Parent Last” and also change the setting to single calss loader as per the figure shown below:
image
There is only one class loader for application and all web module files are also loaded using the same application class loader. This makes web module level classes also visible to the application class loader. As per the hierarchy, parent class loader cannot see classes loaded by the child class loader. In this case all files are loaded by one class loader therefore all classes are visible to each other across the application. Moreover, we have asked it to load child classes first, therefore, it will loaded web module (.war) classes first and then will load the classes defined at application level. This way web module can load its own classes first and hide the classes provided by application.

Saturday, January 16, 2010

Transferring Portal Databases from default Derby Database to DB2 Databases

Portal is installed by default with Derby database to store portal information. Portal uses following 6 databases to store different kind of information:

1. Release

2. Community

3. Customization

4. JCR

5. Feedback

6. Likeminds

Portal provides following 3 options while creating and transferring the databases:

1. Create one database and transfer all the databases to this single database

2. Create separate databases on the same server and transfer the portal data to them

3. Create separate databases on different server (distributed environment) and transfer the portal data to them.

This post will demonstrate how to transfer the portal databases to separate databases on the same server, but you can use the same steps to transfer the database to one database or databases created on separate servers.

After configuring your database server(s) by installing DB2 (or Oracle/MS SQL Server) and creating databases using the DB2 creation script you need to run the following to transfer the databases:

<wp_profile_root>\PortalServer\wizard\configwizard.bat

Running the above batch command will open the following screen:

Database-Migration-1

Click on “Next” to go to next screen.

Database-Migration-2

Select “Transfer data to other databases” and click next to go to next step.

Database-Migration-3

Provide WebSphere Application Server username and password to start WebSphere_Portal server. Click “Next” to go to next screen.

Database-Migration-4

Wizard will check if server is started or not. If server is not started then it will start the server before moving to next screen.

Database-Migration-5

Select “IBM Derby” from the options to select the source database. Click “Next” to go to next screen.

Database-Migration-6

Select “IBM DB2 Universal Database” to select the target database. Click “Next” to go to next screen

Database-Migration-7

Specify database server name or provide IP address in “DbHostName” and “DbPort”. Also specify complete path for “DbLibrary” files. You need to specify the location for the jar files “db2jcc.jar” and “db2jcc_license_cu.jar”. Click “Next” to go to next screen.

Database-Migration-8

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “community” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-12

Wizard will validate the information provided by you before moving to next screen. You just have to wait for it to finish verification to go to next screen.

Database-Migration-9

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “customization” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-10

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “FEEDBACK” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-11

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “jcr” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-13

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “likeminds” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-14

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “release” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen.

Database-Migration-15

Check all the information in that you specified in this screen. If everything is correct then click “Next” to start the transfer of the databases. You will get successful message if everything goes well without any error.

You can now start and stop the servers to propagate the changes. If servers start without any errors and you are able to login successfully using GUI then you have successfully transferred the databases.

Tuesday, January 12, 2010

DB2 Database Creation Script for Portal Database Migration

For migrating WebSphere Portal databases from Derby to DB2 you need to first create the databases in DB2. Following scripts create all the databases required by the Portal on DB2. For executing these scripts open DB2 Command Window and copy and paste each of the commands mentioned in the script one by one or you can also copy and paste them in a bunch. If you receive a success message after every command of the scripts then you have completed the database creation properly.



Release database creation script





db2 "CREATE DB release using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR release USING applheapsz 4096"
db2 "UPDATE DB CFG FOR release USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR release USING stmtheap 32768"
db2 "UPDATE DB CFG FOR release USING dbheap 2400"
db2 "UPDATE DB CFG FOR release USING locklist 1000"
db2 "UPDATE DB CFG FOR release USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR release USING logprimary 12"
db2 "UPDATE DB CFG FOR release USING logsecond 20"
db2 "UPDATE DB CFG FOR release USING logbufsz 32"
db2 "UPDATE DB CFG FOR release USING avg_appls 5"
db2 "UPDATE DB CFG FOR release USING locktimeout 30"
db2 "UPDATE DB CFG FOR release using AUTO_MAINT off"



Community database creation script





db2 "CREATE DB commun using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR commun USING applheapsz 4096"
db2 "UPDATE DB CFG FOR commun USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR commun USING stmtheap 32768"
db2 "UPDATE DB CFG FOR commun USING dbheap 2400"
db2 "UPDATE DB CFG FOR commun USING locklist 1000"
db2 "UPDATE DB CFG FOR commun USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR commun USING logprimary 12"
db2 "UPDATE DB CFG FOR commun USING logsecond 20"
db2 "UPDATE DB CFG FOR commun USING logbufsz 32"
db2 "UPDATE DB CFG FOR commun USING avg_appls 5"
db2 "UPDATE DB CFG FOR commun USING locktimeout 30"
db2 "UPDATE DB CFG FOR commun using AUTO_MAINT off"



Customization database creation script





db2 "CREATE DB custom using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR custom USING applheapsz 4096"
db2 "UPDATE DB CFG FOR custom USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR custom USING stmtheap 32768"
db2 "UPDATE DB CFG FOR custom USING dbheap 2400"
db2 "UPDATE DB CFG FOR custom USING locklist 1000"
db2 "UPDATE DB CFG FOR custom USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR custom USING logprimary 12"
db2 "UPDATE DB CFG FOR custom USING logsecond 20"
db2 "UPDATE DB CFG FOR custom USING logbufsz 32"
db2 "UPDATE DB CFG FOR custom USING avg_appls 5"
db2 "UPDATE DB CFG FOR custom USING locktimeout 30"
db2 "UPDATE DB CFG FOR custom using AUTO_MAINT off"



JCR database creation script





db2 "CREATE DB jcrdb using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR jcrdb USING applheapsz 4096"
db2 "UPDATE DB CFG FOR jcrdb USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR jcrdb USING stmtheap 32768"
db2 "UPDATE DB CFG FOR jcrdb USING dbheap 2400"
db2 "UPDATE DB CFG FOR jcrdb USING locklist 1000"
db2 "UPDATE DB CFG FOR jcrdb USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR jcrdb USING logprimary 12"
db2 "UPDATE DB CFG FOR jcrdb USING logsecond 20"
db2 "UPDATE DB CFG FOR jcrdb USING logbufsz 32"
db2 "UPDATE DB CFG FOR jcrdb USING avg_appls 5"
db2 "UPDATE DB CFG FOR jcrdb USING locktimeout 30"
db2 "UPDATE DB CFG FOR jcrdb using AUTO_MAINT off"



Feedback database creation script





db2 "CREATE DB fdbkdb using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR fdbkdb USING applheapsz 4096"
db2 "UPDATE DB CFG FOR fdbkdb USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR fdbkdb USING stmtheap 32768"
db2 "UPDATE DB CFG FOR fdbkdb USING dbheap 2400"
db2 "UPDATE DB CFG FOR fdbkdb USING locklist 1000"
db2 "UPDATE DB CFG FOR fdbkdb USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR fdbkdb USING logprimary 12"
db2 "UPDATE DB CFG FOR fdbkdb USING logsecond 20"
db2 "UPDATE DB CFG FOR fdbkdb USING logbufsz 32"
db2 "UPDATE DB CFG FOR fdbkdb USING avg_appls 5"
db2 "UPDATE DB CFG FOR fdbkdb USING locktimeout 30"
db2 "UPDATE DB CFG FOR fdbkdb using AUTO_MAINT off"



Likeminds database creation script





db2 "CREATE DB lmdb using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR lmdb USING applheapsz 4096"
db2 "UPDATE DB CFG FOR lmdb USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR lmdb USING stmtheap 32768"
db2 "UPDATE DB CFG FOR lmdb USING dbheap 2400"
db2 "UPDATE DB CFG FOR lmdb USING locklist 1000"
db2 "UPDATE DB CFG FOR lmdb USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR lmdb USING logprimary 12"
db2 "UPDATE DB CFG FOR lmdb USING logsecond 20"
db2 "UPDATE DB CFG FOR lmdb USING logbufsz 32"
db2 "UPDATE DB CFG FOR lmdb USING avg_appls 5"
db2 "UPDATE DB CFG FOR lmdb USING locktimeout 30"
db2 "UPDATE DB CFG FOR lmdb using AUTO_MAINT off"



JCR database update script





You need to perform following additional steps on the JCR DB to match it with the Portal's requirements. replace & with the one you used to create the database.

db2 "CONNECT TO jcrdb USER userid USING pasword"
db2 "CREATE BUFFERPOOL ICMLSFREQBP4 SIZE 1000 PAGESIZE 4 K"
db2 "CREATE BUFFERPOOL ICMLSVOLATILEBP4 SIZE 8000 PAGESIZE 4 K"
db2 "CREATE BUFFERPOOL ICMLSMAINBP32 SIZE 8000 PAGESIZE 32 K"
db2 "CREATE BUFFERPOOL CMBMAIN4 SIZE 1000 PAGESIZE 4 K"
db2 "CREATE REGULAR TABLESPACE ICMLFQ32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('ICMLFQ32') BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE REGULAR TABLESPACE ICMLNF32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('ICMLNF32') BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE REGULAR TABLESPACE ICMVFQ04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('ICMVFQ04') BUFFERPOOL ICMLSVOLATILEBP4"
db2 "CREATE REGULAR TABLESPACE ICMSFQ04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('ICMSFQ04') BUFFERPOOL ICMLSFREQBP4"
db2 "CREATE REGULAR TABLESPACE CMBINV04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('CMBINV04') BUFFERPOOL CMBMAIN4"
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('icmlssystspace32') BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE4 PAGESIZE 4 K MANAGED BY SYSTEM USING ('icmlssystspace4') BUFFERPOOL ICMLSVOLATILEBP4"

db2 "DISCONNECT jcrdb"
db2 "TERMINATE"





Depending on the environment you are setting up you may need to tweak the scripts a little like increasing the pagesize, etc. to achieve the desired level of performance. You can migrate all the Portal DBs into one DB as well but its recommended to have each of them separately for better performance.


Custom Portlet Service

A WebSphere Portlet service is used to provide common functionality/services to portlets. WebSphere Portal provides many out of the box portlet services for different functionality like PUMA, authentication, etc.

JSR 168 portlets use JNDI lookup to obtain an instance of the required portlet service. A portlet service can only be invoked from inside a portlet.

Following are the steps to create a custom Portlet Service:
1. Create an interface which extends com.ibm.portal.portlet.service.PortletService interface and defines public methods which you want to expose through the service.
2. Implement the above interface along with com.ibm.portal.portlet.service.spi.PortletServiceProvider interface in your custom class.
3. Register the portlet service with Portal.

CODE for the above is as follows:

package com.pankaj.portlet.service;

import java.util.Map;

import com.ibm.portal.portlet.service.PortletService;

/**
* @author Pankaj Gupta
*
*/

public interface PortalUserCreationService extends PortletService {

public static final String JNDI_NAME = "portletservice/com.pankaj.portlet.service.PortalUserCreationService";

public static final Class serviceClass = com.pankaj.portlet.service.PortalUserCreationService.class;

public boolean createUser(String shortName, String parentDN, Map map);
}

Code Listing 1: Interface PortalUserCreationService


package com.pankaj.portlet.service.impl;

import java.util.Map;
import java.util.prefs.Preferences;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.PortletServiceUnavailableException;
import com.ibm.portal.portlet.service.spi.PortletServiceProvider;
import com.ibm.portal.um.PumaController;
import com.ibm.portal.um.PumaHome;
import com.ibm.portal.um.User;
import com.ibm.portal.um.exceptions.PumaAttributeException;
import com.ibm.portal.um.exceptions.PumaMissingAccessRightsException;
import com.ibm.portal.um.exceptions.PumaModelException;
import com.ibm.portal.um.exceptions.PumaSystemException;
import com.ibm.websphere.cache.DistributedMap;

/**
* @author Pankaj Gupta
*
*/

public class PortalUserCreationServiceImpl implements PortalUserCreationService, PortletServiceProvider {

private Context ctx = null;

private PumaController pumaController = null;
private PumaHome pumaHome = null;

public boolean createUser(String shortName, String parentDN, Map map) {
boolean flag = false;
try {
User user = pumaController.createUser(shortName, parentDN, map);
flag = true;
}
catch (PumaAttributeException e) {
e.printStackTrace();
}
catch (PumaSystemException e) {
e.printStackTrace();
}
catch (PumaModelException e) {
e.printStackTrace();
}
catch (PumaMissingAccessRightsException e) {
e.printStackTrace();
}
return flag;
}

public void init(Preferences arg0) throws PortletServiceUnavailableException {

try {
ctx = new InitialContext();
pumaHome = (PumaHome)ctx.lookup(PumaHome.JNDI_NAME);
pumaController = pumaHome.getController();
}
catch (NamingException e) {
e.printStackTrace();
}

}

}

Code Listing 2: Implementation of the Listing 1 Interface

package com.pankaj.portlet.service.common;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ibm.portal.portlet.service.PortletService;
import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.PortletServiceUnavailableException;

/**
* @author Pankaj Gupta
*
*/
public class PortletServiceLocator {
//
public static PortletService getPortletService(String jndiName, Class serviceClass){
PortletServiceHome portletServiceHome = null;
PortletService portletService = null;

try {
Context ctx = new InitialContext();
portletServiceHome = (PortletServiceHome)ctx.lookup(jndiName);
portletService = (PortletService) portletServiceHome.getPortletService(serviceClass);
}
catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (PortletServiceUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return portletService;
}
}

Code Listing 3: Service Locator class which abstracts the service lookup.

Monday, January 11, 2010

DB2 DB creation script to create user repository DB for Portal

The following script creates a DB2 DB for storing user credentials. This DB will be used to create a custom user repository in DB2 and use the same to authenticate the portal users.




db2 "CREATE DB wimDb ON 'D:\', 'D:\IBM\wimDb' DBPATH ON 'D:\' using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR wimDb USING applheapsz 4096"
db2 "UPDATE DB CFG FOR wimDb USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR wimDb USING stmtheap 32768"
db2 "UPDATE DB CFG FOR wimDb USING dbheap 2400"
db2 "UPDATE DB CFG FOR wimDb USING locklist 1000"
db2 "UPDATE DB CFG FOR wimDb USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR wimDb USING logprimary 12"
db2 "UPDATE DB CFG FOR wimDb USING logsecond 20"
db2 "UPDATE DB CFG FOR wimDb USING logbufsz 32"
db2 "UPDATE DB CFG FOR wimDb USING avg_appls 5"
db2 "UPDATE DB CFG FOR wimDb USING locktimeout 30"
db2 "UPDATE DB CFG FOR wimDb using AUTO_MAINT off"



Replace the 'D:\', 'D:\IBM\wimDb' DBPATH ON 'D:\' with your own settings. D:\IBM\wimDb is the directory where DB data files will be stored. D:\ is the path under which DB2 directory will be created which will store DB configuration files.

Sponsor Advertisement