6

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)

6 Answers 6

8

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.

4

I finally found the answer:

Go to your tomcat bin folder

run "tomcat7w.exe" as Admin

Add this to the java options in the Java tab

-Xms3072M
-Xmx6144M
-XX:PermSize=512m
-XX:MaxPermSize=1024m

For more info check this link

http://community.jaspersoft.com/wiki/configuring-tomcats-java-heap-size

1

I sorted out the same problem by only adding following line in to catalina.bat in windows 7 tomcat 7.

set JAVA_OPTS =" -XX:PermSize=512m -XX:MaxPermSize=1024m" 

I had 4 GB RAM.

0

You can assign those into JAVA_OPTS variable which is located inside of catalina.sh (tomcatPath/bin):

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"

Another possibility is there can be memory leak. You can check here to troubleshooting memory leaks.

4
  • why would I have to change the catalina.sh file now if it worked perfectly on the previous PC, doesn't make sense, and It can't be a memory leak since I am also running the exact same project I've been using for ages on my previous Computer
    – Andre
    Commented Nov 4, 2013 at 14:26
  • 1
    Are you sure about you're using same Java and ide versions? Commented Nov 4, 2013 at 15:10
  • 1
    Regardless of why it would work differently, does it work if you increase the memory?
    – Darius X.
    Commented Nov 4, 2013 at 15:12
  • C:\>java -version = java version "1.7.0_25" C:\>javac -version = javac 1.7.0_25 -- And i've tried all those memory increases
    – Andre
    Commented Nov 5, 2013 at 7:22
0

After many searchs, I found this solution. It worked correctly.

set JAVA_OPTS=%JAVA_OPTS%” with “set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m” in "setenv" batch file which will be in the following path

\jasperreports-server-cp-5.6.0\apache-tomcat\bin

0

I was able to use the suggestions here to debug a problem I was having with Travis CI running out of memory while running Eclipse plugin unit tests. I had to set the MaxPermSize, which I did by adding the following to my java ant task:

<jvmarg line="-Xms40m -Xmx1024m -XX:MaxPermSize=512m"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.