ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771281] |
Wed, 23 August 2017 16:15 |
P Shetty Messages: 7 Registered: August 2017 |
Junior Member |
|
|
We migrated our code from Toplink 9.0. to Eclipselink 2.6.4. We are using a project configuration xml which has all the mappings and we have the corresponding Java objects for the mappings as well. We are not using EclipseLink JPA. We are using Java 7 with Websphere Application Server 8.5.5
After migrating the code, the application was tested in lower environments and all seemed okay, but in Production we keep getting ConcurrentModificationException. This has led to CPU time of the JVM going up. We did not see this happen with Toplink 9.0 and have not yet been able to reproduce this error in lower environments.
This happens while using ReadObjectQuery with QueryExpression. Please advise. I have been unable to find anything related to this online.
Let me know if you need any more details from me.
Exception :
[8/7/17 11:12:58:747 CDT] 0000035f SystemOut O [EL Warning]: 2017-08-07 11:12:58.746--UnitOfWork(-565105113)--java.util.ConcurrentModificationException
[8/7/17 11:12:58:747 CDT] 0000035f BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method
"getEnhancementInfoForOrderDetailLineItem" on bean "BeanId(TopLinkServicesHC#checks-hc-4.3.0.2.jar#HCCheckService, null)". Exception data:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:934)
at java.util.HashMap$ValueIterator.next(HashMap.java:962)
at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.getNextCacheKey(IdentityMapKeyEnumeration.java:58)
at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.hasMoreElements(IdentityMapKeyEnumeration.java:38)
at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.getFromIdentityMap(IdentityMapManager.java:872)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:527)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.checkCacheForObject(ExpressionQueryMechanism.java:961)
at org.eclipse.persistence.queries.ReadObjectQuery.checkEarlyReturnLocal(ReadObjectQuery.java:260)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:866)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:841)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:441)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1790)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getOne(EclipseLinkTransaction.java:861)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getOne(EclipseLinkTransaction.java:799)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getObject(EclipseLinkTransaction.java:778)
at com.harland.collective.eclipselink.database.AbstractDBManager.getObject(AbstractDBManager.java:575)
at com.harland.checks.server.bizservices.applicationcontrollers.AccessoryController.getAccessoryForCode(AccessoryController.java:1290)
at com.harland.checks.server.bizservices.applicationcontrollers.AccessoryController.getAccessoriesForCodes(AccessoryController.java:1261)
at com.harland.checks.server.EnhancementInfoBuilder.getEnhancementsForCodesNew(EnhancementInfoBuilder.java:472)
Code :
---------
AccessoryController.java :
-------------------------------
........
acc = (Accessory)dbMgr.getObject(
Accessory.class,
"accessoryItemCode",
catalogCode.toUpperCase());
.....
EclipseLinkTransaction.java:
--------------------------------------------
.....
public Object getOne(
Class objectClass,
String attributeName,
Object attributeValue)
throws IPDatabaseException
{
return getOne(
objectClass,
new QueryExpression[]
{
new QueryCompare(
attributeName,
QueryCompare.EQUAL,
attributeValue)
});
}
public Object getOne(Class objectClass, QueryExpression[] params)
throws IPDatabaseException
{
try
{
ReadObjectQuery query = new ReadObjectQuery();
query.setSelectionCriteria(getExpression(params));
query.setReferenceClass(objectClass);
query.checkCacheThenDatabase();
return getUow().executeQuery(query); ------- This is point in our code where eclipselink call triggers and we get a ConcurrentModification Exception
}
catch (DatabaseException exc)
{
throw new IPDatabaseException(exc.getMessage());
}
}
..........
|
|
|
|
|
|
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771721 is a reply to message #1771687] |
Tue, 29 August 2017 20:59 |
P Shetty Messages: 7 Registered: August 2017 |
Junior Member |
|
|
Thanks again for your response. Now, that you mentioned this about SHOULD_TRIGGER_INDIRECTION , I am wondering if all the relationships of Accessory.java will be triggered by doing this. My query is based on direct field value 'accessoryItemCode' in the Accessory object. Would using SHOULD_TRIGGER_INDIRECTION also trigger all the other relationships in Accessory.java and clone the entire Accessory object with all indirections resolved? Or it just makes a copy of the collection, but does not resolve other indirections since it is not required for 'accessoryItemCode=somevalue" query expression
Please advise.
This is what I have in my code -
IDBManager dbMgr = DBManagerFactory.getInstance().getDBManager();
acc = (Accessory)dbMgr.getObject(
Accessory.class,
"accessoryItemCode",
codeForSearch);
In Accessory.java , accessoryItemCode is a String , but it also has several other relationship objects which are one-many, one-one and there is also one of the many-many kind.
private String accessoryItemCode;
public Accessory()
{
accessoryListTypesHolder = new ValueHolder(new Vector());
accyComponentsHolder = new ValueHolder(new Vector());
defaultCatalogAssemblyHolder = new ValueHolder();
catalogAssembliesHolder = new ValueHolder(new Vector());
defaultFontHolder = new ValueHolder();
logoImageHolder = new ValueHolder();
apCheckFeatureHolder = new ValueHolder(new Vector());
accCompImageViewHolder = new ValueHolder(new Vector());
optionValuesHolder = new ValueHolder(new Vector());
}
public void setAccessoryItemCode(String code)
{
accessoryItemCode = code;
}
public String getAccessoryItemCode()
{
return accessoryItemCode;
}
Attaching the descriptor for the Accessory object.
<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
<class>com.harland.checks.server.businessobjects.product.Accessory</class>
<alias>Accessory</alias>
<primary-key>
<field table="p_accessory" name="accessory_id" xsi:type="column"/>
</primary-key>
<events xsi:type="event-policy"/>
<querying xsi:type="query-policy"/>
<attribute-mappings>
<attribute-mapping xsi:type="one-to-many-mapping">
<attribute-name>accCompImageViewHolder</attribute-name>
<read-only>true</read-only>
<get-method>getAccCompImageViewHolder</get-method>
<set-method>setAccCompImageViewHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.AccCompImageView</reference-class>
<target-foreign-key>
<field-reference>
<source-field table="hc_acc_compimg_view" name="accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</target-foreign-key>
<batch-reading>true</batch-reading>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>accessoryId</attribute-name>
<get-method>getAccessoryId</get-method>
<set-method>setAccessoryId</set-method>
<field table="p_accessory" name="accessory_id" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>accessoryItemCode</attribute-name>
<get-method>getAccessoryItemCode</get-method>
<set-method>setAccessoryItemCode</set-method>
<field table="p_accessory" name="hc_accessory_code" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>replacedAccessoryItemCode</attribute-name>
<get-method>getReplacedAccessoryItemCode</get-method>
<set-method>setReplacedAccessoryItemCode</set-method>
<field table="p_accessory" name="accessory_code" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-many-mapping">
<attribute-name>accessoryListTypesHolder</attribute-name>
<get-method>getAccessoryListTypesHolder</get-method>
<set-method>setAccessoryListTypesHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.AccessoryListTypeAccLink</reference-class>
<private-owned>true</private-owned>
<target-foreign-key>
<field-reference>
<source-field table="acclisttypeacc_lk" name="acc_uid" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</target-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>accessoryOptionDescription</attribute-name>
<get-method>getAccessoryOptionDescription</get-method>
<set-method>setAccessoryOptionDescription</set-method>
<field table="p_accessory" name="acc_option_desc" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>accessoryType</attribute-name>
<get-method>getAccessoryType</get-method>
<set-method>setAccessoryType</set-method>
<field table="p_accessory" name="accessory_type" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="many-to-many-mapping">
<attribute-name>accyComponentsHolder</attribute-name>
<read-only>true</read-only>
<get-method>getAccyComponentsHolder</get-method>
<set-method>setAccyComponentsHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.AbstractComponent</reference-class>
<relation-table>p_accessory_comp</relation-table>
<source-relation-foreign-key>
<field-reference>
<source-field table="p_accessory_comp" name="accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</source-relation-foreign-key>
<target-relation-foreign-key>
<field-reference>
<source-field table="p_accessory_comp" name="component_id" xsi:type="column"/>
<target-field table="p_component" name="component_id" xsi:type="column"/>
</field-reference>
</target-relation-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
<insert-query xsi:type="data-modify-query"/>
<delete-query xsi:type="data-modify-query"/>
<delete-all-query xsi:type="data-modify-query"/>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-many-mapping">
<attribute-name>apCheckFeatureHolder</attribute-name>
<get-method>getAPCheckFeatureHolder</get-method>
<set-method>setAPCheckFeatureHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.CheckFeature</reference-class>
<private-owned>true</private-owned>
<target-foreign-key>
<field-reference>
<source-field table="check_feature" name="accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</target-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-many-mapping">
<attribute-name>catalogAssembliesHolder</attribute-name>
<get-method>getCatalogAssembliesHolder</get-method>
<set-method>setCatalogAssembliesHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.CatalogAssembly</reference-class>
<target-foreign-key>
<field-reference>
<source-field table="p_catalog" name="accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</target-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>checkmarkAllowedStr</attribute-name>
<field table="p_accessory" name="checkmarkallowed" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-one-mapping">
<attribute-name>defaultCatalogAssemblyHolder</attribute-name>
<get-method>getDefaultCatalogAssemblyHolder</get-method>
<set-method>setDefaultCatalogAssemblyHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.CatalogAssembly</reference-class>
<foreign-key>
<field-reference>
<source-field table="p_accessory" name="catalog_id" xsi:type="column"/>
<target-field table="p_catalog" name="catalog_id" xsi:type="column"/>
</field-reference>
</foreign-key>
<foreign-key-fields>
<field table="p_accessory" name="catalog_id" xsi:type="column"/>
</foreign-key-fields>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-object-query"/>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-one-mapping">
<attribute-name>defaultFontHolder</attribute-name>
<get-method>getDefaultFontHolder</get-method>
<set-method>setDefaultFontHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.Accessory</reference-class>
<foreign-key>
<field-reference>
<source-field table="p_accessory" name="font_accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</foreign-key>
<foreign-key-fields>
<field table="p_accessory" name="font_accessory_id" xsi:type="column"/>
</foreign-key-fields>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-object-query"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>effectiveDate</attribute-name>
<get-method>getEffectiveDate</get-method>
<set-method>setEffectiveDate</set-method>
<field table="p_accessory" name="eff_dt" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>expirationDate</attribute-name>
<get-method>getExpirationDate</get-method>
<set-method>setExpirationDate</set-method>
<field table="p_accessory" name="exp_dt" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>initialAllowedStr</attribute-name>
<field table="p_accessory" name="initialallowed" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>licenseInfo</attribute-name>
<get-method>getLicenseInfo</get-method>
<set-method>setLicenseInfo</set-method>
<field table="p_accessory" name="lisc_info" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="one-to-one-mapping">
<attribute-name>logoImageHolder</attribute-name>
<get-method>getLogoImageHolder</get-method>
<set-method>setLogoImageHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.ImageReference</reference-class>
<foreign-key>
<field-reference>
<source-field table="p_accessory" name="logo_image_id" xsi:type="column"/>
<target-field table="p_image" name="image_id" xsi:type="column"/>
</field-reference>
</foreign-key>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-object-query"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>longDescription</attribute-name>
<get-method>getLongDescription</get-method>
<set-method>setLongDescription</set-method>
<field table="p_accessory" name="hc_long_desc" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>replacedLongDescription</attribute-name>
<get-method>getReplacedLongDescription</get-method>
<set-method>setReplacedLongDescription</set-method>
<field table="p_accessory" name="long_desc" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>miscInfo</attribute-name>
<get-method>getMiscInfo</get-method>
<set-method>setMiscInfo</set-method>
<field table="p_accessory" name="misc_info" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>monogramRequiredStr</attribute-name>
<field table="p_accessory" name="monogramrequired" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="many-to-many-mapping">
<attribute-name>optionValuesHolder</attribute-name>
<get-method>getOptionValuesHolder</get-method>
<set-method>setOptionValuesHolder</set-method>
<reference-class>com.harland.checks.server.businessobjects.product.AccessoryOptionValue</reference-class>
<relation-table>acc_option_val_lk</relation-table>
<source-relation-foreign-key>
<field-reference>
<source-field table="acc_option_val_lk" name="accessory_id" xsi:type="column"/>
<target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</field-reference>
</source-relation-foreign-key>
<target-relation-foreign-key>
<field-reference>
<source-field table="acc_option_val_lk" name="acc_option_val_id" xsi:type="column"/>
<target-field table="acc_option_value" name="uid" xsi:type="column"/>
</field-reference>
</target-relation-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>java.util.Vector</collection-type>
</container>
</selection-query>
<insert-query xsi:type="data-modify-query"/>
<delete-query xsi:type="data-modify-query"/>
<delete-all-query xsi:type="data-modify-query"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>shortDescription</attribute-name>
<get-method>getShortDescription</get-method>
<set-method>setShortDescription</set-method>
<field table="p_accessory" name="hc_short_desc" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>replacedShortDescription</attribute-name>
<get-method>getReplacedShortDescription</get-method>
<set-method>setReplacedShortDescription</set-method>
<field table="p_accessory" name="short_desc" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>supportedBinding</attribute-name>
<get-method>getSupportedBinding</get-method>
<set-method>setSupportedBinding</set-method>
<field table="p_accessory" name="supported_binding" xsi:type="column"/>
</attribute-mapping>
<attribute-mapping xsi:type="direct-mapping">
<attribute-name>teamNameRequiredStr</attribute-name>
<field table="p_accessory" name="teamnamerequired" xsi:type="column"/>
</attribute-mapping>
</attribute-mappings>
<descriptor-type>independent</descriptor-type>
<locking xsi:type="version-locking-policy">
<version-field table="p_accessory" name="lock_version" xsi:type="column"/>
</locking>
<sequencing>
<sequence-name>p_accessory</sequence-name>
<sequence-field table="p_accessory" name="accessory_id" xsi:type="column"/>
</sequencing>
<instantiation/>
<copying xsi:type="instantiation-copy-policy"/>
<change-policy xsi:type="deferred-detection-change-policy"/>
<tables>
<table name="p_accessory"/>
</tables>
</class-mapping-descriptor>
I also had another question :-
Can I catch the ConcurrentModificationException? Is it alright to do so and if so, how can I capture something useful in the catch section? Would something like session.getIdentityMapAccessor().printIdentityMap(Accessory.class) help ? I was wondering if that will affect performance even more.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03958 seconds