You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Alexandru Popescu <th...@gmail.com> on 2006/02/04 12:01:03 UTC

OutOfMemory while running tests

Hi!

I have a set of tests (more or less unit tests). Considering that I want to be able to run some of 
them individually or all of them I have each TestCase returning a RepositoryLifecycleTestSetup (that 
is registering/unregistering the test repository).

[code]
public class MyTestClass extends TestCase {
	public static Test suite() {
		return new RepositoryLifecycleTestSetup(new TestSuite(MyTestClass.class));
	}

	[...]
}
[/code]

[code]
package org.apache.portals.graffito.jcr;

import org.apache.portals.graffito.jcr.repository.RepositoryUtil;

import junit.extensions.TestSetup;
import junit.framework.Test;


/**
  * This class/interface
  */
public class RepositoryLifecycleTestSetup extends TestSetup {
     public RepositoryLifecycleTestSetup(Test test) {
         super(test);
     }

     /**
      * @see junit.extensions.TestSetup#setUp()
      */
     protected void setUp() throws Exception {
         super.setUp();
         RepositoryUtil.registerRepository("repositoryTest",
                 "./src/test-config/repository-derby.xml", "./target/repository");
     }

     /**
      * @see junit.extensions.TestSetup#tearDown()
      */
     protected void tearDown() throws Exception {
         RepositoryUtil.unRegisterRepository("repositoryTest");
         super.tearDown();
     }


}
[/code]

While running test by test this works as expected, when trying to run all tests in the package I hit 
quite soon an OutOfMemory problem:

[stacktrace]
javax.jcr.RepositoryException: failed to write node state: 86d66b84-96c3-434c-bf0c-5bd7630cb254: 
Java exception: 'Java heap space: java.lang.OutOfMemoryError'.: failed to write node state: 
86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
	at 
org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:273)
	at 
org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193)
	at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736)
	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150)
	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758)
	at 
org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894)
	at 
org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112)
	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 junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.extensions.TestSetup.run(TestSetup.java:23)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: 
86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592)
	at 
org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78)
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446)
	at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306)
	at 
org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266)
	... 25 more
Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585)
	... 31 more
org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: 
86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592)
	at 
org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78)
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446)
	at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306)
	at 
org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266)
	at 
org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193)
	at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736)
	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150)
	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758)
	at 
org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894)
	at 
org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112)
	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 junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.extensions.TestSetup.run(TestSetup.java:23)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
	at 
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585)
	... 31 more
java.lang.OutOfMemoryError: Java heap space
[/stacktrace]

Now my question is: am I doing something stupid with these tests or is it what I imagine it can be 
(derby is not able to handle anymore connections).

thanks in advance,

./alex
--
.w( the_mindstorm )p.

Re: OutOfMemory while running tests

Posted by Alexandru Popescu <th...@gmail.com>.
#: Marcel Reutegger changed the world a bit at a time by saying (astral date: 2/6/2006 10:48 AM) :#
> Please check if the repository is really stopped after each test case. 
> What exactly happens in your utility method 
> RepositoryUtil.unRegisterRepository?
> 
> Using the jackrabbit default log4j settings you should also see log 
> messages about repository start and stop in the jcr.log file.
> 
> regards
>   marcel
>

The RepositoryUtil just delegates to RegistryHelper.unregisterRepository(ctx, repositoryName), so I 
would expect that the repository should be closed.

What should I do enable log4j? Please give me some hints so that we can further clarify the problem.

tia,

./alex
--
.w( the_mindstorm )p.


