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 differentLANGUAGE_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
- Review your language table:
- Open a connection to your database.
- Run the following SQL statement,
select * from language;
- Note the duplicate
LOCALENAME
entries. For example, you might have twoLOCALENAME
entries withen_US
but differentLANGUAGE_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 - 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;