Monday, April 16, 2018

Solr Search Customization by introducing a new facet in Websphere Commerce

schema.xml 

This file defines the schema fields and data type of the fields.This file also defines the SOLR field settings. Searchable,sortable SOLR fields are defined here.

Go to the below folder
<WCDE>\search\solr\home\MC_<master_catalog_id>\en_US\CatalogEntry\conf.

Open the file schema.xml in a text editor.

Search for the string “Catentry's basic attributes”. This will bring you to the section of the file where the index fields are defined.

The first block of index fields represent data from the CATENTRY table. Since the field1 value is also stored in the CATENTRY table, you need to add the new index field here.

 At the bottom of the CATENTRY fields add the line:

<!--    Catentry's basic attributes: map to table CATENTRY   -->
<field name="catentry_id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="member_id" type="long" indexed="true" stored="true" multiValued="false"/>
<field name="mfName" type="wc_text" indexed="true" stored="true"  multiValued="false"/>
<field name="buyable" type="int" indexed="true" stored="true" multiValued="false"/>
<field name="field1" type="long" indexed="true" stored="true" multiValued="false"/>

Next we  will update the queries that are used to populate the Solr index from the WebSphere Commerce database tables. Each query needs to retrieve the data stored in field1 of the CATENTRY table.

wc-data-config.xml 

This file contains queries for getting data from preprocess tables (regular WC tables if necessary)to populate the search index. The query results are mapped to SOLR fields in this file. Open the file wc-data-config.xml.

(<WCDE>\search\solr\home\MC_<master_catalog_id>\en_US\CatalogEntry\conf)

The wc-data-config.xml file loads catalog entry data in three separate parts. Product data is loaded first. This is followed by bundle data and finally all other catalog entry types. For each of the three sections there is a query for populating the full index and another query for delta updates. For each section (product, bundle and other), you need to update the two queries and then add a new field element to assign the data from the WebSphere Commerce database to the field1 field in the Solr index. All together there are nine updates you need to make to this file.

Update the product queries and assignment.

1) Search for the string buyable from the top of the file. This is another column in the CATENTRY table that is already included in the query.
2) The first place you find the string is in the main product query. Add CATENTRY.FIELD1 to the SELECT statement immediately following CATENTRY.BUYABLE. Your updated query should look like the screen capture below.

query="SELECT CATENTRY.CATENTRY_ID,CATENTRY.MEMBER_ID,CATENTRY.CATENTTYPE_ID,CATENTRY.PARTNUMBER,CATENTRY.MFPARTNUMBER,CATENTRY.MFNAME, CATENTRY.BUYABLE,CATENTRY.FIELD1,STORECENT.STOREENT_ID

Search for buyable again. The second place you find the string is the delta index query. Make the same update to this query as you did to the previous one.

deltaImportQuery="SELECT CATENTRY.CATENTRY_ID,CATENTRY.MEMBER_ID,CATENTRY.CATENTTYPE_ID,CATENTRY.PARTNUMBER,CATENTRY.MFPARTNUMBER,CATENTRY.MFNAME, CATENTRY.BUYABLE,CATENTRY.FIELD1,STORECENT.STOREENT_ID,

Search for buyable once more. This brings you to the section where the data retrieved from the WebSphere Commerce database is assigned to the Solr index fields. Add an element under buyable to map the FIELD1 database column to the field1 index field. Your updated file should look like the screen capture below.

<field column="CATENTRY_ID" name="catentry_id" />
<field column="MEMBER_ID" name="member_id" />
<field column="PARTNUMBER" name="partNumber" />
<field column="MFNAME" name="mfName" />
<field column="BUYABLE" name="buyable" />
<field column="FIELD1" name="field1" />
                                                                                                                                                                 
Do the steps done for products for  bundles  if required

Make field1 a product facet by making entries in SRCHATTR, SRCHATTRPROP tables

Update the SRCHATTR table. Each row in this table represents the logical name of a catalog attribute that is defined in the search schema.

