Saturday, June 1, 2013

SingleColumnRowMapper & ColumnMapRowMapper examples in Spring

Spring JDBC includes two default implementations of RowMapper - SingleColumnRowMapper and ColumnMapRowMapper. Below are the sample usages of those row mappers.

There are lots of situations when you just want to select one column or only a selected set of columns in your application and to write custom row mapper implementations for these scenarios doesn't seem right. In these scenarios, we can make use of the spring provided row mapper implementations.

SingleColumnRowMapper


This class implements RowMapper interface. As the name suggests, this class can be used to retrieve a single value from the database as a java.util.List. The list contains the column values one per each row.

In the below code snippet, the type of the result value for each row is specified by the constructor argument. It can also be specified by invoking the setRequiredType(Class<T> requiredType) method.

public List getFirstName(int userID)

  String sql = "select firstname from users where user_id = " + userID; 
    
  SingleColumnRowMapper rowMapper = new SingleColumnRowMapper(String.class); 
  List firstNameList = (List) getJdbcTemplate().query(sql, rowMapper); 

  for(String firstName: firstNameList) 
    System.out.println(firstName); 
      
  return firstNameList; 
} 

More information on the class and its methods can be found in the below spring javadoc link.
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/core/SingleColumnRowMapper.html

 

ColumnMapRowMapper


ColumnMapRowMapper class can be used to retrieve more than one column from a database table. This class also implements RowMapper interface.This class creates a java.util.Map for each row, representing all columns as key-value pairs: one entry for each column, with the column name as key.

public List<Map<String, Object>> getUserData(int userID)
{
       
  String sql = "select firstname, lastname, dept from users where userID = ? ";
       
  ColumnMapRowMapper rowMapper = new ColumnMapRowMapper();
  List<Map<String, Object>> userDataList =  getJdbcTemplate().query(sql, rowMapper, userID);

  for(Map<String, Object> map: userDataList){
           
      System.out.println("FirstName = " + map.get("firstname"));
      System.out.println("LastName = " + map.get("lastname"));
      System.out.println("Department = " + map.get("dept"));
           
  }
       
  return userDataList;
       
}


More information on the class and its methods can be found in the below spring javadoc link.
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/core/ColumnMapRowMapper.html

Thursday, July 26, 2012

PLS-00201: identifier 'CONTENT_SEARCH.SEARCH_WITH_RESULTSETINTERFACE' must be declared

Recently, we configured our WebCenterContent (UCM) 11g system to use OracleText as the Search Indexing Engine.

After the Collection was successfully rebuilt, the search was throwing the below error. No results were returned, and always got the error "Unable to return results" on the screen.

*******************************************************************************
>systemdatabase/6    07.20 15:05:05.987    IdcServer-39527    Prepared statement is reused.
>systemdatabase/6    07.20 15:05:05.987    IdcServer-39527    Parameters: ([indexName:FT_IdcText1],[tableName:IdcText1],[queryText:(SDATA(sddDocName LIKE 'SAM1059638'))],
>systemdatabase/7    07.20 15:05:06.003    IdcServer-39527    (start) SELECT 1 FROM DUAL
>systemdatabase/6    07.20 15:05:06.003    IdcServer-39527    0.83 ms. SELECT 1 FROM DUAL[Executed. Returned row(s): true]
>systemdatabase/6    07.20 15:05:06.003    IdcServer-39527    !csDbUnableToExecuteCallableQuery,CotsSearchQuery!$ORA-06550: line 1\, column 7:
 systemdatabase/6    07.20 15:05:06.003    IdcServer-39527    PLS-00201: identifier 'CONTENT_SEARCH.SEARCH_WITH_RESULTSETINTERFACE' must be declared
 systemdatabase/6    07.20 15:05:06.003    IdcServer-39527    ORA-06550: line 1\, column 7:
 systemdatabase/6    07.20 15:05:06.003    IdcServer-39527    PL/SQL: Statement ignored

...................
>services/3    07.20 15:05:06.003    IdcServer-39527    !csUserEventMessage,weblogic,server363!$ intradoc.common.ServiceException: !csSearchUnableToReturnResults
 services/3    07.20 15:05:06.003    IdcServer-39527    *ScriptStack GET_SEARCH_RESULTS
 services/3    07.20 15:05:06.003    IdcServer-39527    3:getSearchResults,**no captured values**
******************************************************************************

Solution for this error is to run the contentprocedures.sql on the WebCenterContent (UCM) schema.

This script can be found in the below location.
\\MIDDLEWARE_HOME\ORACLE_HOME\ucm\idc\database\oracle\admin

Monday, September 26, 2011

Consuming External Web Services in UCM11g

In our project, we were trying to consume external web services from a component in UCM 11g but were unsuccessful for a long time.

The component in 10g to consume web services was working very well but when upgraded to 11g, this component was not working.

In 10g, we bundled the stub classes as a jar and deployed it as part of custom component ($Component/lib). When this component was deployed in 11g, we were getting the below error.

Illegal Argument Exception..............
Interface not visible from class loader.


It was clear from the error that the stub classes are not loaded to the correct class loader.

Finally we achieved it by placing the stub jar in the $DOMAIN_DIR/lib folder where $DOMAIN_DIR is the UCM Domain. Then removed the jar from the component and its class path and restarted and then it started working.

If there is a better solution to the problem, please leave your suggestions as comments.

Saturday, August 27, 2011

Content Server won't start with CSDS failing to get initialized in UCM 11g

Recently I got the below error, because of which my managed server (content server) in UCM 11g was getting started with errors but the application won't come up.

Failed to initialize the application 'CSDS' due to error com.rsa.jsafe.JSAFE_PaddingException: Could not perform unpadding: invalid pad byte..

CSDS is the datasource for the DB that UCM connects to. The CSDS datasource configuration and test connection can be done from the Weblogic Server(WLS) console.

The configuration for CSDS that is viewed through the WLS console is stored in the file
cs-ds-jdbc.xml

The file is located in the below path
$MiddlewareHOME/user_projects/domains/YOUR_DOMAIN/config/jdbc/cs-ds-jdbc.xml

The above mentioned error is due to the encrypted password getting corrupted and to resolve it just replace the encrypted password with its corresponding clear text value in the file cs-ds-jdbc.xml

The password is the schema password to connect to the UCM schema.

Then restart the server, it should start without any errors and the application should come up.

Hope this helps someone.

Weblogic server won't start with invalid pad byte error

Many of us would have faced the below error and weblogic server won't start shortly after either extending a domain or creating a domain or done something related to domain.
weblogic.security.internal.encryption.EncryptionServiceException: com.rsa.jsafe.JSAFE_PaddingException: Could not perform unpadding: invalid pad byte.

I use weblogic 10.3.4. This error occurs when the SerializedSystemIni.dat file gets corrupted. It simply means that the server is unable to decrypt the encrypted passwords because the file that has the hash value to decrypt it - SerializedSystemIni.dat - has got corrupted.

There is nothing to worry though, this error could be resolved easily.

All the encrypted passwords in the file config.xml should be replaced with its corresponding clear text (ordinary text) values and then start the server.

For example if weblogic@123 was your password for the server, then follow the below steps to solve the error.
1) In SecurityConfiguration tag, do the following.

