Running 32-bit Apache Tomcat on a 64-bit system with JSVC
I recently ran into a java.lang.OutOfMemoryError exception after moving a Tomcat Web Application from a 32-bit system to a 64-bit system. Not being able to give the JVM more memory, I decided to install a 32-bit JDK on the machine. Getting a 32-bit Tomcat install working on a 64-bit system gave me a bit of trouble, so I decided to write this article.
Installing a 32-bit JDK is very easy. First, download the right package from the sun download site: http://java.sun.com/javase/downloads/index.jsp and extract it. To extract the .bin file, you need need to make sure to make the .bin file executable. After that, you can run the file and it should extract itself to the current directory. You can now use the JDK by referencing it directly or by setting it as an alternative using the appropriate instructions. For the purpose of this article however, we don’t need to get into that. Next, you will need to update your start/stop scripts to take advantage of the new JDK.
Unfortunately, you still have more to do because the start/stop scripts use JSVC to control the Tomcat daemon. If you try to startup tomcat after referencing the new JDK, you will notice that you get an error stating that it cannot locate a valid JVM. This is because the JSVC that has been installed, is a 64-bit binary and is looking for a 64-bit JVM. You will now need to recompile JSVC as a 32-bit binary so that you can use it with your 32-bit JDK. This is where things get a little tricky. After some googling, I found the following instructions. Unfortunately, these instructions didn’t work for me as is.
To compile JSVC, you will first you need to download and extract the JSVC source. Next, make sure you have lib32gcc1 and libc6-dev-i386 installed. On a Debian system you can do this with the following command:
sudo aptitude install lib32gcc1 libc6-dev-i386
If you do not have the packages installed, aptitude will prompt you to install the packages. Next, run the following configure commands to configure and build JSVC:
cd /path/to/jsvc/src/native/unix/
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 LDFLAGS="-L/path/to/32/bit/shared/libraries/" ./configure --with-java=/path/to/32/bit/jdk/ --build=i686-pc-linux-gnu
make
cd native/
gcc -m32 -L/path/to/32/bit/shared/libraries/ -ldl -lpthread jsvc-unix.o libservice.a -o ../jsvc
On a Debian machine the path to your shared libraries might be:
/emul/ia32-linux/usr/lib
By this point, you should have a jsvc binary in your /path/to/jsvc/src/native/unix/ directory. You can move this where ever you like and reference it from your tomcat start/stop scripts. Now, your done!
Tags: Apache, JSVC, Tomcat
Hello very nice blog!! Guy .. Excellent .. Superb .. I’ll bookmark your blog and take the feeds also?I am glad to search out so many helpful info right here within the publish, we need work out more strategies on this regard, thank you for sharing. . . . . .
How much memory can you give Java/Tomcat now?
Patrick, I didn’t go into the details in my post, but the reason my application consumed more memory after switching from 32-bit to 64-bit was due to the fact that now all pointers were now 64-bit references and therefore consumed more memory.
Switching back to a 32-bit JVM didn’t allow me to allocate more memory, it just made my memory usage more efficient.
As a side note, I did some research a few months back and I believe there was an update that let the JVM use compressed, managed pointers to reduce the memory footprint of 64-bit applications.
Running 32-bit Apache Tomcat on a 64-bit system with JSVC – Andrew Vayanis You simply copied an individual else’s tale