Enter the SQL below to add field1 to the table. You can use any available primary key, the value 101 is used here as an example. The value of ‘0’ for INDEXSCOPE indicates that this is a site-wide field.

insert into SRCHATTR (srchattr_id, indexscope, indextype, identifier)values (101, '0', 'CatalogEntry','_cat.Field1');

Update the SRCHATTRPROP table. This table stores information about which fields are defined as facets.

insert into SRCHATTRPROP (srchattr_id, propertyname, propertyvalue) values (101,'facet','field1');

JSP Related Changes for displaying facet in Store

Add the facet to the storefront  so that the Madisons storefront to display the facet data in the left sidebar.

Navigate to Stores>WebContent>Madisons>Snippets>ReusableObjects and open the file SearchFacetsDisplay.jspf. This JSP fragment loops through the available global facets and includes another JSP fragment to display each facet’s data. You will create the new JSP fragment for field1 in a later step.

Add a new test into the <c:choose> block to look for the field1 facet and include its display JSP fragment. You can copy one of the existing <c:when> blocks and update it to match the screen capture below.

<c:when test=”${facetField.value eq ‘field1’}”>
 <%@ include file=”../../ Field1FacetDisplay.jspf”%>
 <c:set var=”f” value=”$(f+1}”/>
</when>

Navigate to Stores > WebContent > Madisons > Snippets > Search.
Make a copy of the file  BrandFacetDisplay.jspf and call the new file Field1FacetDisplay.jspf.

Open Field1FacetDisplay.jspf. Remove   the below line starts with

<span class =left_sidebar_header”> <fmt:message key="SEARCH_FACET_MANUFACTURER" bundle="${storeText}"/></span>
Add the below line
<span class =left_sidebar_header”> Shopper points</span>

Management Center changes

1.Login into Management Center
2.Select the Madisons store.
3.Expand the master catalog and select the Coffee Tables category to display the catalog entries list.
4.Select catalog entry
5.Choose configure columns
6.Select field1,and assign some value so that it will come in facets
7.Do the same for other catalog entries

Thursday, March 29, 2018

EJB Bean and table relation in ibm wcs

Some time i want to see custome access bean belongs to which table.

You search for map.mapxmi this file have linking og table with bean.


For OOB beans refer below URL :

Cross-reference of data beans, EJB beans, and tables

Wednesday, March 21, 2018

IBM WCS Toolkit - java.lang.ClassNotFoundException: com.ibm.db2.jcc.am.SqlDataException



ISSUE:
Frist time after starting WCS V8, I hit store URL and i got below exception:
The exception seems to derive from the class: com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor
In particular, this class makes a check about the existing masked exceptions; the list of values of the masked exceptions is contained in the following file:
 IBM\WCDE80\workspace\WC\xml\config\com.ibm.commerce.foundation\wc-component.xml
<_config:configgrouping name="BusinessObjectDocumentProcessor">
    <_config:property name="maskedExceptionClassList" value="java.sql.SQLException,com.ibm.db2.jcc.am.SqlDataException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException"/>
</_config:configgrouping>
The above code contains- in the maskedExceptionClassList property- the class com.ibm.db2.jcc.am.SqlDataException.
 However, the system is not using DB2 but Oracle, so it's pretty normal an exception is thrown and the class is not found.


