7 Replies Latest reply on Nov 19, 2002 5:52 AM by Stefan Jurk

    OutOfMemoryError after 493 creates

    Stefan Jurk Newbie

      Hi!
      We just tried to insert 5000 Enities of "BelegPosition" into the Database using the BelegPositonEB Entity Bean.
      A BelegEB Entity Bean has many BelegPositonEB Beans (1:N Relation) realized with CMR(EJB2.0, JBoss 3.03 with integrated Tomcat, WinNT40, P3 1000, 512MB).
      JBoss stops with the following OutOfMemoryError after creating/inserting the exact Number of 493 BelegPositionEB's.
      What's our problem?
      What could be wrong with our JBoss configuration? I suppose JBoss can handle more than 493 Beans?
      I'm happy for every hint.
      Thanks
      Stefan


      11:36:57,291 ERROR [LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.EJBException: Unexpected Error
      java.lang.OutOfMemoryError

      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:205)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:203)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.ja
      va:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy85.addBelegPos(Unknown Source)
      at jbosstest.BelegSBBean.addNewPosition(BelegSBBean.java:99)
      at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionConta
      iner.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI
      nterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance
      Interceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:203)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:381)
      at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      11:36:57,341 ERROR [STDERR] javax.ejb.TransactionRolledbackLocalException: Unexpected Error
      java.lang.OutOfMemoryError
      ; CausedByException is:
      Unexpected Error
      java.lang.OutOfMemoryError
      11:36:57,351 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTx
      Interceptor.java:224)
      11:37:00,395 ERROR [LogInterceptor] Unexpected Error:
      java.lang.OutOfMemoryError


      Here are parts of the code:
      /** ----------- Client.java ----------------------------------------*/
      //Client that invokes the SessionBean:
      ...
      try{
      belegSB.loadBeleg(new Integer("12345"));
      logger.debug("loaded Beleg");
      for (int i=1;i<5000;i++)
      {
      logger.debug("------ Start new Belegposition -------------");
      belegSB.addNewPosition(new Integer("154446"),"Maschine",new Integer("123"));
      logger.debug("createt pos: " + i);
      logger.debug("------ End new Belegposition -------------");
      }
      }
      catch (Exception ex){
      ex.printStackTrace();
      }
      ...

      /** ----------- BelegSB.java (SessionBean) -------------------------*/
      public void addNewPosition(Integer artikelNr, String artikelBez, Integer artikelPreis) throws BelegException {
      ...

      belegEB.addBelegPos(artikelNr,artikelBez,artikelPreis);
      ...
      }

      /** ----------- BelegEB.java (EntityBean) -------------------------*/
      ...
      // CMR-Fields 1:N Relation (BelegEB:BelegPositionenEB)
      public abstract void setBelegPositionenEB(java.util.Collection belegPositionenEB);
      public abstract java.util.Collection getBelegPositionenEB();

      ...

      public void addBelegPos(Integer artikelNr, String artikelBez, Integer artikelPreis) {

      if(getBelegPositionenEB() == null) {

      setBelegPositionenEB(new ArrayList());
      }
      try {

      getBelegPositionenEB().add(belegPosEBHome.create(artikelNr,artikelBez,artikelPreis));

      }
      catch (CreateException ex) {
      logger.info("BelegEBBean : " + ex.getMessage());
      }

      }