> Alexandru Popescu wrote:
>> Hi!
>> 
>> I have a set of tests (more or less unit tests). Considering that I want 
>> to be able to run some of them individually or all of them I have each 
>> TestCase returning a RepositoryLifecycleTestSetup (that is 
>> registering/unregistering the test repository).
>> 
>> [code]
>> public class MyTestClass extends TestCase {
>>     public static Test suite() {
>>         return new RepositoryLifecycleTestSetup(new 
>> TestSuite(MyTestClass.class));
>>     }
>> 
>>     [...]
>> }
>> [/code]
>> 
>> [code]
>> package org.apache.portals.graffito.jcr;
>> 
>> import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
>> 
>> import junit.extensions.TestSetup;
>> import junit.framework.Test;
>> 
>> 
>> /**
>>  * This class/interface
>>  */
>> public class RepositoryLifecycleTestSetup extends TestSetup {
>>     public RepositoryLifecycleTestSetup(Test test) {
>>         super(test);
>>     }
>> 
>>     /**
>>      * @see junit.extensions.TestSetup#setUp()
>>      */
>>     protected void setUp() throws Exception {
>>         super.setUp();
>>         RepositoryUtil.registerRepository("repositoryTest",
>>                 "./src/test-config/repository-derby.xml", 
>> "./target/repository");
>>     }
>> 
>>     /**
>>      * @see junit.extensions.TestSetup#tearDown()
>>      */
>>     protected void tearDown() throws Exception {
>>         RepositoryUtil.unRegisterRepository("repositoryTest");
>>         super.tearDown();
>>     }
>> 
>> 
>> }
>> [/code]
>> 
> 
> 


Re: OutOfMemory while running tests

Posted by Marcel Reutegger <ma...@gmx.net>.
well, you call it tweaking, I call it ensuring your test environment is 
set up properly ;)

e.g. jackrabbit unit tests run with a max heap of 128m

if you want to dive into all the dirty details there are several java 
profiler tools that allow you to see the live objects in a jvm...

regards
  marcel

Alexandru Popescu wrote:
> #: Marcel Reutegger changed the world a bit at a time by saying (astral 
> date: 2/6/2006 12:13 PM) :#
>> according to your logs shutdown seems to work fine.
>>
>> did you try to simply increase the heap space for the jvm? maybe your 
>> settings are just to low for the test cases you are running...
>>
>> regards
>>   marcel
>>
> 
> Instead of tweaking the JVM (I would like to consider this the last 
> solution), I would like to find out if I can organize somehow else the 
> tests so that the problem doesn't show.
> 
> ./alex
> -- 
> .w( the_mindstorm )p.
> 


Re: OutOfMemory while running tests

Posted by Alexandru Popescu <th...@gmail.com>.
#: Marcel Reutegger changed the world a bit at a time by saying (astral date: 2/6/2006 12:13 PM) :#
> according to your logs shutdown seems to work fine.
> 
> did you try to simply increase the heap space for the jvm? maybe your 
> settings are just to low for the test cases you are running...
> 
> regards
>   marcel
>

Instead of tweaking the JVM (I would like to consider this the last solution), I would like to find 
out if I can organize somehow else the tests so that the problem doesn't show.

./alex
--
.w( the_mindstorm )p.


> Alexandru Popescu wrote:
>> After each call to RegistryHelper.unregisterRepository(ctx, 
>> repositoryName) I can see in the console:
>> 
>> [log]
>> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
>> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
>> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
>> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
>>  INFO: Notification of EventListeners stopped.
>>  INFO: Notification of EventListeners stopped.
>> DEBUG: dispose IndexMerger
>> DEBUG: dispose IndexMerger
>>  INFO: IndexMerger terminated
>>  INFO: IndexMerger terminated
>> DEBUG: quit sent
>> DEBUG: quit sent
>> DEBUG: IndexMerger thread stopped
>> DEBUG: IndexMerger thread stopped
>> DEBUG: merge queue size: 0
>> DEBUG: merge queue size: 0
>>  INFO: Index closed: .\target\repository\workspaces\default/index
>>  INFO: Index closed: .\target\repository\workspaces\default/index
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.SearchManager@610a39
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.SearchManager@610a39
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.RepositoryImpl@99d1df
>> DEBUG: removing EventListener: 
>> org.apache.jackrabbit.core.RepositoryImpl@99d1df
>>  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>>  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>>  INFO: Database './target/repository/version/db' shutdown.
>>  INFO: Database './target/repository/version/db' shutdown.
>> [/log]
>> 
>> so I would say that the close operation is correctly triggered and even 
>> better it works as expected. Still, the exception occurs.
>> 
>> I would say that it looks like a problem on Derby releasing the 
>> resources, but I would like to be sure that this has nothing to do with 
>> SimpleDbPersistenceManager.
> 
> 