[3/21/18 12:02:57:315 IST] 000000f6 BusinessObjec W com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor static com.ibm.db2.jcc.am.SqlDataException
                                 java.lang.ClassNotFoundException: com.ibm.db2.jcc.am.SqlDataException
 at java.lang.Class.forNameImpl(Native Method)
 at java.lang.Class.forName(Class.java:256)
 at com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor.<clinit>(BusinessObjectDocumentProcessor.java:141)
 at java.lang.J9VMInternals.initializeImpl(Native Method)
 at java.lang.J9VMInternals.initialize(J9VMInternals.java:235)
 at com.ibm.commerce.catalog.facade.server.CatalogFacadeImpl.getCatalog(CatalogFacadeImpl.java:56)
 at com.ibm.commerce.catalog.facade.server.EJSLocalStatelessCatalog_867afe99.getCatalog(EJSLocalStatelessCatalog_867afe99.java:845)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
 at java.lang.reflect.Method.invoke(Method.java:620)
 at com.ibm.commerce.foundation.internal.client.services.invocation.impl.LocalEJBInvocationBindingImpl.invoke(LocalEJBInvocationBindingImpl.java:211)
 at com.ibm.commerce.foundation.internal.client.services.invocation.InvocationService.invoke(InvocationService.java:113)
 at com.ibm.commerce.foundation.client.facade.bod.AbstractBusinessObjectDocumentFacadeClient.internalSendBusinessObjectDocument(AbstractBusinessObjectDocumentFacadeClient.java:813)
 at com.ibm.commerce.foundation.client.facade.bod.AbstractBusinessObjectDocumentFacadeClient.sendBusinessObjectDocument(AbstractBusinessObjectDocumentFacadeClient.java:529)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:186)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:371)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:397)
 at com.ibm.commerce.catalog.facade.server.cache.DefaultCatalogCache$MyDefaultCatalogCacheableDataAndDependencyIdGenerator.generateCacheableData(DefaultCatalogCache.java:117)
 at com.ibm.commerce.datatype.AbstractFinderResult.invokeFinder(AbstractFinderResult.java:622)
 at com.ibm.commerce.datatype.CacheableFinderResult.invokeFinder(CacheableFinderResult.java:195)
 at com.ibm.commerce.dynacache.commands.AbstractFinderResultCache.myInvokeFinder(AbstractFinderResultCache.java:1526)
 at com.ibm.commerce.dynacache.commands.AbstractFinderResultCache.invokeFinder(AbstractFinderResultCache.java:1161)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache$Cache.getOrPut(AbstractDistributedMapCache.java:520)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache$Cache.access$3(AbstractDistributedMapCache.java:507)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache.getOrPut(AbstractDistributedMapCache.java:285)
 at com.ibm.commerce.catalog.facade.server.cache.DefaultCatalogCache.getDefaultCatalogId(DefaultCatalogCache.java:168)
 at com.ibm.commerce.catalog.facade.server.helpers.CatalogComponentHelper.getDefaultCatalogId(CatalogComponentHelper.java:6272)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.populateStoreUrlKeywords(SEOConfigurationRegistry.java:552)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.initialize(SEOConfigurationRegistry.java:306)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.initializeRegistry(SEOConfigurationRegistry.java:1644)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.singleton(SEOConfigurationRegistry.java:843)
 at com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl.getStoreIdFromSEOURL(SEOURLMapperImpl.java:1636)
 at com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl.processRequestURL(SEOURLMapperImpl.java:1743)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.doFilterAction(RuntimeServletFilter.java:647)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.access$0(RuntimeServletFilter.java:614)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter$1.run(RuntimeServletFilter.java:458)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.doFilter(RuntimeServletFilter.java:500)
 at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
 at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
 at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967)
 at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107)
 at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3926)
 at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
 at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
 at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
 at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)
 at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1049)
 at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:643)
 at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
 at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
 at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
 at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
 at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
 at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
 at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
 at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
 at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)

 Resolution:
1) edit the file
  --> IBM\WCDE80\workspace\WC\xml\config\com.ibm.commerce.foundation\wc-component.xml
 and change the property maskedExceptionClassList with the following value:
 java.sql.SQLException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException

 After change value:

  <_config:configgrouping name="BusinessObjectDocumentProcessor">
   <_config:property name="maskedExceptionClassList" value="java.sql.SQLException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException"/>
  </_config:configgrouping>

 2) restart the test server

Monday, February 12, 2018

CreateKeyException in ibm wcs

"com.ibm.commerce.key.CreateKeyException: unexpected error - no row in keys table for XTABLE"

