3 Replies Latest reply on Sep 8, 2003 7:16 AM by Ecka Kjellberg

    OutOfMemoryError

    Ecka Kjellberg Newbie

      I have a bidirectional CMR relation (a tree with folders and objects). One of the folders contains 1 million objects (inserted directly to the DB). But when I'm using the EJB I get OutOfMemoryError.

      2003-09-05 10:15:45,984 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.EJBException: Unexpected Error
      java.lang.OutOfMemoryError

      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:182)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
      at org.jboss.ejb.Container.invoke(Container.java:674)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy125.addChild(Unknown Source)
      at se.teligent.tsp.tree.ejb.TreeFacadeBean.addChildToNode(TreeFacadeBean.java:66)


      The last log before the stacktrace is from JDBCLoadRelationCommand "Executing SQL:".

      I checked exactly what the SQL was and it would find 1000104 rows. And the object I was trying to insert was not even in the folder that contained the 1 million other objects (but .

      The SQL log was

      1. INSERT INTO tree (id, parent) VALUES (10001001103, null)
      2. SELECT parent, id FROM tree WHERE (parent=10000000002) OR (parent=10000000003) OR (parent=10000000004) OR (parent=10000000005) OR (parent=10000000006) OR (parent=10000000007)

      And the database looks like
      +-------------+-------------+
      | id | parent |
      +-------------+-------------+
      | 10000000001 | NULL |
      | 10000000002 | 10000000001 |
      | 10000000003 | 10000000001 |
      | 10000000004 | 10000000001 |
      | 10000000005 | 10000000001 |
      | 10000000006 | 10000000001 |
      | 10000000007 | 10000000001 |
      | 10000000011 | 10000000002 |
      | 10000000014 | 10000000007 |
      | 10000001000 | 10000000004 |
      | 10000001001 | 10000000003 |
      | 10000001002 | 10000000003 |
      | 10000001003 | 10000000003 |
      | 10000001004 | 10000000003 |
      | ...
      +-------------+-------------+

      My question would be:
      1. Why does JBoss search for all those objects?
      2. If I'm trying to insert a new object to the parent containing the 1 million objects - how can achieve that without searching for all its siblings?

        • 1. Re: OutOfMemoryError
          Ecka Kjellberg Newbie

          I realize that I must be more specific.
          I got OutOfMemoryError when I try to insert a new object into a folder

          • 2. Re: OutOfMemoryError
            Ecka Kjellberg Newbie

            I tried to increase the memory (-Xms256m -Xmx1024m) and I got another error.
            It took some time so I expect that it was some database read timeout.


            2003-09-05 14:54:35,578 ERROR [STDERR] PoolThread-9 write 140 2003-sep-05 14:54:35 org.apache.struts.action.RequestProcessor process
            INFO: Processing a 'POST' for path '/adminuser'
            2003-09-05 15:01:48,156 WARN [TransactionImpl] Thread-70 timedOut 228 Transaction TransactionImpl:XidImpl [FormatId=257, GlobalId=seeckj//131, BranchQual=] timed out. status=STATUS_ACTIVE
            2003-09-05 15:01:53,796 ERROR [LogInterceptor] PoolThread-9 handleException 290 TransactionRolledbackLocalException, causedBy:
            java.lang.IllegalStateException: A CMR collection may only be used within the transction in which it was created
            at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.getIdList(RelationSet.java:61)
            at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.add(RelationSet.java:90)
            at se.teligent.tsp.tree.ejb.TreeNodeBean.addChild(TreeNodeBean.java:114)
            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:324)
            at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1044)
            at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
            at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:301)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
            at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:82)
            at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
            at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
            at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
            at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
            at org.jboss.ejb.Container.invoke(Container.java:674)
            at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
            at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
            at $Proxy117.addChild(Unknown Source)
            at se.teligent.tsp.tree.ejb.TreeFacadeBean.addChildToNode(TreeFacadeBean.java:66)
            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:324)
            at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
            at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
            at org.jboss.ejb.Container.invoke(Container.java:674)
            at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            • 3. Re: OutOfMemoryError
              Ecka Kjellberg Newbie

              It is not my intention to fill this forum with strange replies but I only wanted to inform anyone reading this that I 'solved' my problem. I replaced the CMP-relationship btw the parent and its children with a "findChildren" method in the home interface but I kept the relation btw the child and its parent.