Re: OutOfMemory while running tests

Posted by Marcel Reutegger <ma...@gmx.net>.
according to your logs shutdown seems to work fine.

did you try to simply increase the heap space for the jvm? maybe your 
settings are just to low for the test cases you are running...

regards
  marcel

Alexandru Popescu wrote:
> After each call to RegistryHelper.unregisterRepository(ctx, 
> repositoryName) I can see in the console:
> 
> [log]
> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
>  INFO: Notification of EventListeners stopped.
>  INFO: Notification of EventListeners stopped.
> DEBUG: dispose IndexMerger
> DEBUG: dispose IndexMerger
>  INFO: IndexMerger terminated
>  INFO: IndexMerger terminated
> DEBUG: quit sent
> DEBUG: quit sent
> DEBUG: IndexMerger thread stopped
> DEBUG: IndexMerger thread stopped
> DEBUG: merge queue size: 0
> DEBUG: merge queue size: 0
>  INFO: Index closed: .\target\repository\workspaces\default/index
>  INFO: Index closed: .\target\repository\workspaces\default/index
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.SearchManager@610a39
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.SearchManager@610a39
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.RepositoryImpl@99d1df
> DEBUG: removing EventListener: 
> org.apache.jackrabbit.core.RepositoryImpl@99d1df
>  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>  INFO: Database './target/repository/version/db' shutdown.
>  INFO: Database './target/repository/version/db' shutdown.
> [/log]
> 
> so I would say that the close operation is correctly triggered and even 
> better it works as expected. Still, the exception occurs.
> 
> I would say that it looks like a problem on Derby releasing the 
> resources, but I would like to be sure that this has nothing to do with 
> SimpleDbPersistenceManager.


Re: OutOfMemory while running tests

