title: Spring : Illegal access: this web application instance has been stopped already
body: <p>I am working on a Spring-MVC application in which I am computing the statistics every night. The problem is, yesterdays computation failed and I have this error and an hs_err_something.log file. The file basically says Out of memory error, but our servers have 32GB ram and quite lot of disk space too. Also, the server is kind of relaxed in night. Why I am I getting this error. I will post contents of relevant code. </p>
  
  <p>StatisticsServiceImpl :</p>
  
  <pre><code> @Override
          @Scheduled(cron = "0 2 2 * * ?")
          public void computeStatisticsForAllUsers() {
  // One of the count as part of statistics
                  int groupNotesCount = this.groupNotesService.getNoteCountForUser(person.getUsername());
      }
  </code></pre>
  
  <p>GroupNotesDAOImpl :</p>
  
  <pre><code> @Override
      public int getNoteCountForUser(String noteCreatorEmail) {
          Session session = this.sessionFactory.getCurrentSession();
          Query query = session.createQuery("select count(*) from GroupNotes as gn where gn.noteCreatorEmail=:noteCreatorEmail");
          query.setParameter("noteCreatorEmail", noteCreatorEmail);
          return new Integer(String.valueOf(query.uniqueResult()));
  
      }
  </code></pre>
  
  <p>Error log :</p>
  
  <pre><code>Aug 05, 2015 2:02:02 AM org.apache.catalina.loader.WebappClassLoader loadClass
  INFO: Illegal access: this web application instance has been stopped already.  Could not load gn.  The eventual following stack trace is cause
  d by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no function
  al impact.
  java.lang.IllegalStateException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
          at com.journaldev.spring.dao.GroupNotesDAOImpl.getNoteCountForUser(GroupNotesDAOImpl.java:359)
  </code></pre>
  
  <p>hs_err.log file :</p>
  
  <pre><code>#
  # There is insufficient memory for the Java Runtime Environment to continue.
  # Native memory allocation (mmap) failed to map 741867520 bytes for committing reserved memory.
  # Possible reasons:
  #   The system is out of physical RAM or swap space
  #   In 32 bit mode, the process size limit was hit
  # Possible solutions:
  #   Reduce memory load on the system
  #   Increase physical memory or swap space
  #   Check if swap backing store is full
  #   Use 64 bit Java on a 64 bit OS
  #   Decrease Java heap size (-Xmx/-Xms)
  #   Decrease number of Java threads
  #   Decrease Java thread stack sizes (-Xss)
  #   Set larger code cache with -XX:ReservedCodeCacheSize=
  # This output file may be truncated or incomplete.
  #
  #  Out of Memory Error (os_linux.cpp:2673), pid=20080, tid=140319513569024
  #
  # JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
  # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode linux-amd64 compressed oops)
  # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
  #
  </code></pre>
  
  <p>What should I do. Any help would be nice. Thanks a lot. </p>