-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: ArrayStoreException on query
PostPosted: Mon Sep 19, 2005 2:13 pm 
Newbie

Joined: Tue Mar 01, 2005 1:27 pm
Posts: 4
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:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 11:44 am 
Newbie

Joined: Tue Mar 01, 2005 1:27 pm
Posts: 4
After 2 days of studying Hibernate code and java sdk code, this turned out to be a hardware problem -- probably memory. We reproduced it by merely creating a HashMap and adding entries in a loop.

Thanks to all who looked into it.


Top
 Profile  
 
 Post subject: Same problem
PostPosted: Thu Nov 17, 2005 2:31 pm 
Regular
Regular

Joined: Tue Nov 08, 2005 1:30 pm
Posts: 50
Can you send me the code.. coz i am getting the same problem// when i call the query.. I am stuck up here.. Your help will be appreciated with poins..
Thanks
nag


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 2:42 pm 
Newbie

Joined: Tue Mar 01, 2005 1:27 pm
Posts: 4
Here is the short java class that exercises lots (but probably not all) of the memory on a machine. A memory problem showed up as a dump with "SIGSEGV (0xb) at pc=0x105b56d0, pid=20879, tid=16387". If there are no memory problems, you will get the "Memory exhausted..." message. You can use the -Xmx flag to increase the amount of memory that will be exercised.

Code:
import java.util.*;

public class Test {

    public static void main(String[] args) throws Exception {
        try {
            HashMap map = new HashMap();
            long count = 0;
            while (true) {
                map.put(new Long(count), null);
                if ((count++ % 100000) == 0) {
                    System.err.print('.');
                }
            }
        } catch (OutOfMemoryError e) {
            System.err.println("Memory exhausted (test passed)");
        }
       
    }


}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.