Posted by Alexandru Popescu <th...@gmail.com>.
#: Alexandru Popescu changed the world a bit at a time by saying (astral date: 2/6/2006 11:34 AM) :#
> #: Marcel Reutegger changed the world a bit at a time by saying (astral date: 2/6/2006 10:48 AM) :#
>> Please check if the repository is really stopped after each test case. 
>> What exactly happens in your utility method 
>> RepositoryUtil.unRegisterRepository?
>> 
>> Using the jackrabbit default log4j settings you should also see log 
>> messages about repository start and stop in the jcr.log file.
>> 
>> regards
>>   marcel
>> 
>> Alexandru Popescu wrote:
>>> Hi!
>>> 
>>> I have a set of tests (more or less unit tests). Considering that I want 
>>> to be able to run some of them individually or all of them I have each 
>>> TestCase returning a RepositoryLifecycleTestSetup (that is 
>>> registering/unregistering the test repository).
>>> 
>>> [code]
>>> public class MyTestClass extends TestCase {
>>>     public static Test suite() {
>>>         return new RepositoryLifecycleTestSetup(new 
>>> TestSuite(MyTestClass.class));
>>>     }
>>> 
>>>     [...]
>>> }
>>> [/code]
>>> 
>>> [code]
>>> package org.apache.portals.graffito.jcr;
>>> 
>>> import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
>>> 
>>> import junit.extensions.TestSetup;
>>> import junit.framework.Test;
>>> 
>>> 
>>> /**
>>>  * This class/interface
>>>  */
>>> public class RepositoryLifecycleTestSetup extends TestSetup {
>>>     public RepositoryLifecycleTestSetup(Test test) {
>>>         super(test);
>>>     }
>>> 
>>>     /**
>>>      * @see junit.extensions.TestSetup#setUp()
>>>      */
>>>     protected void setUp() throws Exception {
>>>         super.setUp();
>>>         RepositoryUtil.registerRepository("repositoryTest",
>>>                 "./src/test-config/repository-derby.xml", 
>>> "./target/repository");
>>>     }
>>> 
>>>     /**
>>>      * @see junit.extensions.TestSetup#tearDown()
>>>      */
>>>     protected void tearDown() throws Exception {
>>>         RepositoryUtil.unRegisterRepository("repositoryTest");
>>>         super.tearDown();
>>>     }
>>> 
>>> 
>>> }
>>> [/code]
>>> 
>> 
>> 
> 
> Considering the previous answer, can I conclude that I am not doing something wrong in my tests 
> ain't it?
> 
> After each call to RegistryHelper.unregisterRepository(ctx, repositoryName) I can see in the console:
> 
> [log]
> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
> DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
> DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
>   INFO: Notification of EventListeners stopped.
>   INFO: Notification of EventListeners stopped.
> DEBUG: dispose IndexMerger
> DEBUG: dispose IndexMerger
>   INFO: IndexMerger terminated
>   INFO: IndexMerger terminated
> DEBUG: quit sent
> DEBUG: quit sent
> DEBUG: IndexMerger thread stopped
> DEBUG: IndexMerger thread stopped
> DEBUG: merge queue size: 0
> DEBUG: merge queue size: 0
>   INFO: Index closed: .\target\repository\workspaces\default/index
>   INFO: Index closed: .\target\repository\workspaces\default/index
> DEBUG: removing EventListener: org.apache.jackrabbit.core.SearchManager@610a39
> DEBUG: removing EventListener: org.apache.jackrabbit.core.SearchManager@610a39
> DEBUG: removing EventListener: org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
> DEBUG: removing EventListener: org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
> DEBUG: removing EventListener: org.apache.jackrabbit.core.RepositoryImpl@99d1df
> DEBUG: removing EventListener: org.apache.jackrabbit.core.RepositoryImpl@99d1df
>   INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>   INFO: Database '.\target\repository\workspaces\default/db' shutdown.
>   INFO: Database './target/repository/version/db' shutdown.
>   INFO: Database './target/repository/version/db' shutdown.
> [/log]
> 
> so I would say that the close operation is correctly triggered and even better it works as expected. 
> Still, the exception occurs.
> 
> I would say that it looks like a problem on Derby releasing the resources, but I would like to be 
> sure that this has nothing to do with SimpleDbPersistenceManager.
> 
> Please advise.
> 
> ./alex
> --
> .w( the_mindstorm )p.
> 

It looks like there is an exception from Derby with state code: ERROR 08006
The following should help http://db.apache.org/derby/docs/10.1/ref/rrefexcept71493.html, but 
unfortunately the message is completely unusefull.

Do you have any ideas about how to write/organize the tests so that I can go on and not face this 
error again?

tia,

./alex
--
.w( the_mindstorm )p.


Re: OutOfMemory while running tests

Posted by Alexandru Popescu <th...@gmail.com>.
#: Marcel Reutegger changed the world a bit at a time by saying (astral date: 2/6/2006 10:48 AM) :#
> Please check if the repository is really stopped after each test case. 
> What exactly happens in your utility method 
> RepositoryUtil.unRegisterRepository?
> 
> Using the jackrabbit default log4j settings you should also see log 
> messages about repository start and stop in the jcr.log file.
> 
> regards
>   marcel
> 
> Alexandru Popescu wrote:
>> Hi!
>> 
>> I have a set of tests (more or less unit tests). Considering that I want 
>> to be able to run some of them individually or all of them I have each 
>> TestCase returning a RepositoryLifecycleTestSetup (that is 
>> registering/unregistering the test repository).
>> 
>> [code]
>> public class MyTestClass extends TestCase {
>>     public static Test suite() {
>>         return new RepositoryLifecycleTestSetup(new 
>> TestSuite(MyTestClass.class));
>>     }
>> 
>>     [...]
>> }
>> [/code]
>> 
>> [code]
>> package org.apache.portals.graffito.jcr;
>> 
>> import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
>> 
>> import junit.extensions.TestSetup;
>> import junit.framework.Test;
>> 
>> 
>> /**
>>  * This class/interface
>>  */
>> public class RepositoryLifecycleTestSetup extends TestSetup {
>>     public RepositoryLifecycleTestSetup(Test test) {
>>         super(test);
>>     }
>> 
>>     /**
>>      * @see junit.extensions.TestSetup#setUp()
>>      */
>>     protected void setUp() throws Exception {
>>         super.setUp();
>>         RepositoryUtil.registerRepository("repositoryTest",
>>                 "./src/test-config/repository-derby.xml", 
>> "./target/repository");
>>     }
>> 
>>     /**
>>      * @see junit.extensions.TestSetup#tearDown()
>>      */
>>     protected void tearDown() throws Exception {
>>         RepositoryUtil.unRegisterRepository("repositoryTest");
>>         super.tearDown();
>>     }
>> 
>> 
>> }
>> [/code]
>> 
> 
> 

