Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 OutOfMemoryError from UncaughtExceptionHandler

Ok so I recently moved to a new Computer with a fresh install of Win7 Pro

I copied across all my old files and folders from my old PC

I copied my Tomcat 7 file to the new PC

But now when I try and start it I get this error

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "http-bio-8080-exec-2"

I've looked EVERYWHERE for a solution to this and found hundreds of different ones but none helped me

Any ideas what could cause this error ? (I'm using the exact same tomcat file copied from old PC and exact same project that still works on old PC)

NOTE:

I've set the environmental variables exactly like they were on my old Computer.

I'm using the exact same webapp I've been using for ages on my previous PC (So It cant be a memory leak or something wrong with the project)

like image 842
Andre Avatar asked Nov 04 '13 14:11

Andre


1 Answers

I got the same error message, although from other sources on the web the error message may occur due to running out of heap space, and not just due to running out of permgen space.

I needed to fix this from the command line instead of using a graphical interface. To do that, I added a new file at <tomcat install directory>/bin/setenv.sh with the contents:

CATALINA_OPTS="-Xms4096M -Xmx4096M -XX:PermSize=512M -XX:MaxPermSize=512M"

If you have an existing setenv.sh file, add this to that file. Use whatever numbers are appropriate to your installation - my server has 96GB of memory so I can afford 4GB for Tomcat.

As documented in catalina.sh, you should add this to setenv.sh instead of to catalina.sh so as to keep this local modification separate from the base catalina.sh script. You should change CATALINA_OPTS instead of JAVA_OPTS so as to require the larger amount of memory only for the actual Tomcat server; changing JAVA_OPTS will require the memory for the shutdown process as well, which may interfere with shutdown of the server if the system's memory is running low.

like image 110
Warren Dew Avatar answered Sep 28 '22 17:09

Warren Dew