Wednesday, December 16, 2015

Set limits to the shopping cart in ibm wcs

set limits to the shopping cart

1. Open the xml/config/com.ibm.commerce.order/wc-admin-component.xml file. The default values are shown in the following code snippet:
<_config:extendedconfiguration>
  <_config:configgrouping name="ShoppingCartThreshold">
    <_config:property name="size" value="10000" />
    <_config:property name="quantity" value="10000" />
    <_config:property name="defaultPageSize" value="100" />
    <_config:property name="maximumPageSize" value="100" />
  </_config:configgrouping>
  <_config:configgrouping name="RequisitionListThreshold">
    <_config:property name="size" value="10000" />
    <_config:property name="quantity" value="10000" />
  </_config:configgrouping>
  <_config:configgrouping name="RMAThreshold">
    <_config:property name="size" value="2000" />
    <_config:property name="quantity" value="2000" />
  </_config:configgrouping>
  <_config:configgrouping name="OrderHistoryThreshold">
    <_config:property name="defaultPageSize" value="100" />
    <_config:property name="maximumPageSize" value="100" />
  </_config:configgrouping>
  <_config:configgrouping name="RMAHistoryThreshold">
    <_config:property name="defaultPageSize" value="100" />
    <_config:property name="maximumPageSize" value="100" />
  </_config:configgrouping>
</_config:extendedconfiguration>
Where:
ShoppingCartThreshold
size
The maximum number of order items that can be added to the shopping cart.
quantity
The maximum amount of one specific order item that can be added to the shopping cart (related to UOM, default UOM: C62.).
You can specify multiple quantity thresholds for different UOMs. For example:
<_config:property name="quantity_C1" value="100" />
<_config:property name="quantity_C2" value="1000" />
<_config:property name="quantity_C3" value="10000" />
defaultPageSize
The number of order items that are displayed on the shopping cart page when no paging parameters are passed.
maximumPageSize
The maximum number of order items that are displayed on the shopping cart page.
RequisitionListThreshold
size
The maximum number of order items that can be added to a requisition list.
quantity
The maximum amount of one specific order item that can be added to a requisition list.
You can specify multiple quantity thresholds for different UOMs. For example:
<_config:property name="quantity_C1" value="100" />
<_config:property name="quantity_C2" value="1000" />
<_config:property name="quantity_C3" value="10000" />
RMAThreshold
size
The maximum number of items to be returned.
quantity
The maximum amount of one specific order item to be returned.
OrderHistoryThreshold
defaultPageSize
The number of orders that are displayed on the order history page when no paging parameters are passed.
maximumPageSize
The maximum number of orders that are displayed on the order history page.
RMAHistoryThreshold
defaultPageSize
The number of RMA displayed on the return history page when no paging parameters are passed.
maximumPageSize
The maximum number of orders that are displayed on the return history page.
Save and close the file.

Refer : Set limits to the shopping cart in ibm wcs

Thursday, December 3, 2015

Display Espot data and fetch Espot content in command

Espot display through JSP :
<c:import url="../../include/eMarketingSpotDisplay.jsp">
   <c:param name="emsName" value="EspotName" />
   <c:param name="catalogId" value="${WCParam.catalogId}" />  
</c:import>


Getting content of Espot in command:

String triggerParameters = MarketingUtilClient.createTriggerParametersString(ESPOT_NAME, "", "", "", null); // ESPOT_NAME <-- name of ESPOT
List marketingSpotData = client.getMarketingSpotData(triggerParameters);
MarketingSpotDataTypeImpl mkt = (MarketingSpotDataTypeImpl) marketingSpotData.get(0);


Here Client is: com.ibm.commerce.marketing.facade.client.MarketingFacadeClient

Wednesday, August 26, 2015

Run Or debug WebSphere Commerce Dataload Utilities from RAD

To run / debug your WebSphere Commerce Dataload Utilities from RAD,

Click on “Run Configurations”





Double click on java application: New_configration will appear


 Select new_configuration : In “Main” tab, Provide Main class as “com.ibm.commerce.foundation.dataload.DataLoaderMain”
 In the “Arguments” tab,
 In “Program arguments”, provide Dataload command with all the required parameters '
 In “VM arguments”, provide the value as “-Dj2se=true”

 In “Working directory”  --> other, provide bin folder path















In the “Classpath” tab, add ojdb5.jar as External Jar (If you using Oracle as backend DB)














While running the job, run it as the configuration, you have created


Tuesday, August 25, 2015

DB2 SQL Error: SQLCODE=-723, SQLSTATE=09000

Error: DB2 SQL Error: SQLCODE=-723, SQLSTATE=09000, SQLERRMC=DB2WCS.STAGIATTRNONECMC;-420;22018;BIGINT, DRIVER=3.57.82
SQLState:  09000
ErrorCode: -723


What error mean : 

The SQLCODE=-723 error is telling us that an error occurred in the named trigger (in this case, the trigger is named DB2WCS.STAGIATTRNONECMC).

Refer : SQLCODE=-723

Furthermore, in the second part of the message, DB2 is telling us that the error that is occurring in the trigger is SQL0818N (SQLSTATE 22018)


Here mostly We are passing BIGINT value where it accept CHAR or some other thing.