Considering the previous answer, can I conclude that I am not doing something wrong in my tests 
ain't it?

After each call to RegistryHelper.unregisterRepository(ctx, repositoryName) I can see in the console:

[log]
DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
DEBUG: invalidated item cafebabe-cafe-babe-cafe-babecafebabe
DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
DEBUG: removing item cafebabe-cafe-babe-cafe-babecafebabe from cache
  INFO: Notification of EventListeners stopped.
  INFO: Notification of EventListeners stopped.
DEBUG: dispose IndexMerger
DEBUG: dispose IndexMerger
  INFO: IndexMerger terminated
  INFO: IndexMerger terminated
DEBUG: quit sent
DEBUG: quit sent
DEBUG: IndexMerger thread stopped
DEBUG: IndexMerger thread stopped
DEBUG: merge queue size: 0
DEBUG: merge queue size: 0
  INFO: Index closed: .\target\repository\workspaces\default/index
  INFO: Index closed: .\target\repository\workspaces\default/index
DEBUG: removing EventListener: org.apache.jackrabbit.core.SearchManager@610a39
DEBUG: removing EventListener: org.apache.jackrabbit.core.SearchManager@610a39
DEBUG: removing EventListener: org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
DEBUG: removing EventListener: org.apache.jackrabbit.core.lock.LockManagerImpl@112f348
DEBUG: removing EventListener: org.apache.jackrabbit.core.RepositoryImpl@99d1df
DEBUG: removing EventListener: org.apache.jackrabbit.core.RepositoryImpl@99d1df
  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
  INFO: Database '.\target\repository\workspaces\default/db' shutdown.
  INFO: Database './target/repository/version/db' shutdown.
  INFO: Database './target/repository/version/db' shutdown.
[/log]

so I would say that the close operation is correctly triggered and even better it works as expected. 
Still, the exception occurs.

I would say that it looks like a problem on Derby releasing the resources, but I would like to be 
sure that this has nothing to do with SimpleDbPersistenceManager.

Please advise.

./alex
--
.w( the_mindstorm )p.

Re: OutOfMemory while running tests

Posted by Marcel Reutegger <ma...@gmx.net>.
Please check if the repository is really stopped after each test case. 
What exactly happens in your utility method 
RepositoryUtil.unRegisterRepository?

Using the jackrabbit default log4j settings you should also see log 
messages about repository start and stop in the jcr.log file.

regards
  marcel

Alexandru Popescu wrote:
> Hi!
> 
> I have a set of tests (more or less unit tests). Considering that I want 
> to be able to run some of them individually or all of them I have each 
> TestCase returning a RepositoryLifecycleTestSetup (that is 
> registering/unregistering the test repository).
> 
> [code]
> public class MyTestClass extends TestCase {
>     public static Test suite() {
>         return new RepositoryLifecycleTestSetup(new 
> TestSuite(MyTestClass.class));
>     }
> 
>     [...]
> }
> [/code]
> 
> [code]
> package org.apache.portals.graffito.jcr;
> 
> import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
> 
> import junit.extensions.TestSetup;
> import junit.framework.Test;
> 
> 
> /**
>  * This class/interface
>  */
> public class RepositoryLifecycleTestSetup extends TestSetup {
>     public RepositoryLifecycleTestSetup(Test test) {
>         super(test);
>     }
> 
>     /**
>      * @see junit.extensions.TestSetup#setUp()
>      */
>     protected void setUp() throws Exception {
>         super.setUp();
>         RepositoryUtil.registerRepository("repositoryTest",
>                 "./src/test-config/repository-derby.xml", 
> "./target/repository");
>     }
> 
>     /**
>      * @see junit.extensions.TestSetup#tearDown()
>      */
>     protected void tearDown() throws Exception {
>         RepositoryUtil.unRegisterRepository("repositoryTest");
>         super.tearDown();
>     }
> 
> 
> }
> [/code]
> 