i) Replace
<node-manager-password-encrypted>{3DES}Va1McYXiUPirK77U+SQfMg==</node-manager-password-encrypted>

with

<node-manager-password-encrypted>weblogic@123</node-manager-password-encrypted>

ii) Replace
<credential-encrypted>{3DES}diqufr0TEjlJuLvdnhvtCxEUbxr0yIm8dadNaJRqiefJgGQqcWagiY4tlLX3I3pWa/jpBKeMzyEJgufp/725y1/PXSt0mWOh</credential-encrypted>

with

<credential-encrypted>weblogic@123</credential-encrypted>

2) In the EmbeddedLDAP tag do the following.

Replace

<embedded-ldap>
<name>Your_Domain</name>
<credential-encrypted>{3DES}OVxKttua/KHdFNAxuTypkcPZFAcC8kSHQ4X/ZrhTRLUFLAGocQP0yBT7xX7qijqTBMcMBuXkPq0PC19KDuGy2/fAUXMUGpUn</credential-encrypted>
</embedded-ldap>

with

<embedded-ldap>
<name>Your_Domain</name>
<credential-encrypted>weblogic@123</credential-encrypted>
</embedded-ldap>

Now start your server. It should start without any error.

Note: A word of caution - don't change the order of any of the tags in the config.xml file because if you change it, then you get SchemaValidator error. Just replace the encrypted passwords with its corresponding clear text values.


Friday, July 29, 2011

Hiding Navigation Menus in UCM 11g

I was facing problem in hiding the menus that were coming by default - Search and Check In in UCM11g. It took a little time to find out the syntax to make the OOTB menus disappear in 11g.

There is a dynamic html named navigation_filter_rset_menu_item which is used for this purpose. This dynamic html is defined in the file "std_nav.idoc". Follow the below steps to hide the default menus in UCM 11g.

1) Create an environment variable in your component's environment.cfg file.
ShowOOTBMenus=false

2) <@dynamicdata CoreMenuItems@>
id, label, linkType, linkData
MY_MENU, MY Custom Menu, cgi, IdcService=CUSTOM_SERVICE
<@end@>

3) <@dynamicdata CoreMenuItemRelationships@>
parentId, id, loadOrder
MENU_A, MY_MENU, 30
<@end@>

4) <@dynamicdata CoreMenuItemsFlags@>
id, flags
NEW_CHECK_IN, isContributor:isShowOOTBMenus
<@end@>

5)<@dynamichtml navigation_filter_rset_menu_item@>
<$include super.navigation_filter_rset_menu_item$>
<$if not tmpDeleteRow$>
<$if not isTrue(#env.ShowOOTBMenus) and flags like "*isShowOOTBMenus*"$>
<$tmpDeleteRow = 1$>
<$endif$>
<$endif$>
<@end@>

This should hide the Check In menu from the top horizontal menu. This is the same process for hiding the left navigation menus and sub menus.

Hope this helps.

Saturday, May 21, 2011

Javascript undefined error when using wwStrings in UCM 11g

A javascript error is thrown in UCM 11g when wwStrings is used in javascript as in 10g like wwStrings["someString"].

This is because in UCM 11g, wwStrings is moved to the namespace idc.string.wwStrings

So the syntax in UCM 11g to access the strings in javascript is lc("someString") .

It took all day long for me to figure out this.