Friday, August 21, 2015

Rename existing table in db2

Directly renaming table in db2 is difficult. Alternet approch to achieve the same is:

Create table <NewTableName> like <ExistingTableName>
--- It will create same table structure as of existing table

insert into <NewTableName> select * from <ExistingTableName>
--- It will insert all data what we had in existing one.

Tuesday, August 18, 2015

SRVE0190E: File not found: /ManagementCenter.swf

Problem : After doing BuildOpenLazloProject it updates ManagementCenter.swf (Located at \workspace\LOBTools\WebContent) get updated. Some time when we open managment centre we see blank page.


Resolution : From your previour workspace take copy ManagementCenter.swf file and past at \workspace\LOBTools\WebContent. Dont build lazlo project again. Reopen managment centre. It will work

Thursday, August 13, 2015

Avoid dataload failure in ibm wcs


Many time while doing dataload, It get fail at some time for key constrant. How we can avoid it:--


1. Open wc-loader-XXXXX.xml file
2. Search for - <_config:BusinessObjectMediator

3. Get the className, And exyend the class.

4. Override transform method as below. Same way you can get catentry details in catch part.





@Override
protected void transform(Object catalogEntryNoun, boolean deleteFlag)
throws DataLoadException {
// TODO Auto-generated method stub


try{
super.transform(catalogEntryNoun, deleteFlag);
}catch (Exception e) {
TableDataObject.findByPrimaryKey(getAttrID(), null);

System.out.println("Attribute exception"+catalogEntryNoun.toString());
// TODO: handle exception
}



5. Update your loader xml file classname with newly created class and rerun.


Now it will load all data without failure. Some conflich data will go in cath part.

Wednesday, August 12, 2015

Direct add item in cart in ibm wcs through URL



For load testing some time we need to add multiple item in cart. We can achieve it by creating script just need to update catentryId



start /min chrome http://<Domain Name>/webapp/wcs/stores/servlet/NewProductDetailsActionControl?catEntryId=16033169^&quantity=1^&orderId=.^&outOrderName=orderId^&Add2ShopCart=true^&URL=/webapp/wcs/stores/servlet/OrderItemDisplay 

Great example of CREATE TRIGGER with declear set if statment


************************INSERT*****************************************

Create  trigger IBUNDELDERIVED
               AFTER INSERT ON CATENTREL REFERENCING NEW AS N
               FOR EACH ROW MODE DB2SQL
               BEGIN ATOMIC
                           declare reltype CHAR(32);
                           declare existing INT;
                           set reltype=TRIM(N.CATRELTYPE_ID);
                           if  (reltype is not NULL AND reltype  = 'BUNDLE_COMPONENT')
    THEN
                SET existing=(select count(*) from X_BUNDLE_DERIVED where BUNDLE_CATENTRY_ID=N.CATENTRY_ID_PARENT and ATTRIBUTE='Sequence');
                if (existing=0)
                then
                        insert into X_BUNDLE_DERIVED(BUNDLE_CATENTRY_ID,ATTRIBUTE,DERIVATION_STATUS)
                                VALUES (N.CATENTRY_ID_PARENT,'Sequence','UnProcessed');
                end if;
        end if;
               END#

********************************UPDATE*************************************
CREATE TRIGGER UBUNDELDERIVED
AFTER UPDATE ON CATENTREL REFERENCING NEW AS N OLD AS O
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC

declare reltype CHAR(32);
declare existing INT;
set reltype=TRIM(N.CATRELTYPE_ID);

if  (reltype is not null and reltype  = 'BUNDLE_COMPONENT')
    then
SET existing=(select count(*) from X_BUNDLE_DERIVED where BUNDLE_CATENTRY_ID=N.CATENTRY_ID_PARENT and ATTRIBUTE='Sequence');
if (existing =0)
then
insert into X_BUNDLE_DERIVED(BUNDLE_CATENTRY_ID,ATTRIBUTE,DERIVATION_STATUS)
values(N.CATENTRY_ID_PARENT,'Sequence','UnProcessed');
end if;
end if;
 END#

Monday, July 6, 2015

EJB file commit in SVN

Issue : Which all file need to commit in SVN after creating new EJB

Following files need to be committed :

1. No file need to committed which start with "_"
2. File name start with EJS also no need to be committed.
3. Updated: \WebSphereCommerceServerExtensionsData\ejbModule\META-INF\ibm-ejb-access-bean.xmi
4. Updated: WebSphereCommerceServerExtensionsData\ejbModule\META-INF\ejb-jar.xml
5. Updated: WebSphereCommerceServerExtensionsData\ejbModule\META-INF\ibm-ejb-jar-ext.xmi
6. Updated:WebSphereCommerceServerExtensionsData\ejbModule\META-INF\backends\DB2UDBNT_V82_1\<Your DBM Files>.dbm
7. Updated: WebSphereCommerceServerExtensionsData\ejbModule\META-INF\backends\DB2UDBNT_V82_1\ibm_pmbab.properties
8. Updated: WebSphereCommerceServerExtensionsData\ejbModule\META-INF\backends\DB2UDBNT_V82_1\Map.mapxmi
9. Updated: WebSphereCommerceServerExtensionsData\ejbModule\META-INF\ibm-ejb-jar-bnd.xmi
10. 

Wednesday, July 1, 2015

Shortening the context root of a store URL

Shortening the context root of a store's URL makes it easier for shoppers to remember a link and also improves visibility in search engine results.

You can change the default site URL from http://hostname/webapp/wcs/stores/servlet/StoreName/index.jsp to something shorter, such as: http://hostname/shop/StoreName/index.jsp. In this example, shop is used to replace the context root, but any name can be used in its place.
Here the requirement was different, and we need not to display context root in the URL at all, the context root replacement value should be blank.

For example:
Old URL: http://hostname/webapp/wcs/stores/servlet/StoreName/index.jsp
New URL: http://hostname/StoreName/index.jsp

To achieve this functionality we need to update below files:
httpd.conf
wc-server.xml
httpd.conf changes:

If you are running an IBM HTTP Server:
Open the httpd.conf file for editing.
Locate the virtualhost object: <VirtualHost servername:80> Insert the following code inside the <VirtualHost servername:80> object before the ending </VirtualHost> tag.

***********************************************
NOTE:

xyz is DNS

 RewriteEngine on

ServerName  www.xyz.com
ServerAlias  www.xyz.com


RewriteCond %{HTTP_HOST} ^xyz.com$
RewriteCond %{REQUEST_URI} ^(/en/myobof/(.*)|/en/myobof)
RewriteRule ^/(.*) /webapp/wcs/stores/servlet/$1 [PT,L]
******************************************************
 RewriteRule ^/(.*)$      /webapp/wcs/stores/servlet/$1 [PT,NC]
Locate the virtualhost object: <VirtualHost servername:443> Insert the following code inside the <VirtualHost servername:443> object before the ending </VirtualHost> tag.

 RewriteEngine on
 RewriteRule ^/(.*)$      /webapp/wcs/stores/servlet/$1 [PT,NC]
wc-server.xml changes:

Open the wc-ser.xml for editiong.
Search for the SEOConfiguration section.
Update the  element as given below (update the context-root-rewrite with "/").
     <SEOConfiguration defaultUrl="" dynamicUrl="true" enable="true">
        <context-root-rewrite value="/" />
    </SEOConfiguration>
  

  Now you are done with the changes Restart your web server and app server and validate your changes.



Refrence : Shortening the context root of a store URL

Monday, June 29, 2015

Creating new EJB in IBM WCS


NOTE: If you want your table to be used in stagprop, Make sure table name doesnot exceed 18 CHAR length.

Creating new EJB :
Create Table:

1.       Do physical mapping in RAD : Go to WebSphereCommerceServerExtensionsData > Data Models > WCDEV.dbm à Select DB2ADMIN schema. Rename it to NULLID
2.       Right-click NULLID > Add Data Object > Table.
3.       Create ur table. Right click on table and generate DDL. This ddl you can use to create table in DB.



4.       Create the XOrderItemsBundles entity bean
4.1 In the Enterprise Explorer view, expand WebSphereCommerceServerExtensionsData.
4.2 Right-click Deployment Descriptor: WebSphereCommerceServerExtensionsData; select New > Enterprise Bean
4.3 In the Create and Enterprise Bean window:
4.4 Select Entity bean with container-managed persistence (CMP) fields
In the Source folder field, leave the default value, ejbModule.
In the Default package field, enter com.ibm.commerce.extension.objects.
From the CMP Version list, select 1.x.
Click Next.


5.       In the Enterprise Bean Details window, add new CMP attributes for the OrederId,OrderItemsID etc.
5.1 Select the default CMP attribute id:java.lang.Integer and click Remove.
Click Add.
5.2 In the Name field, enter OrederId.
5.3 In the Type field, enter java.lang.Long.
Note : You must use the java.lang.Long data type, not the long data type, since the column OrederId that you are trying to map to is BIGINT or NUMBER.

Select the Key Field check box to indicate that this field is the primary key of the database table.
Click Apply.
Same way for other field.
You must use the java.lang.Integer data type, not the integer data type.


Ensure the Access with getter and setter methods check box is selected. By selecting this option all getter and setter methods will be automatically generated for all fields.



Clear the Access with getter and setter methods check box.
Click Apply then Close to close this window.
Ensure the Use the single key attribute type for the key class check box is not selected, then click Next. Ensuring this check box is not selected ensures that a key class is created, ensuring consistency with other beans.
In the EJB Java Class Details window, create the entity bean called Bonus:
To select the bean's superclass, click Browse.
In the Type Selection window, in the Select a class using: (any) field, enter ECEntityBean and click OK.
Specify the interfaces that the remote interface should extend by clicking Add.
In the Type Selection window, in the Select an interface using: (any) field, enter Protectable and click OK to select com.ibm.commerce.security.Protectable. This interface is required in order to protect the new resource under access control.
Click Next.






Deselect Add bean to Class Diagram.
Click Finish.



Setting EJB properties : Set the EJB isolation level
WebSphereCommerceServerExtensionsData > Deployment Descriptor > Entity Beans
  1. Right-click On your bean and open the bean in its deployment descriptor.
  2. Click the Access tab.
  3. Next to the Isolation Level text box, click Add.
  4. In the Add Isolation Level window, select Read committed, then click Next.
  5. From the Beans found list, select the Bonus bean, then click Next.
  6. From the Methods found list, select Bonus to select all of its methods, and click Finish.
  7. Save your changes and keep the editor open





Set the security identity of the bean:
Ø  Select the Access tab selected.
Ø  In the Security Identity (Method Level) section, click Add.
Ø  Select Use identity of EJB server, then click Next. The Use identity of EJB server field ensures that all EJB beans run under the same identity for security.
Ø  From the Beans found list, select the your bean, then click Next.
Ø  From the Methods found list, select your bean to select all of its methods, and click Finish.
Ø  Save your changes and keep the editor open.





Remove the unused generated fields and methods. The ECEntityBean base class provides its own implementation of these methods:
In the Java EE view, expand WebSphereCommerceServerExtensionsData > Entity Beans > XOrderItemsBundlesBean
Open the XOrderItemsBundlesBeanclass for editing
Ø  In the Outline view removed the unused fields:
Ø  Select the myEntityCtx field and from its pop-up menu, select Delete.
Ø  Select the getEntityContext() method and from its pop-up menu, select Delete.
Ø  Select the setEntityContext(EntityContext) method and from its pop-up menu, select Delete.
Ø  Select the unsetEntityContext() method and from its pop-up menu, select Delete.


Add getter method for all primary key fields.
You can generate this method without having to type the source. Right-click the catalogId property in the Outline view, and select Source > Generate Getter and Setters. Select only the getOrderItemId()
method
In the Outline view, right-click the getOrderItemId method and select Enterprise Bean (1.x-2.x) > Promote to Remote Interface

Add Ejb finder :
  1. In the EJB Deployment Descriptor editor, click the Bean tab.
  2. In the Beans pane, select the XOrderItemsBundles bean.
  3. Click Add next to the Finders text box, as in the following screen capture:



Add ejbCreate and ejbPostCreate methods :
/**
                 * ejbCreate method for a CMP entity bean.
                 */
                public com.XYZ.commerce.bundleorder.XOrderItemsBundlesKey ejbCreate(
                                java.lang.Long orderItemsId,
                                java.lang.Long bundleCatentryId,
                                java.lang.Long ordersId,
                                java.lang.Long catentryId,
                                java.lang.String slot,
                                java.lang.String field1,
                                java.lang.String field2,
                                java.lang.Integer field3) throws javax.ejb.CreateException {
                                this.initializeFields();
                                _initLinks();
                                this.orderItemsId = orderItemsId;
                                this.bundleCatentryId = bundleCatentryId;
                                this.ordersId = ordersId;
                                this.catentryId= catentryId;
                                this.slot = slot;
                                this.field1 = field1;
                                this.field2 = field2;
                                this.field3 = field3;
                                XOrderItemsBundlesKey bunKey = new XOrderItemsBundlesKey(orderItemsId,bundleCatentryId);
                                this.initializeOptCounter(bunKey);
                                return null;
                }

                /**
                 * ejbPostCreate
                 */
                public void ejbPostCreate(
                                java.lang.Long orderItemsId,
                                java.lang.Long bundleCatentryId,
                                java.lang.Long ordersId,
                                java.lang.Long catentryId,
                                java.lang.String slot,
                                java.lang.String field1,
                                java.lang.String field2,
                                java.lang.Integer field3) throws javax.ejb.CreateException {
                }
In the Outline view, right-click the ejbCreate(Long, Integer, Short, Integer, String) method you just created and select Enterprise Bean (1.x-2.x) >Promote to Home Interface

getOwner And fulfills method is not necessary till you have foreign key to any table.

Create getter method for all primary key and in outline right click on getter method  select Enterprise Bean > Promote to Remote Interface. Once this is complete, a small R icon displays next to the method, indicating that it has been promoted to the remote interface.

Map the database table to the EJB :
In the Java EE perspective Enterprise Explorer view, right-click WebSphereCommerceServerExtensionsData and select Java EE > EJB to RDB Mapping (1.x-2.x) > Generate Map






Click finish. If you have preexisting folder :
In overview section by clicking all column you should get field mapped.

Make the bean portable and enable optimistic locking

Enable optimistic locking. Open the deployment descriptor under WebSphereCommerceServerExtensionsData
In the Enterprise Explorer view, navigate to WebSphereCommerceServerExtensionsData > Deployment Descriptor.
Ø  Open the deployment descriptor for editing.
Ø  In the Bean tab, select the your bean.
Ø  In the lower right pane, scroll down to the Concurrency Control section.
Ø  Select Enable optimistic locking.
Ø  Save your changes.
Edit methods to call optimistic locking classes. In the XOrderItemsBundle class make the following changes:
Ø  In the Outline view, select ejbLoad() and add the following code as the first line in the method: super.ejbLoad();
Ø  In the Outline view, select ejbStore() and add the following code as the first line in the method: super.ejbStore();
Ø  In the Outline view, select ejbCreate(Long, Integer) and add the following code:
Ø  Add this.initializeFields(); as the first line in the method.
Ø  Add the following two lines to the method before the return statement
XOrderItemsBundlesKey bunKey = new XOrderItemsBundlesKey(orderItemsId,bundleCatentryId);
            this.initializeOptCounter(bunKey);
Ø  Save your changes.
Generate the Access Bean for the EJB
In the Java EE perspective Enterprise Explorer view, right-click WebSphereCommerceServerExtensionsData . Select New > Other. In the list of options, expand EJB
and select Access Bean. Select Next.
On the Select an Access Bean Type page, select Copy helper . Select Next
On the Select EJB Project page, select XOrderItemsBundles bean.
Select Next.
 On the Copy Helper Access Bean page, for the Constructor method, select
findByPrimaryKey(com.ibm.commerce.extension.helpers.XPaperCatalog).
Select Finish.
Right-click WebSphereCommerceServerExtensionsData. Select Java EE >Prepare for Deployment


Save all file.

Tuesday, June 23, 2015

SQLCODE=-7, SQLSTATE=42601

Issue : com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-7, SQLSTATE=42601

While testing EJB from test client in IBM wcs - If u are getting above issue.

1. Recreate table in NULLID.
2. Save your .dbm file
3. Do mapping again.
4.Do prepare for deployment
5. Regenerate accessbean
6. Test again - It will work

Adding/Deleting fields for Existing EJB


Adding/Deleting fields for Existing EJB

As requirements evolve during the course of a project, the developer may find it necessary to adjust the existing data model.  In most cases, this involves adding or deleting a table column.  Once the table definition is changed, the developer must also update the corresponding EJB.  This is a common development task, yet there is no tutorial or documentation in the WebSphere Commerce Infocenter.
A number of files are generated automatically when the EJB is first created, so it’s not always clear which code should be updated. Follow these steps when adding or deleting fields for existing EJB:
1. Take snapshot!
2. Modify deployment descriptor/bean class
3. Open bean class and add/delete CMP attribute
4. Demote ejbCreate from Home interface
5. Add/delete CMP attribute in ejbCreate and ejbPostCreate argument list
6. Promote ejbCreate to Home interface
7. Modify _copyToEJB and _copyfromEJB methods to account for added/removed field
8. Modify data definition:  WebSphereCommerceServerExtensionsData > ejbModule > META-INF > backends > {databaseType} > MALL_NULLID_{tableName}.tblxmi. Add/delete column from table definition.
9. Modify EJB to RDB mapping:   WebSphereCommerceServerExtensionsData > ejbModule > META-INF > backends > {databaseType} > Map.mapxmi

If adding an EJB field, map the field to the table column.
If deleting a field, remove it from the mapping.

 Note: The field may already have been removed from the mapping when the deployment descriptor and data definition were saved in the previous steps.
10. Deploy.  If the following error occurs, There are no enterprise beans in WebSphereCommerceServerExtensionsData, delete all auto-generated files (prefixed with the underscore), and deploy again.
Build.
11. Regenerate access bean.


We modify the _copy methods to ensure that all bean references are updated.  Without this step, we found that the deployment descriptor sometimes reverted to the original bean definition.

Wednesday, June 17, 2015

Display all subcatogry in facets IBM WCS

Displaying only child category facets of a browsed category
Displaying only child category facets of a browsed category helps limit the number of SQL queries for catalogs with a large number of categories.

Problem
Displaying only child category facets of a browsed category helps limit the number of SQL queries for catalogs with a large number of categories. Otherwise, there is a performance hit for browsing child categories within a category.

If the MAX_DISPLAY column in the FACET value is set too low, some categories might not work correctly.

Solution
To resolve this issue:
Set the MAX_DISPLAY column in the FACET table to -1.
Set the displayChildCategoriesOnly property to true in your custom wc-component.xml file. For more information, see Changing properties in the component configuration file (wc-component.xml) (Search EAR).

These settings ensure that only child category facets of the browsed category are displayed, and that the subcategories of the child categories are not faceted.

e.g To display all subcatogry in catogry landing page 

update facet set  MAX_DISPLAY  = -1
where SRCHATTR_ID in (select SRCHATTR_ID from SRCHATTR where IDENTIFIER= '_cat.ParentCatalogGroup'  and INDEXTYPE = 'CatalogEntry' ) ;

Tables involved with WebSphere Commerce Scheduler framework

Tables involved with WebSphere Commerce Scheduler framework


SCHCMD - All the store and site level scheduler commands are configured in this table. For site level scheduler commands, we can also use the controller commands configured in the struts config file and it's not necessary that all site level schedulers commands needs to be configured in this table but all store level scheduler commands need to configured in this table.

CHKCMD - Check command details are stored in this table. Lets consider a simple scenario, as per requirement you would like to run a specific scheduler command only on weekdays. So before running a scheduler command, you would like to check whether it's weekday or not and decide based on it. This kind of validation is done through this check command and each scheduler command may or may not have a check command.

SCHCONFIG - When you configure a scheduler in WebSphere Commerce admin console, all configuration details are stored in this table. It has details about all the scheduler jobs configured at WebSphere Commerce

SCHACTIVE - This table holds details about what schedule job needs to be executed and when it needs to be executed. WebSphere Commerce scheduler framework looks up for this table to identify which scheduler job needs to be executed at a given time.

SCHSTATUS - The status of all the scheduled jobs gets stored in this table. Like what's the current status of this schedule job, when it's started, when it's ended, whether it's failed or succeed etc.

SCHERRORLOG - When particular schedule job failed to execute, this table logs the exception information against each failed job. This helps to understand why specific scheduled job failed to run.

In short, scheduler command and task command details are stored in SCHCMD and CHKCMD table and scheduler configuration related details are stored in SCHCONFIG and SCHACTIVE. Scheduler framework monitors the SCHACTIVE table to identify which scheduled job needs to be running at a specified time, pulls the corresponding scheduled job configuration details from SCHCONFIG table, executes the identified scheduled job and updates the status in SCHSTATUS table and logs the error message in SCHERRORLOG table if specific scheduled job failed.

The above mentioned tables are not the complete list of tables used by WebSphere Commerce Scheduler Framework, you can refer the Knowledge Center article here to know more about it. This is more like a basic foundation blog for the succeeding blogs which I am going to write about scheduler framework.


Tuesday, June 16, 2015

ERROR - import javax.servlet can't be resolved

ERROR - import javax.servlet can't be resolved
Solution:
Add servlet-api.jsr to the build path or specify the target runtime for the project.
Steps to add servlet-api.jar

1.       Right-click the project, click Properties.
2.       Choose Java Build Path.
3.       Click Add External JARs...
4.       Browse to find servlet-api.jar and select it.
5.       Click OK to update the build path.
Steps to specify the target runtime
1.       Right-click the project, click Properties.
2.       Click Target Runtime.

3.       Set the target runtime and click Ok.

Tuesday, June 9, 2015

Exception detected - PromotionSystemException

Error : Exception detected "com.ibm.commerce.promotion.facade.server.exception.PromotionSystemException: Exception detected "org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. ".". --


Solution :

Mostly we get this issue when we creat promotion or custom promotion in debug mode.

1. Do a clean build
2. Build LobTools
3. Restart server in normal mode.

Sunday, May 31, 2015

Understanding trace.syms 2>&1

Understanding trace.syms 2>&1

cmd 2>&1 > log
This redirects stderr to wherever stdout is currently being redirected, which is typically the console. Then stdout is redirected to log. Remember that stderr does not "follow" stdout, so it continues to redirect to the console.

End result: stdout is redirected to the log file and stderr is (still) sent to the console. This is almost certainly not what you want.

Here’s an example command:

wibble > /dev/null 2>&1
Output redirection
The greater-thans (>) in commands like these redirect the program’s output somewhere. In this case, something is being redirected into /dev/null, and something is being redirected into &1.

Standard in, out, and error
There are three standard sources of input and output for a program. Standard input usually comes from the keyboard if it’s an interactive program, or from another program if it’s processing the other program’s output. The program usually prints to standard output, and sometimes prints to standard error. These three file descriptors (you can think of them as “data pipes”) are often called STDIN, STDOUT, and STDERR.

Sometimes they’re not named, they’re numbered! The built-in numberings for them are 0, 1, and 2, in that order. By default, if you don’t name or number one explicitly, you’re talking about STDOUT.

Given that context, you can see the command above is redirecting standard output into /dev/null, which is a place you can dump anything you don’t want (often called the bit-bucket), then redirecting standard error into standard output (you have to put an & in front of the destination when you do this).


The short explanation, therefore, is “all output from this command should be shoved into a black hole.” That’s one good way to make a program be really quiet!

Friday, May 29, 2015

503 issue in ibm WCS

Problem

Creating, formatting, and reading packet traces is sometimes required to resolve problems with IBM WebSphere  Edge Server. However, the most appropriate tool varies, depending on operating system.
Resolving the problem

Available for multiple operating systems
Wireshark is useful and a freely available tool that can read files and capture packets on almost any operating system.
Solution :

1.     Run iptrace on AIX interface en1 to capture port 80 traffic from a single client IP to a server IP:

iptrace -a -i en1 -s clientip -b -d serverip -p 80 trace.out

This trace will capture both directions of the port 80 traffic on interface en1 between the clientip and serverip and send this to the raw file of trace.out.
2.     Reproduce the problem, then run the following:

ps -ef|grep iptrace
kill -15 <pid>

Trace tools like Wireshark can read trace.out files created by iptrace 

Using Wireshark







Thursday, May 7, 2015

Some useful methods in IBM WCS


/***** Getting DB connection and run direct SQL ******/

public class CommonJDBCHelperBean extends BaseJDBCHelper implements SessionBean {
private String fetchPhysicalStoresSQL = "select stloc_id, identifier, address1, address3, country from stloc where latitude = ? order by address1"
                  + READONLY_WITH_UR_CLAUSE;

                /**
                 * It fetches list of all active stores address details from STLOC table.
                 *
                 * @return Vector - list of StoreLocationObjectBean
                 * @throws NamingException
                 *             If failed to get SQL connection
                 * @throws SQLException
                 *             if failed to execute SQL query
                 */
                public Vector fetchPhysicalStores(String storeId) throws NamingException, SQLException {
                                final String methodName = "fetchPhysicalStores";
                                if (logger.isLoggable(TraceIdentifiers.METHOD_ENTRY_EXIT)) {
                                                logger.entering(CLASS_NAME, methodName);
                                }
                                Vector vPhysicalStore = new Vector();
                                PreparedStatement stmt = null;
                                ResultSet rs = null;
                                try {
                                                makeConnection();
                                                if (logger.isLoggable(TraceIdentifiers.DEBUG_OUTPUT)) {
                                                                logger.logp(TraceIdentifiers.DEBUG_OUTPUT, CLASS_NAME, methodName, "sql is[{0}]",
                                                                                                fetchPhysicalStoresSQL.toString());
                                                }
                                                stmt = getPreparedStatement(fetchPhysicalStoresSQL);
                                                stmt.setBigDecimal(1, new BigDecimal(storeId));
                                                rs = executeQuery(stmt, false);
                                                while (rs.next()) {
                                                                StoreLocationObjectBean storeLocationObjectBean = new StoreLocationObjectBean();
                                                                storeLocationObjectBean.setStloc_id(rs.getString(1));
                                                                storeLocationObjectBean.setIdentifier(rs.getString(2));
                                                                storeLocationObjectBean.setAddress1(rs.getString(3));
                                                                storeLocationObjectBean.setAddress3(rs.getString(4));
                                                                storeLocationObjectBean.setCountry(rs.getString(5));
                                                                vPhysicalStore.add(storeLocationObjectBean);
                                                }
                                } finally {
                                                closeConnection();
                                                if (null != rs) {
                                                                rs.close();
                                                }

                                                if (null != stmt) {
                                                                stmt.close();
                                                }
                                }
                                if (logger.isLoggable(TraceIdentifiers.METHOD_ENTRY_EXIT)) {
                                                logger.entering(CLASS_NAME, methodName);
                                }
                                return vPhysicalStore;

                }

/********* To send XML in QUEUE ***************/

To send OR02XML

Insert in msgtype:
insert into msgtypes values(10002,1,'OR02MIGRATION','OR02MIGRATION','Abster Send OR02 XML Message for completed Orders',null);


SendMsgCmd sendXMLCmd = (SendMsgCmd) CommandFactory
                                                                        .createCommand(SendMsgCmd.NAME, oaBean.getStoreEntityIdInEJBType());
                                                sendXMLCmd.setMsgType("OR02MIGRATION");
                                                sendXMLCmd.setStoreID(oaBean.getStoreEntityIdInEJBType());
// get clone of request to put additional values
                                                TypedProperty properties = (TypedProperty) getRequestProperties()
                                                                        .clone();
properties.put("ordersId", ordersId);
properties.put("OrderRefNumber", ordersId);
properties.put("LanguageId", -1);
sendXMLCmd.compose(OR02_VIEW,getCommandContext(), properties);
sendXMLCmd.sendTransacted();
sendXMLCmd.setCommandContext(getCommandContext());

sendXMLCmd.execute();



*****************Session *******************
<c:choose>
<c:when test="${userType == 'G' || fn:contains(userEmail,'@X.XX')|| user_id == '-1002'}">
<%
session.setAttribute("eMarketsubscriberBeanRequired","N");
session.setAttribute("subscriberBean",new com.xxxx.commerce.subscribers.commands.EmailServiceDataBean());
%>

</c:when>

<c:otherwise>

<wcbase:useBean id="bnRegister" classname="com.ibm.commerce.user.beans.UserRegistrationDataBean" >
<c:set value="${CommandContext.user.userRegistry.userId}" target="${bnRegister}" property="userId"/>
</wcbase:useBean>
<c:set var="service_Id"><fmt:message key="SUBSCRIPTION_DEFAULT_SERVICE_ID" bundle="${storeFrontText}"/></c:set>
<c:set var="qubituserEmail" value="${bnRegister.email1}" />
<c:if test="${!fn:contains(qubituserEmail,'@X.XX')|| user_id == '-1002'}">
<%
Object isAlreadyAvailable= session.getAttribute("eMarketsubscriberBeanRequired");                                            
              if(null != isAlreadyAvailable && isAlreadyAvailable.toString().equals("N")) {                                          

%>
<wcbase:useBean id="bean" classname="com.xxxxx.commerce.subscribers.commands.EmailServiceDataBean">
<c:set value="${service_Id}" target="${bean}" property="inputVal" />
<c:set value="${qubituserEmail}" target="${bean}" property="userEmail"/>
<c:set value="${userType}" target="${bean}" property="userType"/>
</wcbase:useBean>
<%
session.setAttribute("eMarketsubscriberBeanRequired","Y");
session.setAttribute("subscriberBean",bean);
}
%>    
</c:if>

</c:otherwise>
</c:choose>


Using it

<%@include file="QubitMarketing.jspf"%>
<%
com.xxxxxx.commerce.subscribers.commands.EmailServiceDataBean subscriberBean=(com.xxxxx.commerce.subscribers.commands.EmailServiceDataBean)session.getAttribute("subscriberBean"); 
if(subscriberBean!= null && subscriberBean.getSubscriberId() > 0 && subscriberBean.getSubscriptionId()>0 && subscriberBean.getSubscriptionStatus()>0){%>,
"subscriber_id": "<c:out value="${subscriberBean.subscriberId}" />",
"subscription_id": "<c:out value="${subscriberBean.subscriptionId}" />"<%} %>

Creating data bean
public class EmailServiceDataBean implements SmartDataBean {
private static final String CLASS_NAME = EmailServiceDataBean.class
.getName();
private static final Logger logger = Logger.getLogger(CLASS_NAME);
private Long subscriberId;
private String emailAddress;
private Integer brandId;
private String userEmail;
protected Integer Key_emailServiceId;
private String userType;
private Long subscriptionId;
private Short subscriptionStatus;
public CommandContext iCommandContext = null;
public TypedProperty requestProperties = null;

public String getUserType() {
return userType;
}

public void setUserType(String userType) {
this.userType = userType;
}

protected String inputVal;

public String getInputVal() {
return inputVal;
}

public void setInputVal(String inputVal) {
this.inputVal = inputVal;
}

public Integer getKey_emailServiceId() {
return Key_emailServiceId;
}

public void setKey_emailServiceId(Integer key_emailServiceId) {
Key_emailServiceId = getKey_emailServiceId();
}

public String getUserEmail() {
return userEmail;
}

public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}

public Long getSubscriberId() {
return subscriberId;
}

public void setSubscriberId(Long subscriberId) {
this.subscriberId = subscriberId;
}

public String getEmailAddress() {
return emailAddress;
}

public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}

public Integer getBrandId() {
return brandId;
}

public void setBrandId(Integer brandId) {
this.brandId = brandId;
}

@Override
public void populate() throws Exception {
final String METHOD_NAME = "populate";
if (logger.isLoggable(TraceIdentifiers.METHOD_ENTRY_EXIT)) {
logger.entering(CLASS_NAME, METHOD_NAME);
}
// EmailServiceAccessBean is initilize to get brand_id from
// EMAIL_SERVICE table
EmailServiceAccessBean emailServiceAccessBean = new EmailServiceAccessBean();
emailServiceAccessBean.setInitKey_emailServiceId(Integer
.valueOf(getInputVal()));
emailServiceAccessBean.refreshCopyHelper();
brandId = emailServiceAccessBean.getBrandId();
// Guest user check. If user is of type guest then emailId will not
// available
System.out.println("brandId"+brandId);
System.out.println("getInputVal()"+getInputVal());
try {
if (!getUserType().equals("G") && !getUserEmail().equals(null)) {
// subscriberId from SubscriberAccessBean
SubscriberAccessBean subscriberAccessBean = new SubscriberAccessBean();
subscriberAccessBean.findByBrandIdAndEmailAddress(brandId,
getUserEmail());
Enumeration subscriberIds = null;
subscriberIds = subscriberAccessBean
.findByBrandIdAndEmailAddress(brandId, getUserEmail());
if (subscriberIds != null) {
boolean count = true;
while (subscriberIds.hasMoreElements() && count == true) {
subscriberId = ((SubscriberAccessBean) (subscriberIds
.nextElement())).getSubscriberId();
count = false;
}
}
// subscriptionId from SubscriptionsAccessBean
System.out.println("subscriberId"+subscriberId);
Enumeration subscriptionIds = null;
Enumeration subscriptionStatuss = null;
SubscriptionsAccessBean subscriptionsAccessBean = new SubscriptionsAccessBean();
try {
if (subscriberId != null) {
subscriptionIds = subscriptionsAccessBean
.findBySubscriberIdAndEmailServiceId(
subscriberId, Integer
.valueOf(getInputVal()));
subscriptionStatuss = subscriptionsAccessBean
.findBySubscriberIdAndEmailServiceId(
subscriberId, Integer
.valueOf(getInputVal()));
if (subscriptionIds != null) {
boolean count1 = true;
while (subscriptionIds.hasMoreElements()) {
subscriptionId = ((SubscriptionsAccessBean) (subscriptionIds
.nextElement())).getSubscriptionId();
count1 = false;
}
}
if (subscriptionStatuss != null) {
boolean count1 = true;
while (subscriptionStatuss.hasMoreElements()) {
subscriptionStatus = ((SubscriptionsAccessBean) (subscriptionStatuss
.nextElement()))
.getSubscriptionStatus();
count1 = false;
}
}
}
} catch (NullPointerException e) {
System.out.println("subscriberId is null ..."
+ e.getMessage());
}
}
} catch (Exception e) {
System.out.println("No Record Found ...." + e.getMessage());
}

if (logger.isLoggable(TraceIdentifiers.METHOD_ENTRY_EXIT)) {
logger.exiting(CLASS_NAME, METHOD_NAME);
}
}

public Long getSubscriptionId() {
return subscriptionId;
}

public void setSubscriptionId(Long subscriptionId) {
this.subscriptionId = subscriptionId;
}

public Short getSubscriptionStatus() {
return subscriptionStatus;
}

public void setSubscriptionStatus(Short subscriptionStatus) {
this.subscriptionStatus = subscriptionStatus;
}

@Override
public void setCommandContext(CommandContext commandContext) {
iCommandContext = commandContext;
}

@Override
public void setRequestProperties(TypedProperty reqProp) throws Exception {
requestProperties = reqProp;
}

@Override
public CommandContext getCommandContext() {
return iCommandContext;
}

@Override
public TypedProperty getRequestProperties() {
return requestProperties;
}

}