Re: OutOfMemory while running tests

Posted by Alexandru Popescu <th...@gmail.com>.
#: Alexandru Popescu changed the world a bit at a time by saying (astral date: 2/4/2006 1:01 PM) :#
> Hi!
> 
> I have a set of tests (more or less unit tests). Considering that I want to be able to run some of 
> them individually or all of them I have each TestCase returning a RepositoryLifecycleTestSetup (that 
> is registering/unregistering the test repository).
> 
> [code]
> public class MyTestClass extends TestCase {
> 	public static Test suite() {
> 		return new RepositoryLifecycleTestSetup(new TestSuite(MyTestClass.class));
> 	}
> 
> 	[...]
> }
> [/code]
> 
> [code]
> package org.apache.portals.graffito.jcr;
> 
> import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
> 
> import junit.extensions.TestSetup;
> import junit.framework.Test;
> 
> 
> /**
>   * This class/interface
>   */
> public class RepositoryLifecycleTestSetup extends TestSetup {
>      public RepositoryLifecycleTestSetup(Test test) {
>          super(test);
>      }
> 
>      /**
>       * @see junit.extensions.TestSetup#setUp()
>       */
>      protected void setUp() throws Exception {
>          super.setUp();
>          RepositoryUtil.registerRepository("repositoryTest",
>                  "./src/test-config/repository-derby.xml", "./target/repository");
>      }
> 
>      /**
>       * @see junit.extensions.TestSetup#tearDown()
>       */
>      protected void tearDown() throws Exception {
>          RepositoryUtil.unRegisterRepository("repositoryTest");
>          super.tearDown();
>      }
> 
> 
> }
> [/code]
> 
> While running test by test this works as expected, when trying to run all tests in the package I hit 
> quite soon an OutOfMemory problem:
> 
> [stacktrace]
> javax.jcr.RepositoryException: failed to write node state: 86d66b84-96c3-434c-bf0c-5bd7630cb254: 
> Java exception: 'Java heap space: java.lang.OutOfMemoryError'.: failed to write node state: 
> 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
> 	at 
> org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:273)
> 	at 
> org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193)
> 	at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736)
> 	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150)
> 	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758)
> 	at 
> org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894)
> 	at 
> org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112)
> 	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 junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: 
> 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592)
> 	at 
> org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78)
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446)
> 	at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514)
> 	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344)
> 	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306)
> 	at 
> org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266)
> 	... 25 more
> Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585)
> 	... 31 more
> org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: 
> 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592)
> 	at 
> org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78)
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446)
> 	at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514)
> 	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344)
> 	at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306)
> 	at 
> org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266)
> 	at 
> org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193)
> 	at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736)
> 	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150)
> 	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758)
> 	at 
> org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894)
> 	at 
> org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112)
> 	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 junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'.
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
> 	at 
> org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585)
> 	... 31 more
> java.lang.OutOfMemoryError: Java heap space
> [/stacktrace]
> 
> Now my question is: am I doing something stupid with these tests or is it what I imagine it can be 
> (derby is not able to handle anymore connections).
> 
> thanks in advance,
> 
> ./alex
> --
> .w( the_mindstorm )p.
> 

Some more details about this: the jackrabbit version against which the tests are run is: r367360. 
Between that moment and the current head there where no changes to the SimpleDbPersistenceManager.

Another very interesting result is that if I switch the PersistenceManager to BerkleyDb I am not 
hitting this problem, so I start to think that my assumption about SimpleDbPersistenceManager is true.

thanks in advance for any comments, ideas, suggestions,

./alex
--
.w( the_mindstorm )p.