I'm trying to get a huge amount or records from the db, I'm just getting the Ids from these objects to minimize the data read
while iterating the
scrollableContracts.next() result I'm getting, sometimes out of memory errors and sometimes (more often) session time out
errors:
11:50:28,484 WARN [TimeScheduler] task org.jgroups.protocols.pbcast.STABLE$StableTask@aa9567 took 47922ms to execute, please check why it is taking so long. It is delaying other tasks
11:50:45,734 INFO [STDOUT] 11687
11:50:51,734 INFO [STDOUT] 11688
11:50:55,953 INFO [STDOUT] 11689
11:51:20,687 ERROR [TimeScheduler] failed running task org.jgroups.protocols.pbcast.STABLE$StableTask@aa9567
java.lang.OutOfMemoryError: Java heap space
---------------------------------------------------------------------
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0xc10e4773, pid=9608, tid=5460
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
# Problematic frame:
# C 0xc10e4773
---------------------------------------------------------------------
12:07:48,750 ERROR [UDP] failed sending message
java.lang.OutOfMemoryError: Java heap space
12:07:48,750 ERROR [ContainerBase] Exception invoking periodic operation:
java.lang.OutOfMemoryError: Java heap space
12:07:49,750 WARN [DiskStore] py.com.wpg.coopy.crm.entity.security.UserGroupCache: Expiry thread throwable caught. Message was: Java heap space. Continuing...
java.lang.OutOfMemoryError: Java heap space
12:07:49,750 ERROR [UDP] failed unmarshalling message
java.lang.OutOfMemoryError: Java heap space
12:08:02,937 WARN [UpHandler] UpHandler (FD) caught exception
java.lang.NoClassDefFoundError: org/jgroups/stack/Retransmitter$Task
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:672)
at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:652)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:190)
at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:517)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.jgroups.stack.Retransmitter.add(Retransmitter.java:104)
at org.jgroups.stack.NakReceiverWindow.add(NakReceiverWindow.java:228)
at org.jgroups.protocols.pbcast.NAKACK.handleMessage(NAKACK.java:637)
at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:508)
at org.jgroups.stack.Protocol.receiveUpEvent(Protocol.java:488)
at org.jgroups.stack.Protocol.passUp(Protocol.java:538)
at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:119)
at org.jgroups.stack.Protocol.receiveUpEvent(Protocol.java:488)
at org.jgroups.stack.Protocol.passUp(Protocol.java:538)
at org.jgroups.protocols.FD.up(FD.java:274)
at org.jgroups.stack.UpHandler.run(Protocol.java:59)
12:08:02,937 WARN [TimeScheduler] task org.jgroups.protocols.pbcast.STABLE$StableTask@e21f5d took 11391ms to execute, please check why it is taking so long. It is delaying other tasks
12:08:35,328 ERROR [STDERR] Exception in thread "PingWaiter"
12:08:35,328 ERROR [STDERR] java.lang.OutOfMemoryError: Java heap space
12:08:36,218 ERROR [STDERR] Exception in thread "TimeScheduler.Thread"
12:08:36,218 ERROR [STDERR] java.lang.reflect.UndeclaredThrowableException
12:08:36,218 ERROR [STDERR] at org.apache.commons.logging.impl.Log4jProxy.log(Log4jProxy.java:296)
12:08:36,218 ERROR [STDERR] at org.apache.commons.logging.impl.Log4jProxy.error(Log4jProxy.java:270)
12:08:36,218 ERROR [STDERR] at org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:119)
12:08:37,156 ERROR [STDERR] at org.jgroups.util.TimeScheduler$Loop.run(TimeScheduler.java:144)
12:08:37,156 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
12:08:37,156 ERROR [STDERR] Caused by: java.lang.OutOfMemoryError: Java heap space
I'm running in the server-side, not in the client-side, so, where to fix the problem ?
this is the code:
Code:
List<String> activecontracts = new Vector<String>();
ScrollableResults scrollableContracts = ContractLookup.getLookup().getContracts(searchparameters);
int count = 0;
if(scrollableContracts!=null)
{
try
{
while(scrollableContracts.next())
{
count++;
System.out.println(count);// just to check the amount of records got before the error
Contract contract = (Contract) scrollableContracts.get(0);
if(contract.getState()!=null)
{
activecontracts.add(contract.getCode());
}
}
scrollableContracts.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
return activecontracts;
}
and this is the code fro the session criteria:
Code:
Session session = getSession();
Criteria crit = session.createCriteria(Contract.class);
if(activeOnly != null)
{
crit.add(Expression.or(Expression.isNull("endDate"),
Expression.or(Expression.leProperty("endDate", "startDate"),
Expression.gt("endDate", WPGCalendar.getToday()))));
}
if((contracttypes != null) && (!contracttypes.isEmpty()))
{
crit.add(Expression.in("type", contracttypes));
}
crit.setFetchSize(100);
crit.setFlushMode(FlushMode.AUTO);
return crit.scroll(ScrollMode.FORWARD_ONLY);//to optimize resources
[/b]