WebSphere Commerce Version 7.0.0.3WebSphere Commerce Version 7.0.0.8WebSphere Commerce Version 7.0.0.6WebSphere Commerce Version 7.0.0.5WebSphere Commerce Version 7.0.0.7WebSphere Commerce Version 7.0.0.2WebSphere Commerce Version 7.0.0.1WebSphere Commerce Version 7.0.0.4

Troubleshooting: DuplicateKeyException occurs when you create an Extended sites store

When you create an Extended Sites store, creation can fail with the following DuplicateKeyException when the process tries to update the ShpModeDsc table.

WC_CONTRACT 3
    com.ibm.commerce.contract.commands.AddStoreNLDescriptionCmdImpl performExecute Found
    policy with properties: shippingMode=Mail&carrier=Mail 
CommerceSrvr E com.ibm.commerce.contract.commands.AddStoreNLDescriptionCmdImpl
    performExecute CMN0413E: The following create operation exception has occurred during
    processing: "{0}". javax.ejb.DuplicateKeyException at
    com.ibm.ejs.container.activator.OptCEntityActivationStrategy.atCreate
    (OptCEntityActivationStrategy.java:356) at
    com.ibm.ejs.container.activator.Activator.addBean(Activator.java:631) at
    com.ibm.ejs.container.EJSContainer.addBean(EJSContainer.java:2685) at
    com.ibm.ejs.container.EJSHome.postCreateCommon(EJSHome.java:2818) at
    com.ibm.ejs.container.EJSHome.postCreate(EJSHome.java:2705) at
    om.ibm.commerce.contract.objects.EJSCMPPolicyDescriptionHomeBean_bd251e9f.
    postCreateWrapperEJSCMPPolicyDescriptionHomeBean_bd251e9f.java:19) at
    com.ibm.commerce.contract.objects.EJSCMPPolicyDescriptionHomeBean_bd251e
    9f.create(EJSCMPPolicyDescriptionHomeBean_bd251e9f.java:39) at
    com.ibm.commerce.contract.objects.EJSRemoteCMPPolicyDescriptionHome_bd25
    1e9f.create(EJSRemoteCMPPolicyDescriptionHome_bd251e9f.java:30) at
    com.ibm.commerce.contract.objects._PolicyDescriptionHome_Stub.create
    (_PolicyDescriptionHome_Stub.java:80) at
    com.ibm.commerce.contract.objects.PolicyDescriptionAccessBean.<init>
    (PolicyDescriptionAccessBean.java:69) at
    com.ibm.commerce.contract.commands.AddStoreNLDescriptionCmdImpl.performExecute
    (AddStoreNLDescriptionCmdImpl.java:314) 

Problem

The DuplicateKeyException can occur if the same locale name is defined multiple times but with different LANGUAGE_ID values. You see in the logs that the ShpModeDsc table successfully updates for the first LOCALENAME, but fails during the attempt to update the table for the second LOCALENAME.

Solution

  1. Review your language table:
    1. Open a connection to your database.
    2. Run the following SQL statement,
      select * from language;
  2. Note the duplicate LOCALENAME entries. For example, you might have two LOCALENAME entries with en_US but different LANGUAGE_ID values.
    LANGUAGE_ID LOCALENAME LANGUAGE COUNTRY VARIANT ENCODING MIMECHARSET OPTCOUNTER
    -1 'en_US ' 'en ' 'US ' NULL 'UTF-8' 'iso-8859-1' 7
    9999 'en_US ' 'en ' 'US ' NULL 'UTF-8' 'iso-8859-1' 1
  3. Delete one of the duplicate localename entries. For example, to delete the entry with LANGUAGE_ID=9999, run the following SQL statement,
    delete from language where language_id = 9999;