This issue mostly happens when in you bean class e.g. TableBeam - EjbCreate method using table name in capital and in KEYS table TABLE name is in small.

Solution : Eighter update bean with small letters as you have in keys table or Update KEYS table with table name you have in bean class.

Monday, November 13, 2017

constructing XPATH in IBM WCS



Catalog :

https://www.ibm.com/support/knowledgecenter/en/SSZLC2_7.0.0/com.ibm.commerce.services.doc/Catalog/CatalogEntry/noun.htm


Wednesday, September 20, 2017

Importing SSL certificates

you must export the certificate from the chain into its own certificate file:
1.       Double-click the server's certificate (i.e. server.cer) file and a Certificate dialog box opens.
2.       Click Certification Path tab.
3.       Highlight an entry of the certificate chain.
4.       Click View Certificate.
5.       In the Certificate dialog window, click the Details tab.
6.       Click Copy to File...
7.       In the Certificate Export Wizard that appears, click Next.
Select Base-64 encoded X.509 (.CER), and click Next.
Type in a unique name for the certificate you are exporting and click Next. For example, "payment" for VeriSign's intermediary certificate authority.
8.       Click Finish. Click OK in the dialog box that displays the following message: The export was successful.
Finally, import the intermediary CA certificate into the keystore by completing the following steps:
Process 1:- Using below process sometime you will keep getting handshake exception. I preffer to use process 2
1.       Using the Integrated Solutions Console,
1.1   click Security > SSL Certificate and key management.
1.2   Click Key stores and certificates.
1.3   Click CellDefaultKeyStore.
1.4   Click Signer certificates.
1.5   Click Add.
1.6    In the Alias field, type a short descriptive name for the certificate. For example, "Verisign Intermediary CA."
1.7   In the File name field, type the path to the certificate file of the intermediary CA. For example, C:\certs\ payment.cer.
1.8   Accept the default file data type.
1.9   Click Apply and Save.
Repeat the preceding steps for each intermediary CA that is part of the certificate chain. In most cases, only one intermediary CA exists.

2.       process 2:-
2.1   On the Connections server, enter: cd path_to_WebSphere/WebSphere/AppServer/java/jre/lib/security
2.2    Import the certificate into the keystore. Enter:
keytool -import -alias KeyAlias -file path_to_certificate_file -keystore cacerts -storepass changeit
Examples:
Windows: C:\IBM\WebSphere\AppServer\java\jre\bin\keytool -import -alias ExchangeCert -file C:\certs\ payment.cer -keystore cacerts -storepass changeit
Linux: /opt/IBM/WebSphere/AppServer/java/jre/bin/keytool -import -alias ExchangeCert -file /tmp/payment.cer -keystore cacerts -storepass changeit


Note: changeit is the default password for cacerts

Friday, June 9, 2017

CMN1245E Server fails to redirect to the view URL

Issue - CMN1245E: Server fails to redirect to the view URL.

Sometime when you move to new environment yo face above issue while doing any transection (Like registration or moving to some other view)

Solution : This happens mostly when url filtring is enabled in wc-server.xml and your hostname is not mentioned under allowed domail.

Follow below step:

1. Open the WebSphere Commerce configuration file. (wc-server.xml)
2. Locate the web module where you want to enable this feature. For example, if you want to enable this feature for the Stores web module, modify the following section:

<Module contextPath="/webapp/wcs/stores"
                fileServletEnabled="false" name="Stores"
                urlMappingPath="/servlet" webAlias="/wcsstore">
                <InitParameters adapters="XML/HTTP, BrowserAdapter"
                contextSetName="Store" handleDoubleClick="true"/>
                <URLRedirectFilter enable="true">
                <AllowedHost name="www.mycompany1.com"/>
                <AllowedHost name="www.mycompany2.com"/>
                <AllowedDomain name="mycompany3.com"/>
                </URLRedirectFilter>
</Module>


Refrence - Technote