Hi,
I am getting an intermittent ArrayStoreException when running certain query. The exception occurs in HashMap.java. Looking at this code I don't understand how an ArrayStoreException can be thrown, unless the object itself is corrupted via threadsafe issues.
That it seems to happen when multiple requests are running concurrently is further evidence that it is a threadsafe issue. The requests each open their own Session.
The javadoc for PersistenceContext says that there should be a one-to-one correspondence between a SessionImpl and a PersistentContext. Is this always true?
Is there any other reason that I am getting this error?
Hibernate version:
3.0.5
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false">
<!-- typedefs to improve readability -->
<typedef class="com.twosigma.service.corecalendar.FinDateUserType"
name="findate"/>
<class name="com.twosigma.eventsds.api.v1.EventDTO"
table="event">
<composite-id>
<key-property name="tid" type="int" column="tid"/>
<key-property name="date" type="findate" column="event_date"/>
<key-property name="categoryId" type="int" column="event_category_id"/>
<key-property name="variableId" type="int" column="event_variable_id"/>
</composite-id>
<property name="value" column="event_variable_value" type="string"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false">
<!-- typedefs to improve readability -->
<typedef class="com.twosigma.service.corecalendar.FinDateUserType"
name="findate"/>
<class entity-name="com.twosigma.eventsds.api.v1.UniverseComponent"
table="universe_component">
<composite-id>
<key-property name="universeId" column="universe_id" type="integer"/>
<key-property name="tid" column="tid" type="integer"/>
<key-property name="beginDate" column="begin_date" type="findate"/>
</composite-id>
<property name="endDate" column="end_date" type="findate"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session session = null;
Transaction txn = null;
try {
session = SessionFactoryProvider.getSessionFactory(this, context).openSession();
txn = session.beginTransaction();
final List events = session.createQuery(
" FROM com.twosigma.eventsds.api.v1.EventDTO e " +
" WHERE e.categoryId = :cat_id " +
" AND e.date >= :begin_date " +
" AND e.date < :end_date " +
" AND EXISTS( FROM com.twosigma.eventsds.api.v1.UniverseComponent uc " +
" WHERE uc.universeId = :universe_id " +
" AND uc.tid = e.tid) ")
.setInteger("cat_id", categoryId)
.setParameter("begin_date", begin, FinDateUserType.TYPE)
.setParameter("end_date", end, FinDateUserType.TYPE)
.setInteger("universe_id", universeId)
.list();
txn.commit();
return events;
} catch(HibernateException he) {
throw new DBException("getEvents DBContext: " + context +
" universeId: " + universeId + " categoryId: " + categoryId +
" begin: " + begin + " end: " + end, he);
} finally {
HibernateUtil.cleanup(txn, session);
}
Full stack trace of any exception that occurs:
java.lang.ArrayStoreException
at java.util.HashMap.transfer(HashMap.java:474)
at java.util.HashMap.resize(HashMap.java:455)
at java.util.HashMap.addEntry(HashMap.java:745)
at java.util.HashMap.put(HashMap.java:395)
at org.apache.commons.collections.SequencedHashMap.put(SequencedHashMap.java:446)
at org.hibernate.util.IdentityMap.put(IdentityMap.java:137)
at org.hibernate.engine.PersistenceContext.addEntry(PersistenceContext.java:454)
at org.hibernate.engine.PersistenceContext.addEntity(PersistenceContext.java:414)
at org.hibernate.engine.TwoPhaseLoad.addUninitializedEntity(TwoPhaseLoad.java:192)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:984)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:942)
at org.hibernate.loader.Loader.getRow(Loader.java:855)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:305)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.twosigma.eventsds.impl.v1.EventServiceImpl.getEvents(EventServiceImpl.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.twosigma.rest.RestMethod.invokeLocal(RestMethod.java:155)
at com.twosigma.rest.RestServiceBridge.handle(RestServiceBridge.java:127)
at com.twosigma.rest.RestServer.handle(RestServer.java:221)
at com.twosigma.rest.RestServer.handleAndLog(RestServer.java:185)
at com.twosigma.rest.RestServer.access$000(RestServer.java:58)
at com.twosigma.rest.RestServer$Handler.handle(RestServer.java:81)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1563)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1515)
at org.mortbay.http.HttpServer.service(HttpServer.java:956)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Name and version of the database you are using:
SQL Server 2000
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: